mirror of https://github.com/Icinga/icinga2.git
parent
beead48302
commit
dcf9e7bfe2
|
@ -28,7 +28,8 @@ usage: $0 options
|
||||||
-H Host name for the check result
|
-H Host name for the check result
|
||||||
-S Service name for the check result. If not provided, a host check result is assumed.
|
-S Service name for the check result. If not provided, a host check result is assumed.
|
||||||
-r Return code of the check result
|
-r Return code of the check result
|
||||||
-o Output of the checkresult
|
-o Output of the check result
|
||||||
|
-T Timestamp of the check result
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +39,10 @@ CMDFILE="/var/run/icinga2/cmd/icinga2.cmd"
|
||||||
HOST=""
|
HOST=""
|
||||||
SERVICE=""
|
SERVICE=""
|
||||||
RETURNCODE=0
|
RETURNCODE=0
|
||||||
OUTPUT="icinga2 extcmdfile test @ `date +%s`"
|
TIMESTAMP="`date +%s`"
|
||||||
|
OUTPUT="icinga2 extcmdfile test @ $TIMESTAMP"
|
||||||
|
|
||||||
while getopts ":c:H:S:r:o:h" opt; do
|
while getopts ":c:H:S:r:o:T:h" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
|
@ -61,6 +63,9 @@ while getopts ":c:H:S:r:o:h" opt; do
|
||||||
o)
|
o)
|
||||||
OUTPUT=$OPTARG
|
OUTPUT=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
T)
|
||||||
|
TIMESTAMP=$OPTARG
|
||||||
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
usage
|
usage
|
||||||
|
@ -74,8 +79,6 @@ while getopts ":c:H:S:r:o:h" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
DATETIME=`date +%s`
|
|
||||||
|
|
||||||
if [ -z "$HOST" ]; then
|
if [ -z "$HOST" ]; then
|
||||||
echo "Host name missing. Please use -H with a valid host name."
|
echo "Host name missing. Please use -H with a valid host name."
|
||||||
usage
|
usage
|
||||||
|
@ -83,9 +86,9 @@ if [ -z "$HOST" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SERVICE" ]; then
|
if [ -z "$SERVICE" ]; then
|
||||||
CMDLINE="[$DATETIME] PROCESS_HOST_CHECK_RESULT;$HOST;$RETURNCODE;$OUTPUT"
|
CMDLINE="[$TIMESTAMP] PROCESS_HOST_CHECK_RESULT;$HOST;$RETURNCODE;$OUTPUT"
|
||||||
else
|
else
|
||||||
CMDLINE="[$DATETIME] PROCESS_SERVICE_CHECK_RESULT;$HOST;$SERVICE;$RETURNCODE;$OUTPUT"
|
CMDLINE="[$TIMESTAMP] PROCESS_SERVICE_CHECK_RESULT;$HOST;$SERVICE;$RETURNCODE;$OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Sending '$ECHO $CMDLINE >> $CMDFILE'"
|
echo "Sending '$ECHO $CMDLINE >> $CMDFILE'"
|
||||||
|
|
Loading…
Reference in New Issue