I'm not exactly sure what the problem is with your module but it appears that you are trying to use a ganglia module for something that ganglia isn't intended for. Ganglia is a metric gathering system rather than a status reporting system. Returning a status of 1 or 2 isn't really what Ganglia is expecting. Nagios would probably be a better choice for just reporting the status of a particular system. Ganglia monitoring is about reporting trends rather than status. Things like CPU or memory usage. You might want to rethink what your module is doing and try to make it report metric values rather than system status.
Brad >>> On 3/8/2010 at 6:45 AM, in message <[email protected]>, <[email protected]> wrote: > Hi > > I'm writting a python module to check the status of a RAID, this is the > module: > > import os > > def raid_handler(name): > > tw_cli = "sudo /usr/local/bin/tw_cli /c0/u0 show status" > out = os.popen(tw_cli) > f = out.read(18) > print f > if f == '/c0/u0 status = OK': > return 1 > else: > return 2 > > def metric_init(params): > global descriptors > > d1 = {'name': 'unit_status', > 'call_back': raid_handler, > 'time_max': 90, > 'value_type': 'uint', > 'units': '', > 'slope': 'both', > 'format': '%u', > 'description': 'catacrocker', > 'groups': 'health'} > > descriptors = [d1] > > 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) > > > The output of the command tw_cli /c0/u0 show status is: > /c0/u0 status = OK > > and I have some problems: when I test the module, executing: > > [r...@oceano ~]# python /usr/lib64/ganglia/python_modules/raid_status.py > > it works well (RAID os OK and it returns "value for unit_status is 1"), but > when > is gmond who use it, it no works, the graphs shown value 2; I also add the > line > "print f" for test and to see the value of f, and it's value is "/c0/u0 > status > = OK", nobody has been added to sudoers so it has the correct permissions. > The > other lines of the module are ok (I used it as template for other similar > modules that work very well) so the problem is o the raid_handler function. > I've tried with this other raid_handler: > > def raid_handler(name): > > tw_cli = "sudo /usr/local/bin/tw_cli /c0/u0 show status" > out = os.popen(tw_cli) > f = out.read(18) > l = f.split() > if l[3] == "OK": > return 1 > else: > return 2 > > When I test it, it works: > > [r...@oceano ~]# python /usr/lib64/ganglia/python_modules/raid_status.py > value for unit_status is 1 > > I also add the lines "print l" and "print l[3]" for test and to see the > value of > l and l[3], and it's values are ['/c0/u0', 'status', '=', 'OK'] and OK. The > graphs don't shown any value, and the /var/log/messages shows: > > Mar 8 14:34:35 oceano /usr/sbin/gmond[16660]: [PYTHON] Can't call the > metric > handler function for [unit_status] in the python module [raid_status]. > > What happens? > > I need help please > > 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 ------------------------------------------------------------------------------ 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

