views:

53

answers:

2

in the python console the following statement works perfectly fine (i guess using eval that way is not really good, but its just for testing purpose in this case and will be replaced with proper parsing)

$ python
>>> import subprocess
>>> r = subprocess.Popen(['/pathto/plugin1.rb'], stdout=subprocess.PIPE, close_fds=True).communicate()[0]
>>> data = eval(r)
>>> data
{'test': 1}

when i convert this into a Serverdensity plugin however it keeps crashing the agent.py daemon everytime it executes the plugin. i was able to narrow it down to the subprocess line but could not find out why. exception catching did not seem to work also.

here how the plugin looks like:

class plugin1:
  def run(self):
    r = subprocess.Popen(['/pathto/plugin1.rb'], stdout=subprocess.PIPE, close_fds=True).communicate()[0]
    data = eval(r)
    return data

I'm quite new to work with python and cant really figure out why this wont work. Thanks a lot for ideas :)

A: 

Do you have subprocess imported in the module? Also what error are you getting could you post the error message ?

anijhaw
Unfortunately i do not get any error message at all, just the daemon process calling the plugin crashes without notice (or i dont know where this notice would appear, not in the daemons log).Here is the source of how the plugin is called:http://github.com/boxedice/sd-agent/blob/master/checks.py#L1167Its still a little beyond my python knowledge (just started today to make a plugin)
maxigs
A: 

After switching my dev box (maybe because of the different python version?) i finally was able to get some proper error output.

Then it was rather simple: I really just needed to import the missing subprocess module.

For who is interested in the solution:

http://github.com/maxigs/Serverdensity-Wrapper-Plugin/blob/master/ruby_plugin.py

Not quite production ready yet, but works already for save input

maxigs