3 #/******************************************************************************
5 # * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
7 # * This program is free software; you can redistribute it and/or *
8 # * modify it under the terms of the GNU General Public License *
9 # * as published by the Free Software Foundation; either version 2 *
10 # * of the License, or (at your option) any later version. *
12 # * This program is distributed in the hope that it will be useful, *
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 # * GNU General Public License for more details. *
17 # * You should have received a copy of the GNU General Public License *
18 # * along with this program; if not, write to the Free Software Foundation *
19 # * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
20 # ******************************************************************************/
24 This script sends check results to an icinga(2) cmd pipe.
27 -c External command pipe file path, e.g. '/var/run/icinga2/icinga2.cmd'
28 -H Host name for the check result
29 -S Service name for the check result. If not provided, a host check result is assumed.
30 -r Return code of the check result
31 -o Output of the checkresult
37 CMDFILE="/var/run/icinga2/cmd/icinga2.cmd"
41 OUTPUT="icinga2 extcmdfile test @ `date +%s`"
43 while getopts ":c:H:S:r:o:h" opt; do
65 echo "Invalid option: -$OPTARG" >&2
70 echo "Option -$OPTARG requires an argument." >&2
79 if [ -z "$HOST" ]; then
80 echo "Host name missing. Please use -H with a valid host name."
85 if [ -z "$SERVICE" ]; then
86 CMDLINE="[$DATETIME] PROCESS_HOST_CHECK_RESULT;$HOST;$RETURNCODE;$OUTPUT"
88 CMDLINE="[$DATETIME] PROCESS_SERVICE_CHECK_RESULT;$HOST;$SERVICE;$RETURNCODE;$OUTPUT"
91 echo "Sending '$ECHO $CMDLINE >> $CMDFILE'"
92 `$ECHO $CMDLINE >> $CMDFILE`