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
|