Discussion:
How to call shell script?
mikea730
2012-01-10 19:52:03 UTC
Permalink
mikea730 [http://community.zenoss.org/people/mikea730] created the discussion

"How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63659#63659

--------------------------------------------------------------
Sorry for what is probably a very basic question that has been asked a bunch of times.  I searched the forum and could not find anything specific.

For a specific device (in /server/linux server for example), what is the easiest way to call a simple shell script and send an alert if the shell script returns a bad return code.  

Thanks!
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63659#63659]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jmp242
2012-01-10 20:23:01 UTC
Permalink
jmp242 [http://community.zenoss.org/people/jmp242] created the discussion

"Re: How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63660#63660

--------------------------------------------------------------
Look in the admin guide regarding command datasources (and the FAQs).

--
James Pulver
ZCA Member
LEPP Computer Group
Cornell University
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63660#63660]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
mikea730
2012-01-10 22:33:33 UTC
Permalink
mikea730 [http://community.zenoss.org/people/mikea730] created the discussion

"Re: How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63662#63662

--------------------------------------------------------------
Thanks for the quick response! 

I'm looking at the documentation (6.3.2 Writing a ZenCommand)  Page 75.

The Docs say to "Create a local copy".  But there is no "Create local copy".  Should I "Add Local Template" or "Override Template here". 

When adding a data source, which template should be used?  Should I use the main template for the device type and make that local?  (Linux would be /Server/Linux ?).  Or create a new template?

Thanks!


--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63662#63662]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
mikea730
2012-01-10 23:05:58 UTC
Permalink
mikea730 [http://community.zenoss.org/people/mikea730] created the discussion

"Re: How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63664#63664

--------------------------------------------------------------
ok, so I created a local copy of the template.  In the datasource I call a test shell script.  If the shell script returns 1, then I get the following alert event.  If it returns 0 it clears. 

Cmd: /home/zenoss/test.sh - Code: 1 - Msg: General

Is that the correct usage of the return codes?  

As far as formatting the alert text, is the only option to do a transform on the Event Class?

Thanks!



--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63664#63664]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jmp242
2012-01-11 12:51:14 UTC
Permalink
jmp242 [http://community.zenoss.org/people/jmp242] created the discussion

"Re: How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63671#63671

--------------------------------------------------------------
That is the correct use of exit codes. I could be wrong, but I believe you can output information in the Nagios format like so:
https://zcaportal.org/wiki/bin/view/ZCA/ZCAFAQ#Command_Based_Data_Sources https://zcaportal.org/wiki/bin/view/ZCA/ZCAFAQ#Command_Based_Data_Sources

When you're talking about alert text (in zenoss alerts are e-mails), you can edit the alerting rule itself to change the e-mail message, or yes, if you want to edit the *event* (the thing in the webGUI) or do changes the alerting rules don't let you, you would use event transforms.

--
James Pulver
ZCA Member
LEPP Computer Group
Cornell University
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63671#63671]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
mikea730
2012-01-11 18:26:46 UTC
Permalink
mikea730 [http://community.zenoss.org/people/mikea730] created the discussion

"Re: How to call shell script?"

To view the discussion, visit: http://community.zenoss.org/message/63681#63681

--------------------------------------------------------------
So here's how it works.

The shell script should return the following via STDOUT

message here will be put in the summary of the alert | datapoint1=999 datapoint2=999

the delimeter is the "pipe" symbol.  Everything before the pipe symbol will be put in the summary of the alert "if" the script returns 1, 2, 3 for the return code.  If the script returns 0, the just the right side data points are returned.

This was not in the documentation.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63681#63681]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...