Archived community.zenoss.org | full text search
Skip navigation
2845 Views 3 Replies Latest reply: Jan 24, 2012 2:26 PM by jcurry RSS
David Sloboda Rank: White Belt 64 posts since
Nov 29, 2007
Currently Being Moderated

Jan 19, 2012 2:35 PM

How to pull Datasource from nagios style script and zencommand?

Zenoss 3.2.1 on RHEL5

 

I have a nagios-style command in libexec that works great.  Command output is in the format:

    Datasource|Datapoint=integer

and the threshold detects on Datapoint.  So far, so good.

 

[zenoss@bby1ems05 ~]$ /opt/zenoss/libexec/lsload-query-command.py

ERROR: kel-lx62 has low free swap, only [2232M] |result=2

[zenoss@bby1ems05 ~]$

 

The challenge I have is that this particular command can produce useful detail in Datasource.

I would like to put that detail into the evt.message

It would help staff who get the alert and who are not Zenoss administrators.

 

[zenoss@bby1ems05 libexec]$ ./lsload-query-command.py

ERROR: kel-lx19 has low free swap, only [7792M]ERROR: kel-lx25 has low free swap, only [4M]ERROR: kel-lx52 has low free swap, only [0M] |result=2

[zenoss@bby1ems05 libexec]$

 

I've searched the forum and these posts, and Jane Curry's event management paper

docs/DOC-2514

docs/DOC-3909

thread/15493

 

I suspect Datasource is thrown away.  I would like to confirm that somehow.


If that part of the output is thrown away, does anyone have any suggestions on how to find that data using an event transform? 

 

Thanks,

David Sloboda

  • jcurry ZenossMaster 1,021 posts since
    Apr 15, 2008

    If the exit status of your script is anything other than 0 (OK), then the text from the datasource is all provided in the event's summary field.  If you wanted to then extract parts of that, you could use an event transform to do stuff.

    Cheers,

    Jane

  • jcurry ZenossMaster 1,021 posts since
    Apr 15, 2008

    No - exit status is not the same as your result variable.  Here is my little test command:

     

    #!/bin/sh

     

    # Nagios return codes

    STATE_OK=0

    STATE_WARNING=1

    STATE_CRITICAL=2

    STATE_UNKNOWN=3

    #

    exitstatus=$STATE_OK

     

    # Nagios format echos information and status followed by pipe |

    #  followed by <var name>=<value> tuples

    # Note that Zenoss datapoints must match these var names exactly

    #

    echo "This is a test - status OK | timevar=1s sizevar=2B percentvar=10% countervar=123c"

    exit $exitstatus

     

    If $exitStatus is anything other than 0 then you get an event whose summary is

    This is a test - status OK

    ie everything upto the pipe symbol.  In addition, you get the timevar, sizevar, percentvar and countervar datapoints.

     

    Cheers,

    Jane

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points