Okay, so I have been strugling with getting a command to run properly from
/ZenEventManager/Event Commands.
The command that I am running is this:
Code:
/usr/local/lib/alert/bin/sendnotification2 1 52 4 1 down
The code for this command is here:
Code:
#!/bin/sh
MyOS=`uname -a \| sed 's/ .*$$//g'`
if [ $$MyOS = "Linux" ]
then
alias "echo"="echo -e"
fi
if [ $$MyOS = "AIX" ]
then
alias "echo"="echo"
fi
binlocation="/usr/local/lib/alert/bin"
if [ $$# -lt 5 ]
then
echo
echo
echo Usage: SendNotification SystemID ActivityID MsgType Severity MsgText
echo " SystemID - The numeric ID of the system"
echo " ActivityID - The numeric ID type of the activity"
echo " MsgType - 1=Error, 2=Warning, 4=Info"
echo " Severity - Higher numbers have more importance"
echo " MsgText - Message enclosed in double quotes"
echo " "
echo "Note: 1) The ID's must be set up on the central server."
echo " 2) The CNSettings.txt file must be in /usr/local/lib/alert."
else
#First, Lets try an XML HTTP post
ReturnVal=`$$binlocation/sendXML $$1 $$2 $$3 $$4 "$$5" `
#if this fails twice, we will send via email
if [ $$ReturnVal -ne 0 ]
then
ReturnVal=`$$binlocation/sendXML $$1 $$2 $$3 $$4 "$$5" `
if [ $$ReturnVal -ne 0 ]
then
ReturnVal=`$$binlocation/sendemail $$1 $$2 $$3 $$4 "$$5" `
fi
fi
fi
After reading though the forums I learned (hopefully correctly) that I have to
double the "$" and put a "\" before the "|".
Without all the doubling and "\"s I can successfully run this command from the
# prompt. Even in the Zenactions log the command processes without errors. But
for some reason it just wouldn't run.
After changing the doubling "$" and adding in "\" (as seen in the code above) I
get the following error in the zenactions log.
> 2009-08-20 10:10:30 INFO zen.ZenActions: Running
> /usr/local/lib/alert/bin/sendnotification2 1 51 4 1 up
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: DELETE FROM alert_state WHERE
> evid='5da2dfbb-9735-4996-bcd8-c4c39c3f91a9' AND userid='' AND
> rule='biscuit'
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 INFO zen.ZenActions: Processed 1 commands in 0.039963
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: SELECT
> device,component,message,firstTime,summary,severity,summary, evid FROM status
> WHERE (prodState = 1000) and (eventState = 0) and (severity >= 4) AND evid
> NOT IN (SELECT evid FROM alert_state WHERE userid='mdavis' AND
> rule='Cn_Test' )
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: SELECT
> h.device,h.component,h.message,h.firstTime,h.summary,h.severity,h.summary,
> h.evid FROM history h, alert_state a WHERE h.evid=a.evid AND
> a.userid='mdavis' AND a.rule='Cn_Test'
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: call age_events(4, 4);
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: SELECT device, component FROM
> status WHERE eventClass = '/Status/Heartbeat'
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: SELECT device, component FROM
> heartbeat WHERE DATE_ADD(lastTime, INTERVAL timeout SECOND) <= NOW();
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 INFO zen.ZenActions: processed 1 rules in 0.07 secs
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
> 2009-08-20 10:10:30 DEBUG zen.ZenActions: Command finished: A process has
> ended with a probable error condition: process ended with exit code 126.
> 2009-08-20 10:10:30 ERROR zen.ZenActions: Command biscuit says /bin/sh:
> /usr/local/lib/alert/bin/sendnotification2: Permission denied
>
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Retrieved a connection; Pool
> size: 0
> 2009-08-20 10:10:30 DEBUG zen.DbConnectionPool: Returned a connection; Pool
> size: 1
>
I just know that I am missing something small. Any help is appreciated it.
Thanks in advance.
Micah
-------------------- m2f --------------------
Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=38208#38208
-------------------- m2f --------------------
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users