root / plugins / ipmi / ipmi_ @ 942bda31
Historique | Voir | Annoter | Télécharger (2,77 ko)
| 1 |
#!/usr/bin/env python |
|---|---|
| 2 |
from commands import getstatusoutput as gso |
| 3 |
|
| 4 |
def safe(s): |
| 5 |
s=s.replace("-", "_")
|
| 6 |
s=s.replace(" ", "_")
|
| 7 |
s=s.replace(".", "_")
|
| 8 |
return s |
| 9 |
|
| 10 |
def config(data,title): |
| 11 |
for i in data: |
| 12 |
print "%s.label %s"%(safe(i[0]), i[0]) |
| 13 |
|
| 14 |
# check for non-critical thresholds |
| 15 |
if i[6] != 'na': |
| 16 |
if i[7] != 'na': |
| 17 |
warning = "%s:%s"%(i[6],i[7]) |
| 18 |
else: |
| 19 |
warning = "%s:"%i[6] |
| 20 |
else: |
| 21 |
if i[7] != 'na': |
| 22 |
warning = "%s"%i[7] |
| 23 |
else: |
| 24 |
warning = "" |
| 25 |
if warning: |
| 26 |
print "%s.warning %s"%(safe(i[0]),warning) |
| 27 |
|
| 28 |
# check for critical thresholds |
| 29 |
if i[5] == 'na': |
| 30 |
i[5] == i[4] # N/A, so see if there is a non-recoverable threshold |
| 31 |
if i[8] == 'na': |
| 32 |
i[8] == i[9] # N/A, so see if there is a non-recoverable threshold |
| 33 |
if i[5] != 'na': |
| 34 |
if i[8] != 'na': |
| 35 |
critical = "%s:%s"%(i[5],i[8]) |
| 36 |
else: |
| 37 |
critical = "%s:"%i[5] |
| 38 |
else: |
| 39 |
if i[8] != 'na': |
| 40 |
critical = "%s"%i[8] |
| 41 |
else: |
| 42 |
critical = "" |
| 43 |
if critical: |
| 44 |
print "%s.critical %s"%(safe(i[0]),critical) |
| 45 |
|
| 46 |
print "graph_title %s"%title |
| 47 |
if title == "Voltages": |
| 48 |
print "graph_args -X 0 --logarithmic -l 1 -u 15" |
| 49 |
#print "graph_args --base 1000 --logarithmic" |
| 50 |
else: |
| 51 |
print "graph_args -l 0" |
| 52 |
print "graph_vlabel %s"%i[2] |
| 53 |
print "graph_period minute" |
| 54 |
print "graph_category IPMI" |
| 55 |
|
| 56 |
def get_data(): |
| 57 |
import sys |
| 58 |
category = sys.argv[0].split("_",1)[1]
|
| 59 |
data = [] |
| 60 |
if category =="Fans": |
| 61 |
ids = ("Fan 1 Tach", "Fan 2 Tach", "Fan 3 Tach",
|
| 62 |
"Fan 4 Tach", "Fan 5 Tach", "Fan 6 Tach",) |
| 63 |
title = "Fan Speed" |
| 64 |
elif category == "Temperature": |
| 65 |
ids = ("Ambient Temp", "Memory Temp",)
|
| 66 |
title = "Temperatures" |
| 67 |
elif category == "Voltage": |
| 68 |
ids = ("Planar 1.5V", "Planar 1.8V",
|
| 69 |
"Planar 3.3V", "Planar 5V", "Planar 12V", |
| 70 |
"Planar VBAT", "CPU 1 VCore", "CPU 2 VCore",) |
| 71 |
title = "Voltages" |
| 72 |
|
| 73 |
status, output = gso("ipmitool sensor")
|
| 74 |
for row in output.split("\n"):
|
| 75 |
items = map(str.strip,row.split("|"))
|
| 76 |
field,value,units,status,lower_nonrecoverable,lower_critical,lower_non_critical,upper_non_critical,upper_critical,upper_nonrecoverable=items |
| 77 |
if field in ids: |
| 78 |
if value == 'na': continue |
| 79 |
data.append(items) |
| 80 |
return data,title |
| 81 |
|
| 82 |
def sample(data): |
| 83 |
for i in data: |
| 84 |
print "%s.value %s"%(safe(i[0]),i[1]) |
| 85 |
|
| 86 |
def main(): |
| 87 |
import sys |
| 88 |
data,title = get_data() |
| 89 |
if 'config' in sys.argv: |
| 90 |
return config(data,title) |
| 91 |
sample(data) |
| 92 |
|
| 93 |
if __name__ == '__main__': |
| 94 |
main() |
| 95 |
|
