Icinga2 Plugins: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „=Example= =Script= =Definition= cat<<HERE >> /usr/share/icinga2/include/command-plugins.conf <pre> object CheckCommand "processes" { import "plugin-c…“) |
|||
| (4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 2: | Zeile 2: | ||
=Script= | =Script= | ||
| + | *cat /usr/lib/nagios/plugins/check_processes | ||
| + | <pre> | ||
| + | #!/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 | ||
| + | </pre> | ||
=Definition= | =Definition= | ||
| − | + | <pre> | |
cat<<HERE >> /usr/share/icinga2/include/command-plugins.conf | cat<<HERE >> /usr/share/icinga2/include/command-plugins.conf | ||
| − | |||
object CheckCommand "processes" { | object CheckCommand "processes" { | ||
import "plugin-check-command" | import "plugin-check-command" | ||
| Zeile 22: | Zeile 62: | ||
} | } | ||
} | } | ||
| + | HERE | ||
</pre> | </pre> | ||
| − | + | ||
| + | =Links= | ||
| + | *https://github.com/Icinga/icingaweb2-module-director/issues/957 | ||
Aktuelle Version vom 20. November 2018, 20:45 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