Icinga2 Plugins

Aus xinux.net
Zur Navigation springen Zur Suche springen

Example

Script

  • cat /usr/lib/nagios/plugins/check_processes
#!/bin/bash
function check_pgrep()
{
for PROC in $PROCS
do
 PROCID=$(pgrep -x $PROC | head -1)
 if test -z "$PROCID"
  then
  ERRLIST="$ERRLIST $PROC"
  fi
done
if [[ -n $ERRLIST ]]
then
 echo "MISSING:$ERRLIST"
 exit 2
else
 echo "OK: $PROCS"
fi
}


while getopts ":p:" opt
do
        case $opt in
       p) PROCS=$OPTARG;;
       \?) echo "USAGE: $0 -p PROC"; exit 2 ;;
        :)
        echo "Option -$OPTARG requires an argument." >&2
         exit 1
        ;;

   esac
done

if test -n "$PROCS"
then
check_pgrep
else
 echo "USAGE: $0 -p PROC"
exit 1
fi

Definition

cat<<HERE >> /usr/share/icinga2/include/command-plugins.conf
object CheckCommand "processes" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_processes" ]
    timeout = 1m
    arguments += {
        "-p" = {
            description = "Programnames"
            required = true
            value = "$processes_names$"
        }
    }
}
HERE

Links