Custom notification commands...old question with new twist...

Lawrence, Lynne LLawrence at osc.uscg.mil
Wed Oct 6 15:21:55 CEST 2004


Steve,

I am not sure that this is what you want, but I have taken advantage of the
fact that comment lines in the .cfg files are ignored to save additional
info in my config files.  For instance, I have a config file for a clustered
service where check_cluster is used to check the cluster.  Rather than
having a separate file for the cluster service defs, I mark the cluster
services with '##', and pick them up when the check command is run.  You
could do something similar by tagging comments, though it might be tedious.

  ## host1 serial_no nnn-nn-nnnn
  ## host1 location Main floor, cabinet 183
  define host {
      use              generic_host
      host_name        host1
      alias            host1
      address          ip_goes_here
  }

Here is the config I am using, as an example.  File cust01_jabber.cfg:

 
#===========================================================================
===
  # This file contains configuration for monitoring the CUST01 jabber
servers.
  # They operate as an active/passive cluster where the jabber service
should
  # be available on one or other of the servers at all times.
 
#===========================================================================
===

 
#---------------------------------------------------------------------------
---
  # Hosts defs
 
#---------------------------------------------------------------------------
---

  # the actual hosts
  define host {
      use              generic_host
      host_name        cust01-prod-jabber01
      alias            cust01-prod-jabber01
      address          ip_goes_here
  }
  define host {
      use              generic_host
      host_name        cust01-prod-jabber02
      alias            cust01-prod-jabber02
      address          ip_goes_here
  }

  # A pseudo host representing the cluster
  define host {
      use              generic_host_nocheck
      host_name        cust01-prod-jabber
      alias            cust01-prod-jabber
      address          None
  }

 
#---------------------------------------------------------------------------
---
  # Services
 
#---------------------------------------------------------------------------
---

  # No notifications if a single cust01 jabber service is not available -
  # check_cluster used to alarm if both are down.
  #
  define service {
      use                     generic-service
      host_name               cust01-prod-jabber01,cust01-prod-jabber02
      service_description     jabber
      check_command           check_jabber
      notification_options    n
  }
  define service {
      use                     generic-service
      host_name               cust01-prod-jabber
      service_description     jabber_cluster
      check_command
check_cluster_service!2!2!etc/cust01_jabber.cfg
  }

 
#---------------------------------------------------------------------------
---
  # check_cluster_service input starts with a '##'
 
#---------------------------------------------------------------------------
---

  ## cust01-prod-jabber01;jabber
  ## cust01-prod-jabber02;jabber

My cluster check command looks like this:

  #
  # Use this to check a service cluster.  The file named by $ARG3$ should
contain
  # lines beginning with '##'.  Each of these lines should contain a
  # <host>;<service> following the '##', with optional spaces in between
  #
  define command {
      command_name    check_cluster_service
      command_line    cat /usr/local/nagios/$ARG3$ | grep '^##' | sed 's/##
*//' | $USER1$/check_cluster --service /usr/local/nagios/var/status.log
$ARG1$ $ARG2$
  }

> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net
> [mailto:nagios-users-admin at lists.sourceforge.net]On Behalf Of Steve
> Gilbert
> Sent: Tuesday, October 05, 2004 4:11 PM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Custom notification commands...old 
> question with
> new twist...
> 
> 
> 
> I've got a variation on a question that has been asked here several
> times before.  Please bear with me...
> 
> I want to modify my notification messages to include such things as
> physical location, serial number, user contact list, vendor contract
> numbers, etc.
> 
> This is simple to do via changing the misccommands.cfg file...lots of
> folks seem to be just having it grep for the appropriate info from a
> flat file or database or whatever.  Simple enough.
> 
> Here's where I'd like to do it a little differently...and I'm not sure
> if this is possible or not.  I'd really like to have all this 
> info come
> straight from my hosts.cfg file somehow.  Is it possible to add in
> another directive to a hosts definition?  I've played around with just
> trying to use the alias directive to hold all this info, but 
> it's pretty
> ugly.  I'd love to have some sort of "notes" directive in here that
> would populate a macro...preferably being able to hold 
> multiple lines of
> info.  It would just be nice to store all this info in one 
> place and not
> have to maintain a hosts.cfg and a separate notes file.  Would this
> require a modification to the core Nagios code?
> 
> Thanks!
> 
> Steve Gilbert
> Unix Systems Administrator
> sgilbert at nvidia.com
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on 
> ITManagersJournal
> Use IT products in your business? Tell us what you think of 
> them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to 
> find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS 
> when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
> 


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list