-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorcli-disk-check.py
executable file
·47 lines (38 loc) · 1.07 KB
/
storcli-disk-check.py
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
#!/usr/bin/python3
# used as a cron checker
# use --test to check agains test file storcli-disk-failed.txt
# python3 as a requirement for subprocess.run()
import subprocess
import sys
err = 0
if len(sys.argv) > 1 and sys.argv[1] == '--test':
f = open("storcli-disk-failed.txt", "r")
freadlist = f.readlines()
f.close()
output = ""
output = output.join(freadlist)
else:
try:
cmd = ["/usr/bin/storcli", "/c0/vall", "show"]
cp = subprocess.run(cmd, capture_output=True,
universal_newlines=True,
check=True)
output, rc, err = cp.stdout, cp.returncode, cp.stderr
except:
print("exception running " + ' '.join(cmd))
quit()
if err:
print(rc, err)
quit()
dash = 0
for line in output.split('\n'):
if line.startswith('---'):
dash = dash+1
elif dash == 2:
data = line.split(' ')
#
# if disk state is not Optimal , print and exit
if data[4] != 'Optl':
print(output)
quit()
# vim: set syntax=python: