calling external program

hkung1 thkung at yahoo.com
Fri Apr 11 09:02:38 CEST 2003


I'm using check command - check_http to check http status for one of my server(namely PSSR06, defined in hosts.cfg,) that's being monitored. Whenever check_http returns a status warning, i'll need to execute script_test which will then execute my java program. 
Below are the configuration that i've done so far:

services.cfg 
------------
define service{
        use                             generic-service         ; Name of service template to use

        host_name                       PSSR06
        service_description             my-HTTP
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           120
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_my_http
}

checkcommands.cfg
-----------------
define command{
        command_name    check_my_http
        command_line    $USER1$/script_test
}

Below is my script:
#!/bin/bash

cStatus=1

result="`/usr/local/nagios/libexec/check_http -I 172.20.0.0`"

#echo $result

if [ "$result" == "HTTP ok: HTTP/1.1 200 OK - 0.003 second response time |time= 0.003" ]; then
        echo "http status ok"
        cStatus=0
        exit $cStatus
elif [ "$result" == "HTTP WARNING: HTTP/1.1 403 Access Forbidden" ]; then
        echo "http with warning status"
        java sendSMS
        cStatus=1
        exit $cStatus
else
        echo "http with critical status";
        cStatus=2
        exit $cStatus
fi

This script works fine when i execute it manually. However, it doesn't seem to be triggered by Nagios eventhough the HTTP is returning "HTTP WARNING: HTTP/1.1 403 Access Forbidden" as checked in the script. Can anyone help? Thanks in advance!




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list