I do include that in all my py modules, I just wanted to debug in the
callback function to see if the values were different there when
ganglia runs in debug.  The debug information returns the correct
value.

# ./lsof.py
value for metric1 is 235
value for metric2 is 232

It's very strange.. i'm looking at using something else other than
commands.getstatusoutput() for the lsof call at the moment, but
obviously commands.getstatusoutput() is cleaner.

2009/8/20 Brad Nicholes <bnicho...@novell.com>:
>>>> On 8/20/2009 at 9:01 AM, in message
> <68fea9390908200801m3e1f43ecy2c33e743ccc0d...@mail.gmail.com>, Matt
> <mattmora...@gmail.com> wrote:
>> Hi all,
>>
>> I'm getting inconsistent results when gmond is running my python module
>>
>> # gmond --version
>> gmond 3.1.2
>>
>> # ./lsof.py
>> (0, '2699')
>> 2699
>> 2700
>> 1000
>>
>> # gmond -d1
>> (0, '535')
>> 551
>> 552
>> 1000
>>
>> --- python code ---
>> #!/usr/bin/python
>>
>> import commands
>>
>> def lsof_handler(name):
>>     cmd = 'lsof -p 3123 | wc -l'
>>     lsof = commands.getstatusoutput(cmd)[1]
>>     print commands.getstatusoutput(cmd)
>>     print lsof
>>     print int(lsof) + 1
>>     lsof = 1000
>>     print lsof
>>
>> Any ideas? i've got a similar function that uses
>> commands.getstatusoutput() to grab the pid of a process which works
>> fine.
>>
>
> I would suggest adding something like the following to your python module and 
> then running it as a stand alone script outside of gmond to see what your 
> module is returning.  I haven't see any problems like this with any other 
> python module.
>
>
> #This code is for debugging and unit testing
> if __name__ == '__main__':
>
>    # If your module expects configuration parameters, adjust
>    # this line to match the expected parameters
>    params = {'RandomMax': '500',
>        'ConstantValue': '322'}
>    # Manually call the metric_init function
>    metric_init(params)
>
>    # Manually call the callback that where defined in the
>    # metric descriptor.  Then prin the return values.
>    for d in descriptors:
>        v = d['call_back'](d['name'])
>        print 'value for %s is %u' % (d['name'],  v)
>
>
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ganglia-general mailing list
Ganglia-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-general

Reply via email to