-
Notifications
You must be signed in to change notification settings - Fork 16
/
md3000.py
48 lines (40 loc) · 1.28 KB
/
md3000.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
48
#!/usr/bin/env python
import sys
import os
import subprocess
# settings
controller = '192.168.0.1'
def smcli(p):
try:
return subprocess.check_output(['sudo', 'SMcli', controller, '-S', '-c', p])
except Exception, e:
print "Plugin Failed: %s" % e
sys.exit(2)
success_message = "OK - "
fail_message = "FAIL! - "
critical = False
health_output = smcli('show storageArray healthStatus;')
if health_output.strip() == 'Storage array health status = optimal.':
success_message += "Array is Healthy. "
else:
fail_message += "Array is Critical. "
critical = True
virtualdisk_output = smcli('show allvirtualdisks summary;')
table = virtualdisk_output.split('\n')[5:]
for line in table:
if 'Optimal' not in line and len(line) > 0:
fail_message += line.split(' ')[0] + ' is not optimal. '
critical = True
success_message += "Virtual disks healthy. "
unreadable_output = smcli('show storageArray unreadablesectors;')
if unreadable_output.strip() == 'There are currently no unreadable sectors on the storage array.':
success_message += "No unreadable sectors. "
else:
fail_message += "Array has unreadable sectors! "
critical = True
if critical:
print fail_message
sys.exit(2)
else:
print success_message
sys.exit(0)