Icinga2 Plugins: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Script) |
(→Script) |
||
| Zeile 3: | Zeile 3: | ||
=Script= | =Script= | ||
*cat /usr/lib/nagios/plugins/check_processes | *cat /usr/lib/nagios/plugins/check_processes | ||
| − | < | + | <pre> |
#!/bin/bash | #!/bin/bash | ||
function check_pgrep() | function check_pgrep() | ||
| Zeile 45: | Zeile 45: | ||
exit 1 | exit 1 | ||
fi | fi | ||
| − | <pre> | + | </pre> |
=Definition= | =Definition= | ||
Version vom 20. November 2018, 17:57 Uhr
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