-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_repl.py
More file actions
executable file
·53 lines (40 loc) · 996 Bytes
/
check_repl.py
File metadata and controls
executable file
·53 lines (40 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only
# - flo932@uxsrv.de micha.r
import os
import subprocess
cmd='/usr/bin/checkzfs --remote={pve} --filter tank/{ds} --replicafilter etank/crypt-repl/{ds} --prefix ""'
cmd=cmd.format(ds="everest" ,pve="router01")
#cmd="ls -l"
print(cmd)
r = os.popen(cmd)
if not r:
_exit += 1
lines = r.readlines()
print("---")
import json
perf = []
_max = 79
_exit = 3 #unknown
if lines:
for line in lines:
line=line.strip()
j=line
print("line:",line)
continue
try:
u = 10 #int(j["CAP"][:-1])
if u > _max:
_exit = 2 # krit
if u > _max-5:
if _exit not in [2]: #== 3:
_exit = 1 # warn
pf = "|{}={};{};{}".format(d,u,_max-10,_max)
perf.append(pf)
except Exception as e:print(e)
print()
print("exit:",_exit)
if perf:
for i,p in enumerate(perf):
print(p)
print()