pcp
[Top] [All Lists]

Python pmda instances

To: PCP Mailing List <pcp@xxxxxxxxxxx>
Subject: Python pmda instances
From: Martins Innus <minnus@xxxxxxxxxxx>
Date: Fri, 13 Feb 2015 14:33:52 -0500
Delivered-to: pcp@xxxxxxxxxxx
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
Hi,
I am trying to write a python PMDA (since the thing i am trying to monitor only has python and not perl bindings) and am running into an implementation problem, likely due to my python knowledge. In perl you can do (simplified):

our %h = ();
$h{$nfsinst} = {};
$h{$nfsinst}->{'nfsclient.export'} = $export;
$h{$nfsinst}->{'nfsclient.mountpoint'} = $mtpt;
.......
$pmda->replace_indom($nfsclient_indom, \%h);
.......
my $lookup = pmda_inst_lookup($nfsclient_indom, $inst);

Basically to have a hash of hashes with all the information for the instances stored in the cache and this works as it seems to be intended.



But in python when I do what I think is the equivalent thing:


self.cards = {}
self.cards[device] = {}
self.cards[device]['numcores'] = mic.mic_get_cores_count()

self.replace_indom(self.card_indom, self.cards)


I get the following:

File "pmdamic.py", line 42, in update_mic
    self.replace_indom(self.card_indom, self.cards)
File "/usr/lib64/python2.6/site-packages/pcp/pmda.py", line 218, in replace_indom
    replacement = pmdaIndom(indom, insts)
File "/usr/lib64/python2.6/site-packages/pcp/pmda.py", line 105, in __init__
    self.set_instances(indom, insts)
File "/usr/lib64/python2.6/site-packages/pcp/pmda.py", line 128, in set_instances
    self.set_dict_instances(indom, insts)
File "/usr/lib64/python2.6/site-packages/pcp/pmda.py", line 120, in set_dict_instances LIBPCP_PMDA.pmdaCacheStore(indom, cpmda.PMDA_CACHE_ADD, key, byref(insts[key]))
TypeError: byref() argument must be a ctypes instance, not 'dict'


I can work around this by just storing an index instead, but I don't know enough about python to know if there is a way to make that cast work.

Thanks

Martins

<Prev in Thread] Current Thread [Next in Thread>