TECHZEN Zenoss User Community ARCHIVE  

Command content Included in notification Email

Subject: Command content Included in notification Email
Author: [Not Specified]
Posted: 2014-05-19 13:14

Hello,
I am currently working on a way to monitor a ceph cluster. I already have a shell script that returns the status and health information on the cluster the out put looks similar to this.

status=1,message= cluster "mac address of node the command was executed on"
health HEALTH_OK
monmap e1: 3 mons at {ceph006=0.0.0.0 136:6789/0,ceph007=0.0.0.0:6789/0,ceph008=0.0.0.0:6789/0}, election epoch 102, quorum 0,1,2 ceph006,ceph007,ceph008
osdmap e1146: 11 osds: 11 up, 11 in
pgmap v7171245: 1088 pgs, 3 pools, 604 GB data, 152 kobjects
1798 GB used, 18629 GB / 20428 GB avail
1088 active+clean
client io 828 kB/s wr, 77 op/s

So what i have setup to trigger an alert is if status=1 everything is fine if it =0 then zenoss sends me and alert stating that the health of the cluster has changed.

Now what I would really like is to include the output above in the email notification that zenoss fires off to me when the status=0. Is this possible if so, how do you include the output in the notification email.



Subject: The easiest way will be to
Author: [Not Specified]
Posted: 2014-05-21 09:26

The easiest way will be to not use a trigger, instead create an event from the script itself, that way you can easily make the event's message whatever you want.

An example:
zensendevent -c /App/Fail -p sky -s Critical The server blew up

Hydruid



Subject: zensendevent
Author: [Not Specified]
Posted: 2014-05-21 12:00

could you explain zensendevent I am still fairly new to zenoss and haven't heard of zensendevent or how it works.



Subject: The basic definition is that
Author: [Not Specified]
Posted: 2014-05-21 12:04

The basic definition is that you can use it to create events from the CLI. Typically it's used for creating "dummy" events test test triggers/notifications. However I've used it before with a custom script to generate events. It's already installed, just has to be called by the zenoss user!

Hydruid



Subject: Thanks for the explanation I
Author: [Not Specified]
Posted: 2014-05-21 14:39

Thanks for the explanation I did some experimenting with the command and also ran across some posts that state that it can be installed and used on any instance so long that python is installed(which it is in my case). So I went a head an installed it but when I go to call the command I get permission denied. I am assuming this is because it needs to be run as the zenoss user. So what is the benefit of installing it on a remote server if it doesn't run with out the zenoss user



Subject: The benefit is that it allows
Author: [Not Specified]
Posted: 2014-05-21 15:09

The benefit is that it allows you to create events (with output from your script) directly from your script, even if you have to run it as the zenoss user. Also depending on the language you're using, it's not very difficult to run the script as another user and just run zensendevent as the zenoss user.

#Bash example
su -l -c "$ZENHOME/bin/zensendevent -c /App/Fail -p sky -s Critical The server blew up" zenoss

Hydruid



Subject: Another option if you want to
Author: [Not Specified]
Posted: 2014-05-21 15:12

Another option if you want to continue using the threshold, is to let the threshold create the event, and then use a zendmd script to update the event with output from your script.

Hydruid



Subject: command
Author: [Not Specified]
Posted: 2014-05-21 16:15

here is the issue i am dealing with the command ceph -s or ceph health can not be run from the node in which zenoss is installed they have to be ran locally on the nodes in which ceph is installed. What I would like to do is have zenoss send an alert when the output of ceph health is not equal to HEALTH_OK and and in that alert or a separate notification send the output of the ceph -s command. With what I am understanding from the previous posts both the zensendevent and zendmd command can only be executed from the node that zenoss lives on.



Subject: Remote
Author: [Not Specified]
Posted: 2014-05-22 10:01

If that is the case, you could use SSH to run the script on the remote node.
http://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-shell-sc...

Another option is to run the script on node and transfer the results (ftp, sftp, mysql) back to the zenoss server, then have a script on the zenoss server that checks the file to see if it needs to create an event.

There are many ways that you can accomplish this!

Hydruid



Subject: ok lets start from the
Author: [Not Specified]
Posted: 2014-05-22 16:52

ok lets start from the beginning, since I found out what i had returns and error. I have the following set up in a local template i have a command setup with use ssh checked the command is /usr/local/bin/cephHealth which is the location of the script. IN configuration properties zencommanduser is set to root (for testing purposes for now). When i run the command the output returned is:

Preparing Command...
Executing command /usr/local/bin/cephHealth against node006.medoraco.com
/bin/sh: /usr/local/bin/cephHealth: Permission denied
DONE in 0 seconds

when i call the file as root on the server it executes, but on zenoss it tells me permission denied.



Subject: Root
Author: [Not Specified]
Posted: 2014-05-23 08:10

I highly recommend using a different user than root, and I suspect that the server might be blocking SSH access for root or stopping the command from running. Set it up as another user and make sure to put the user's password in there as well, and verify that user has SSH access.

Hydruid



< Previous
Internal exception processing event: IndexError('list index out of range',)
  Next
event suppression issue
>