Ad Widget

Collapse

Zext_nagios.sh

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wikisb
    Member
    • May 2011
    • 64

    #1

    Zext_nagios.sh

    hi all!
    i'm trying to put parameters in a item to monitorize a service but... i don't know how the sintax works of zext_nagios.sh.
    how do you add parameters??
    for example to do a check_ping you have to put 3 parameters (hostname or ip, warning thereshold, critical thershold) for example with:
    "HOSTNAME -w 100,60% -c 100,60%"
    how it would be??????
    zext_nagios[ping {HOSTNAME}.... ]
    i have tried to put this parameters in diferents forms but i haven't been able to solve this issue. i would be very glad if someone helps me.
    it only gives me value 2 or 3 for critical or unknown
    thanks !!
  • JBo
    Senior Member
    • Jan 2011
    • 310

    #2
    Hi,

    Code:
    zext_nagios.sh[ping {HOSTNAME} -w 100,60% -c 100,60%]
    works.

    I have attached a template that defines it and associated performance items (ping_rta, ping_pl).

    Regards,
    JBo
    Attached Files

    Comment

    • wikisb
      Member
      • May 2011
      • 64

      #3
      hi JBo!!!!
      thanks again for the post!! but i don't know what i'm doing wrong because i still get values 1 to 3 when i try to monitorize services with zext_nagios.sh that needs more parameters than the HOSTNAME.
      if i do
      zext_nagios.sh[ssh {HOSTNAME}] it gives me 0 when ssh is running & when i stop ssh it gives me 2, value for critical. so it works OK like check_pop and the others checks that only need the HOSTNAME as parameter.
      But when i try to monitorize postgres, ping and such other services that need more than one parameter it doesn't works, with check_ping i have put the code you posted "zext_nagios.sh[ping {HOSTNAME} -w 100,60% -c 100,60%]" but it gives me value 3 when it should be 0. i also imported your template and linked it to a host and it gives me value 3 for UNKNOWN. if i run ./check_ping HOSTNAME -w 100,60% -c 100,60% in console it gives me OK
      with check_postgres it happens the same, if i put "zext_nagios.sh[pgsql {HOSTNAME} -l nobody -p nobody]" it gives me value 3 for UNKNOWN but i know that if i run in the terminal "./check_pgsql 192.168.1.16 -l nobody -p nobody" it gives me OK.
      i don't use zabbix_agent but it shouldn't matter to do external checks.
      thanks one again and i hope we can solve this in brief.
      and if it wheren't for you JBo i wouldn't be monitoring any services at all. so special thanks for you

      Comment

      • JBo
        Senior Member
        • Jan 2011
        • 310

        #4
        Hi,

        I have tested
        Code:
         zext_nagios.sh[ping {HOSTNAME} -w 100,60% -c 100,60%]
        on my Zabbix installation and it is working fine.

        I don't know what is wrong on your setup.
        You can try to edit zext_nagios.sh and set
        Code:
        DEBUG=1
        at the beginning of the script.

        It will send a lot of traces to /tmp/zext_nagios.log, it may help you find what is wrong.

        Regards,
        JBo

        Comment

        • wikisb
          Member
          • May 2011
          • 64

          #5
          hi
          i just put debbug=1 and the zext_nagios.log prints this:
          the nagios plugin path is the one i edited from zabbix_Server.conf
          Code:
          + NAGIOS_PLUGIN_PATH=/usr/lib/nagios/plugins
          + export LANG=C
          + LANG=C
          + ip=182.10.1.16
          + plugin=ping
          + host=fsystem
          + shift 3
          + '[' -w = -p ']'
          + prefix=ping
          ++ /usr/lib/nagios/plugins/check_ping -H 172.20.1.16 -w 100,60% -c 100,60%
          i don't know if there is something not expected in this zext_nagios.log...

          Comment

          • JBo
            Senior Member
            • Jan 2011
            • 310

            #6
            Hi,

            This is the trace I get (host is www.google.com and I have set critical level to 200,90%):
            Code:
            + NAGIOS_PLUGIN_PATH=/usr/lib/nagios/plugins
            + export LANG=C
            + ip=www.google.com
            + plugin=ping
            + host=www.google.com
            + shift 3
            + [ -w = -p ]
            + prefix=ping
            + /usr/lib/nagios/plugins/check_ping -H www.google.com -w 100,60% -c 200,90%
            + res=PING OK - Packet loss = 0%, RTA = 31.58 ms|rta=31.584999ms;100.000000;200.000000;0.000000 pl=0%;60;90;0
            + code=0
            + sed -n s/.*|//p
            + echo PING OK - Packet loss = 0%, RTA = 31.58 ms|rta=31.584999ms;100.000000;200.000000;0.000000 pl=0%;60;90;0
            + res=rta=31.584999ms;100.000000;200.000000;0.000000 pl=0%;60;90;0
            + zabbix_sender --zabbix-server 127.0.0.1 -i -
            + echo rta=31.584999ms;100.000000;200.000000;0.000000
            + sed -e s/=.*$//
            + param=rta
            + sed -e s/.*=// -e s/[^0-9\.].*//gi
            + echo rta=31.584999ms;100.000000;200.000000;0.000000
            + value=31.584999
            + echo www.google.com ping_rta 31.584999
            + sed -e s/=.*$//
            + echo pl=0%;60;90;0
            + param=pl
            + sed -e s/.*=// -e s/[^0-9\.].*//gi
            + echo pl=0%;60;90;0
            + value=0
            + echo www.google.com ping_pl 0
            + echo 0
            If your trace stops at
            /usr/lib/nagios/plugins/check_ping -H 172.20.1.16 -w 100,60% -c 100,60%
            it seems that check_ping is blocked.

            Does
            /usr/lib/nagios/plugins/check_ping -H 172.20.1.16 -w 100,60% -c 100,60%
            return something when run from the command line ?

            JBo

            Comment

            • wikisb
              Member
              • May 2011
              • 64

              #7
              hi JBo
              the first time i realized i wasn't getting the wright values for ping, postgres, etc.. i runned them with the terminal "./check_ping 182.10.1.16 -w 100,60% -c 100,60%" or "./check_pqsql 182.10.1.16 -l nobody -p nobody" and both of them returned OK with several info... but putting it in zabbix it says item not supported...
              i don't know what to do.... it seems wierd that everything else works except the zext_nagios.sh with more than one parameter. i have monitorized lots of items i also have several triggers that work fine, graphs ,etc...
              I WANT AN OUTPUT of zext_nagios.log as yours!!!!
              thanks for helping me!!
              Last edited by wikisb; 22-06-2011, 17:35.

              Comment

              • JBo
                Senior Member
                • Jan 2011
                • 310

                #8
                I don't have any clue on what is going on.

                Just a little thing:
                zext_nagios.sh uses:
                /usr/lib/nagios/plugins/check_ping -H 172.20.1.16 -w 100,60% -c 100,60%

                You test it with:
                ./check_ping -H 172.20.1.16 -w 100,60% -c 100,60%

                What do you get with the exact same command as zext_nagios.sh (including /usr/lib/nagios/plugins path) ?

                JBo

                Comment

                • wikisb
                  Member
                  • May 2011
                  • 64

                  #9
                  hi JBo
                  Code:
                  [root@fsystem ~]# /etc/zabbix/externalscripts/check_ping -H 182.10.1.16 -w 100,60% -c 100,60%
                  PING OK - Packet loss = 0%, RTA = 0.01 ms|rta=0.015000ms;100.000000;100.000000;0.000000 pl=0%;60;60;0
                  this is the same output as doing it without all the path
                  i changed the path of the scripts in zabbix_server.conf and zext_nagios.sh so all the scripts are in /etc/zabbix/externalscripts

                  Comment

                  • JBo
                    Senior Member
                    • Jan 2011
                    • 310

                    #10
                    Originally posted by wikisb
                    hi JBo
                    Code:
                    [root@fsystem ~]# /etc/zabbix/externalscripts/check_ping -H 182.10.1.16 -w 100,60% -c 100,60%
                    PING OK - Packet loss = 0%, RTA = 0.01 ms|rta=0.015000ms;100.000000;100.000000;0.000000 pl=0%;60;60;0
                    this is the same output as doing it without all the path
                    i changed the path of the scripts in zabbix_server.conf and zext_nagios.sh so all the scripts are in /etc/zabbix/externalscripts
                    OK but /etc/zabbix/externalscripts is not the path that appears in your debug log.
                    You have:
                    Code:
                    + prefix=ping
                    ++[B] /usr/lib/nagios/plugins[/B]/check_ping -H 172.20.1.16 -w 100,60% -c 100,60%
                    Sorry to pin point what may be obvious to you but, since I have no explanation, I am tracking everything that looks strange

                    JBo

                    Comment

                    • wikisb
                      Member
                      • May 2011
                      • 64

                      #11
                      hi JBo
                      i have tried lots of things but i haven't been able to solve the issue so finally about an hour ago i changed the paths of zabbix_server.conf where fetches the scripts and the path of zext_nagios.sh where fetches the script to /etc/zabbix/externalscripts. so now in zext_nagios.log i see
                      Code:
                      NAGIOS_PLUGIN_PATH=/etc/zabbix/externalscripts
                      but i get the same sh*t as before...
                      i'm sorry that you have put lot of your time to try to help me
                      thanks!!
                      Last edited by wikisb; 22-06-2011, 18:04.

                      Comment

                      • wikisb
                        Member
                        • May 2011
                        • 64

                        #12
                        hi JBo!
                        still i didn't solved all the problem, but with some changes in permissions and giving shell to user nobody (it didn't had one till this morning) now i can monitorize all the services except "PING" but i don't mind if only doesn't works service ping, i will monitorize it with another thing instead using nagios scripts. but service postgres works fine like all the others.

                        the last thing i tried with check_ping was:
                        Code:
                        res='strace $NAGIOS_PLUGIN_PATH/check_$plugin -H $ip $*'
                        the last line returned was
                        Code:
                        write(1, "Ping OK".....) =-1 broken Pipe
                        thanks for your cool script

                        Comment

                        • JBo
                          Senior Member
                          • Jan 2011
                          • 310

                          #13
                          Hi,

                          Happy to know you could make some progress

                          According to strace, check_ping is working but it cannot write to its standard output.

                          You may try to replace:
                          Code:
                          res=`$NAGIOS_PLUGIN_PATH/check_$plugin -H $ip $*`
                          code=$?
                          res=`echo $res | sed -n 's/.*|//p'`
                          with:
                          Code:
                          $NAGIOS_PLUGIN_PATH/check_$plugin -H $ip $* > /tmp/zext_nagios.$$.out
                          code=$?
                          res=`cat /tmp/zext_nagios.$$.out | sed -n 's/.*|//p'`
                          rm /tmp/zext_nagios.$$.out
                          It may give a clue about what is going on.

                          Regards,
                          JBo

                          Comment

                          • wikisb
                            Member
                            • May 2011
                            • 64

                            #14
                            Hi JBo!!
                            i tried what you posted yesterday afternoon. i have put a strace in the first line to be modified.
                            Code:
                            strace $NAGIOS_PLUGIN_PATH/check_$plugin -H $ip $* > /tmp/zext_nagios.$$.out
                            and know it doesn't says Pipe broken but still it gets stuck in this line never passing to the next lines. it creates the zext_nagios.$$.out that contains the response of PING with OK, rta... but it never removes it.
                            the last lines of the output of strace are the following:
                            Code:
                            read(3, "PING 182.10.1.16 (182.10.1.16) 5"..., 4096) = 112
                            read(3, "64 bytes from 182.10.1.16: icmp_"..., 4096) = 59
                            read(3, "64 bytes from 182.10.1.16: icmp_"..., 4096) = 59
                            read(3, "64 bytes from 182.10.1.16: icmp_"..., 4096) = 59
                            read(3, "64 bytes from 182.10.1.16: icmp_"..., 4096) = 60
                            read(3, "--- 182.10.1.16 ping statistics "..., 4096) = 149
                            --- SIGCHLD (Child exited) @ 0 (0) ---
                            read(3, "", 4096)                       = 0
                            read(5, "", 4096)                       = 0
                            close(5)                                = 0
                            munmap(0x7f21c81af000, 4096)            = 0
                            close(3)                                = 0
                            munmap(0x7f21c81b0000, 4096)            = 0
                            wait4(8104, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 8104
                            fstat(1, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
                            mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f21c81b0000
                            write(1, "PING OK - Packet loss = 0%, RTA "..., 102) = 102
                            exit_group(0)                           = ?
                            thanks!!

                            Comment

                            • JBo
                              Senior Member
                              • Jan 2011
                              • 310

                              #15
                              Hi,

                              It seems that zext_nagios.sh script is killed as soon as check_ping terminates.

                              It is possible that it is killed by Zabbix because of a timeout.
                              You can check Timeout parameter in zabbix_server.conf
                              Code:
                              Timeout=30
                              I set the timeout to its maximum value (30s) because I have a few checks that may take several seconds.

                              Regards,
                              JBo

                              Comment

                              Working...