Announcement

Collapse
No announcement yet.

Shown Invalid Service Status Value in Nagios network application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shown Invalid Service Status Value in Nagios network application

    Hi
    Iam using nagios network application when i trying to found service status value.But finally it shown invalid status value in nagios application. I wrote a code as mentioned below

    Code:
    #!/bin/sh
    host="$1"
    service="$2"
    /etc/init.d/$service status | while read t
    echo $t
    do
    if [[ "$t" == *running* ]]
    then
            echo "Service is running "
    else
            echo "Service is stopped"
    
    fi
    done
    But as mentioned above code running in command prompt on fedora linux,it shown a correct service status value.But when i trying from nagios.It shows a invalid status value.

    If any plugins for checking a service status value or any modification. Please suggest to me on this issue.
    Last edited by sureshkumar.repaka; 19 April 2007, 13:17.

  • #2
    do you try your script under nagios user or under root ?
    Intel(R) Xeon(TM) CPU 3.4GHz - MemTotal : 1034476 kB
    Centreon 2.4.1 - Nagios 3.2.1 - Nagios Plugins 1.4.15 - Manubulon Plugins tuné
    Fedora Core 5 - 2.6.20-1.2320

    Comment


    • #3
      Shown Invalid Service Status Value in Nagios network application

      This script excuting in "root"

      Comment


      • #4
        Hi,

        I'm not really sure if I understand what you want to do, but here is my view:

        You want this script beeing used as a check with Nagios ?!

        If so, then you made a HUGE mistake. Every Plugin/Check-Script MUST return status as descripted in the nagios documentation. (Exit-Value of the Script must be: 0, 1, 2, 3 which means for Nagios: 0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN) If your Check doesn't return these values (your script returns 0 everytime - no matter if there are services running), nagios can't treat it right. The data which service is running of not, can be outputted as text or perfdata.

        Please read the section about plugins in the nagios documentation.

        Yours,

        Ira

        Comment


        • #5
          Thanks Iralein.After some modifcations,I trying to excuted as below code
          Code:
          #!/bin/sh
          host="$1"
          service="$2"
          t=$(/etc/init.d/$service status)
          if echo "$t" |grep -q running; then 
                   echo "OK - $service service is running."
                   exit 0
          else
                   echo "Critical - $service service is stopped."
                   exit 2
          fi

          return 0 while running a service from command prompt and configure in nagios as mentioned below code

          Code:
          define command{
                  command_name    check_localhost_service
                  command_line    $USER1$/check_service_status localhost $ARG1$
          }
          
          define service{
                  use                      local-service ; Name of service template to use
                  host_name               localhost
                  service_description      acpid service status
                  normal_check_interval  1
                  check_command	 check_localhost_service!acpid
          }
          But the same script is excuting in nagios and it returns a "Critical - $service service is stopped." while running a service.In nagios doesn't excute the "/etc/init.d/$service status" command.Please any solution on this issue.

          Comment


          • #6
            Hi,

            I've tested your script, but it has one fault.
            In my system nagios is not root and only root can run /etc/init.d/acpid status. (s-Bit will change nothing, because s-Bit on scripts are not allowed)
            So you have to change the permissions of acpid which isn't very good, or you find an other solution with checkproc or something like that.
            Bye,

            Ira

            Comment

            Working...
            X