4. Plugin Format for ZenCommands

Nagios® plugins are configured using a Command Template that is much like the RRDTemplates used for performance monitoring. So a template named “Device” will bind to all devices below the template definition. Within each template is a list of commands that will run. The commands can be any program that follows the Nagios® plug-in standard (inputs are command line arguments output is first line of stdout plus a return code) as defined in:

http://nagiosplug.sourceforge.net/developer-guidelines.html

A Nagios® command has several fields:

  • name – name of the command object

  • enabled – should this command be used on a give device

  • component – the component name to use when zencommand sends events to Zenoss

  • event class – the event class to used when sending events to Zenoss

  • severity – the default severity to use when sending events to Zenoss

  • cycle time – how often a command should be run in seconds

  • command template – the command to run

    The command template string is built using Zope TALES. Several variables are passed when evaluating the template. They are:

  • zCommandPath – The path to the zencommand plug-ins on a given box it comes from the zProperty zCommandPath. zCommandPath will be automatically added to a command if a path is absent from the beginning of the beginning of the command.

  • devname – The device name of the device against which the command is being evaluated

  • dev – The device object against which the command is being evaluated

  • here – The context of evaluation. For a device, this is equivalent to dev for a component such as a filesystem or interface this is the component object

  • compname – If this command evaluates against a component, this is its name as a string

  • now – The current time

    Template values are accessed like shell variables. They are the same as the expression syntax used in the section of this guide called TALES Expressions. Here are some examples:

    Run an http check against all devices using the url /zport/dmd

    check_http –H ${devname}-u /zport/dmd

    In a template named FileSystem the following command will run against all FileSystems on a device.

    check_disk –w 10% -c 5% -p ${compname}