You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Apache Wiki <wi...@apache.org> on 2014/03/24 22:58:31 UTC

[Tomcat Wiki] Update of "tools/nagios-send-passive-check.sh" by ChristopherSchultz

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.

The "tools/nagios-send-passive-check.sh" page has been changed by ChristopherSchultz:
https://wiki.apache.org/tomcat/tools/nagios-send-passive-check.sh

New page:
{{{
#!/bin/sh
#
# nagios-send-passive-check.sh
#
# Sends a passive-check to a Nagios service.
#
# Copyright (c) 2014 Christopher Schultz
#
# Christopher Schultz licenses this file to You under the Apache License,
# Version 2.0 (the "License"); you may not use this file except in
# compliance with the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

NAGIOS_BASE_URL=https://localhost/nagios
NAGIOS_USER=nagios
NAGIOS_PASSWORD=[specify]

DEFAULT_HOST=
DEFAULT_SERVICE=
# Plugin states: 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN
DEFAULT_STATE=2
DEFAULT_STATUS=CRITICAL
DEFAULT_PERFORMANCE=

HOST=${1:-"${DEFAULT_HOST}"}
SERVICE=${2:-"${DEFAULT_SERVICE}"}
STATE=${3:-"${DEFAULT_STATE}"}
STATUS_STRING=${4:-"${DEFAULT_STATUS}"}
PERFORMANCE=${5:-"${DEFAULT_PERFORMANCE}"}

LOG="/tmp/nagios-passive-check.log.$$"

curl -si --user "${NAGIOS_USER}:${NAGIOS_PASSWORD}' \
     --data-urlencode 'cmd_typ=30' \
     --data-urlencode 'cmd_mod=2' \
     --data-urlencode "host=$HOST" \
     --data-urlencode "service=$SERVICE" \
     --data-urlencode "plugin_state=$STATE" \
     --data-urlencode "plugin_output=$STATUS_STRING" \
     --data-urlencode "performance_data=$PERFORMANCE" \
     "${NAGIOS_BASE_URL}/cgi-bin/cmd.cgi" \
     | tee "$LOG" 2>&1 \
     | grep -q "successfully submitted"

result=$?

if [ "0" != "$result" ] ; then
        echo  Error submitting passive-check to Nagios:
        echo HOST=$HOST
        echo SERVICE=$SERVICE
        echo STATE=$STATE
        echo STATUS_STRING=$STATUS_STRING
        echo PERFORMANCE_DATA=$PERFORMANCE
        cat "$LOG"
fi

rm "$LOG"
}}}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org