jcurry
2013-04-11 15:54:42 UTC
jcurry [http://community.zenoss.org/people/jcurry] created the discussion
"Command Notification to run a python script"
To view the discussion, visit: http://community.zenoss.org/message/72786#72786
--------------------------------------------------------------
Zenoss 4.2.3.
I want a command notification to run a python script.
Script is:
[***@zen42 local]$ cat change_summary_command.py
#!/usr/bin/env python
#
# First parameter is evt/evid - event id
import sys
import os
import time
#import Globals
zenhome = os.environ['ZENHOME']
of = open(os.path.join(zenhome, 'local', 'change_summary_command.out'), 'a')
evid = sys.argv[1]
localtime = time.asctime( time.localtime(time.time()) )
of.write(' Time is %s Event id %s \n' % (localtime, evid))
of.close()
sys.exit()
It is called from an enabled command notification that says:
/opt/zenoss/local/change_summary_command.py ${evt/evid}
It fails - I am pretty sure in calling the python.
zenactiond.log has:
2013-04-11 16:41:26,997 DEBUG zen.processqueue: execution time 0.292196035385 seconds; queue time 0.000481128692627 seconds; process process /bin/sh -c /opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2be44f810f9
2013-04-11 16:41:26,997 DEBUG zen.actions: Command finished: 'A process has ended with a probable error condition: process ended with exit code 1.'
I have tried with both single and double quotes around the whole notification command which produces:
2013-04-11 16:45:40,992 DEBUG zen.processqueue: execution time 0.210268974304 seconds; queue time 0.000412940979004 seconds; process process /bin/sh -c "/opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2bedc54638e"
2013-04-11 16:45:40,992 DEBUG zen.actions: Command finished: 'A process has ended with a probable error condition: process ended with exit code 127.'
Have also tried with /usr/bin/python explicitly on the front of the notification command - same 127 error.
Running the command reported in zenactiond.log, from a command line, such as:
/bin/sh -c "/opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2bedc54638e"
works perfectly, so I think it has to be to do with shells / environment.
Can anyone share a working example of calling a python script from a command notification in 4.2.3??
Thanks,
Jane
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72786#72786]
Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
"Command Notification to run a python script"
To view the discussion, visit: http://community.zenoss.org/message/72786#72786
--------------------------------------------------------------
Zenoss 4.2.3.
I want a command notification to run a python script.
Script is:
[***@zen42 local]$ cat change_summary_command.py
#!/usr/bin/env python
#
# First parameter is evt/evid - event id
import sys
import os
import time
#import Globals
zenhome = os.environ['ZENHOME']
of = open(os.path.join(zenhome, 'local', 'change_summary_command.out'), 'a')
evid = sys.argv[1]
localtime = time.asctime( time.localtime(time.time()) )
of.write(' Time is %s Event id %s \n' % (localtime, evid))
of.close()
sys.exit()
It is called from an enabled command notification that says:
/opt/zenoss/local/change_summary_command.py ${evt/evid}
It fails - I am pretty sure in calling the python.
zenactiond.log has:
2013-04-11 16:41:26,997 DEBUG zen.processqueue: execution time 0.292196035385 seconds; queue time 0.000481128692627 seconds; process process /bin/sh -c /opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2be44f810f9
2013-04-11 16:41:26,997 DEBUG zen.actions: Command finished: 'A process has ended with a probable error condition: process ended with exit code 1.'
I have tried with both single and double quotes around the whole notification command which produces:
2013-04-11 16:45:40,992 DEBUG zen.processqueue: execution time 0.210268974304 seconds; queue time 0.000412940979004 seconds; process process /bin/sh -c "/opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2bedc54638e"
2013-04-11 16:45:40,992 DEBUG zen.actions: Command finished: 'A process has ended with a probable error condition: process ended with exit code 127.'
Have also tried with /usr/bin/python explicitly on the front of the notification command - same 127 error.
Running the command reported in zenactiond.log, from a command line, such as:
/bin/sh -c "/opt/zenoss/local/change_summary_command.py 000c29d9-f87b-8309-11e2-a2bedc54638e"
works perfectly, so I think it has to be to do with shells / environment.
Can anyone share a working example of calling a python script from a command notification in 4.2.3??
Thanks,
Jane
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72786#72786]
Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]