diff --git a/tools/scripts/process_check_result b/tools/scripts/process_check_result index 229b671e7..50cf7b1e5 100755 --- a/tools/scripts/process_check_result +++ b/tools/scripts/process_check_result @@ -28,7 +28,8 @@ usage: $0 options -H Host name for the check result -S Service name for the check result. If not provided, a host check result is assumed. -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 } @@ -38,9 +39,10 @@ CMDFILE="/var/run/icinga2/cmd/icinga2.cmd" HOST="" SERVICE="" 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 h) usage @@ -61,6 +63,9 @@ while getopts ":c:H:S:r:o:h" opt; do o) OUTPUT=$OPTARG ;; + T) + TIMESTAMP=$OPTARG + ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -74,8 +79,6 @@ while getopts ":c:H:S:r:o:h" opt; do esac done -DATETIME=`date +%s` - if [ -z "$HOST" ]; then echo "Host name missing. Please use -H with a valid host name." usage @@ -83,9 +86,9 @@ if [ -z "$HOST" ]; then fi if [ -z "$SERVICE" ]; then - CMDLINE="[$DATETIME] PROCESS_HOST_CHECK_RESULT;$HOST;$RETURNCODE;$OUTPUT" + CMDLINE="[$TIMESTAMP] PROCESS_HOST_CHECK_RESULT;$HOST;$RETURNCODE;$OUTPUT" else - CMDLINE="[$DATETIME] PROCESS_SERVICE_CHECK_RESULT;$HOST;$SERVICE;$RETURNCODE;$OUTPUT" + CMDLINE="[$TIMESTAMP] PROCESS_SERVICE_CHECK_RESULT;$HOST;$SERVICE;$RETURNCODE;$OUTPUT" fi echo "Sending '$ECHO $CMDLINE >> $CMDFILE'"