Ad Widget

Collapse

check service status on Linux

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • natalia
    Senior Member
    • Apr 2013
    • 159

    #1

    check service status on Linux

    Hello,

    I am using Zabbix 2.0.5.
    I want to check "puppet" service on Linux servers.

    %service puppet status

    There are 4 possible values:

    0 - puppetd (pid 1069) is running...
    1 - puppetd is stopped
    2 - puppet: unrecognized service
    3 - puppet in maintenance state (?)

    The following alerts should be sent :
    0 - "OK"- "Puppet is running" (will Ack. any of the below alerts)
    1- "Critical" - "Puppet is not running"
    2 - "Information" - "Puppet is unrecognized service"
    3 - "Information" - "Puppet is in maintenance mode"

    I find the item "proc.num" but it don't return status of service.

    How can I config the above checks/alerts ?
    I don't believe that nobody was needed this but can't find any info.

    Please help.
    Thanks
  • Colttt
    Senior Member
    Zabbix Certified Specialist
    • Mar 2009
    • 878

    #2
    ehm thats an nagios-check, right?

    please post the complete script, there is a description how nagios get the different stati
    Debian-User

    Sorry for my bad english

    Comment

    • natalia
      Senior Member
      • Apr 2013
      • 159

      #3
      Originally posted by Colttt
      ehm thats an nagios-check, right?

      please post the complete script, there is a description how nagios get the different stati
      Thanks for the reply,
      I don't using nagios and didn't find any check_service nagios plugin.
      I put a "puppet" as an example, it can be any other our service "kuku" - I just try to understand how to config this ?

      The script can be like this :

      % check_service.sh
      #!/bin/sh
      service="$1"
      status=`/sbin/service $service status`
      if echo "$status" |grep -q running; then
      echo "Status 0 - OK : $service is running"
      else
      if echo "$status" | grep -q stopped; then
      echo "Status 1 - Critical : $service is not running"
      else
      echo "Status 2 - Information : $service is unrecognized service"
      fi
      fi

      Thanks for the help!
      Natalia

      Comment

      • Colttt
        Senior Member
        Zabbix Certified Specialist
        • Mar 2009
        • 878

        #4
        ok, the programm checks only if the programm is running, its the same with proc.num.. if it returns "0" the programm/service is not start..

        echo "Status 2 - Information : $service is unrecognized service"
        i have never seen somthing like this..
        Debian-User

        Sorry for my bad english

        Comment

        • natalia
          Senior Member
          • Apr 2013
          • 159

          #5
          Originally posted by Colttt
          ok, the programm checks only if the programm is running, its the same with proc.num.. if it returns "0" the programm/service is not start..

          i have never seen somthing like this..
          if service not installed on the server you will get :

          %service ncsd status
          ncsd: unrecognized service

          and this is a diff from "service is stopped"

          still need a option to run "service $service status" and to get a status : 0,1 or 2.

          Should I define it with UserParameter, maybe (?)

          Thanks

          Comment

          • Colttt
            Senior Member
            Zabbix Certified Specialist
            • Mar 2009
            • 878

            #6
            yes ok, but why should i to monitor a service that dont exist/not installed?

            yes you can use that as a userparameter
            Debian-User

            Sorry for my bad english

            Comment

            • natalia
              Senior Member
              • Apr 2013
              • 159

              #7
              Originally posted by Colttt
              yes ok, but why should i to monitor a service that dont exist/not installed?

              yes you can use that as a userparameter
              for example, "puppet" service must be on all servers.You want to get alert once it not installed.

              Could you explain more how to implement this with userparameter ?

              Thanks !

              Comment

              • Colttt
                Senior Member
                Zabbix Certified Specialist
                • Mar 2009
                • 878

                #8
                hello,

                you can use this:
                system.sw.packages[<package>,<manager>,<format>]
                if you installed it by a supported packagemanager
                now, you know if it installed..
                after this you can use proc.num

                if you dont use a package-manager for puppet you can try this
                Code:
                which puppetd
                /usr/sbin/puppetd
                vfs.file.exists[/usr/sbin/puppetd]
                or
                Code:
                vfs.file.exists[/etc/init.d/puppet]
                i hope it helped!?
                Debian-User

                Sorry for my bad english

                Comment

                • natalia
                  Senior Member
                  • Apr 2013
                  • 159

                  #9
                  Originally posted by Colttt
                  hello,

                  you can use this:
                  system.sw.packages[<package>,<manager>,<format>]
                  if you installed it by a supported packagemanager
                  now, you know if it installed..
                  after this you can use proc.num

                  if you dont use a package-manager for puppet you can try this
                  Code:
                  which puppetd
                  /usr/sbin/puppetd
                  vfs.file.exists[/usr/sbin/puppetd]
                  or
                  Code:
                  vfs.file.exists[/etc/init.d/puppet]
                  i hope it helped!?
                  Looks like system.sw.packages can be a solution.Will check this.

                  Thanks a lot for your help !

                  Comment

                  Working...