Hi everybody, I have a problem with this python module: smartest_new.py
import os
descriptors = list()
def smart_handler(name):
comando = "sudo /usr/sbin/smartctl -H " + d['mount']
out = os.popen(comando)
for c in out:
if c.startswith("SMART"):
l = c.split()
if l[5] == "PASSED":
return 0
else:
return 1
def smart_handler_2(name):
comando = "sudo /usr/sbin/smartctl -l error " + d['mount']
out = os.popen(comando)
i = 0
for c in out:
i = i + 1
if i != 6:
continue
elif c.startswith("No Errors Logged"):
return 0
else:
return 1
def smart_handler_3(name):
comando = "sudo /usr/sbin/smartctl -l selftest " + d['mount']
out = os.popen(comando)
i = 0
for c in out:
i = i + 1
if i == 7:
l = c.split()
if (l[4] == "Completed" and l[5] == "without" and l[6] == "error")
or l[4] == "Aborted":
return 0
else:
return 1
def Init_Metric (vol, name, handler):
'''Create a metric definition dictionary object for a device.'''
metric_name = vol + name
metric_group = vol + " SMART"
d = {'name': metric_name,
'call_back': handler,
'time_max': 90,
'value_type': 'uint',
'units': '',
'slope': 'both',
'format': '%u',
'description': '0:No errors 1:There is any error',
'mount': vol,
'groups': metric_group}
return d
def metric_init(params):
global descriptors
for c in os.popen("ls /dev/sd[a-z]"):
l = c.split()
print 'Discovered device %s' % l[0]
descriptors.append(Init_Metric(l[0], '_smartest_I', smart_handler))
descriptors.append(Init_Metric(l[0], '_smartest_II', smart_handler_2))
descriptors.append(Init_Metric(l[0], '_smartest_III', smart_handler_3))
return descriptors
def metric_cleanup():
'''Clean up the metric module.'''
pass
#This code is for debugging and unit testing
if __name__ == '__main__':
metric_init(None)
for d in descriptors:
v = d['call_back'](d['name'])
print 'value for %s is %u' % (d['name'], v)
It works well when I execute it at command line:
[r...@meteo2 ~]# python /usr/lib64/ganglia/python_modules/smartest_new.py
Discovered device /dev/sda
value for /dev/sda_smartest_I is 0
value for /dev/sda_smartest_II is 0
value for /dev/sda_smartest_III is 0
But it don't show any graph, only the names. The permissions of nobody are
correct , it's checked. The .pyconf archive is:
modules {
module {
name = "smartest_new"
language = "python"
}
}
collection_group {
collect_every = 10
time_threshold = 50
metric {
name = "/dev/sda_smartest_I"
title = "sda SMART overall-health self-assessment test"
value_threshold = 1.0
}
}
collection_group {
collect_every = 10
time_threshold = 50
metric {
name = "/dev/sda_smartest_II"
title = "sda SMART Error Log"
value_threshold = 1.0
}
}
collection_group {
collect_every = 10
time_threshold = 50
metric {
name = "/dev/sda_smartest_III"
title = "sda SMART Self-test log"
value_threshold = 1.0
}
}
someone knows what is the problem?
I need your help
Thank you
ICV
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ganglia-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-general