Ad Widget

Collapse

Smokeping replacement?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pad19
    Junior Member
    • Jul 2013
    • 22

    #16
    Originally posted by mbsit
    Set item type of information to Text then you will see the output (maybe some useful error message).
    When I set items to text, nothing happened becouse It looks like Zabbix didn't run the script.

    Originally posted by mbsit
    But, rememberer that, in this solution, zabbix_sender is used, so you have to have (in zabbix server configuration) zabbix traper active (more than 1).
    I have found only this: StartTrappers=5
    Do you wrote about this option?

    Originally posted by mbsit
    Every time you use the script:
    ./zbxsmokeping 127.0.0.1 6 1000 68 localhost
    4 new values are send to server so should be visible on SmokeItems.
    Yes 4 values are sending and I see them. But it only works when I manualy start it from shell. Zabbix dont start script...

    Michał

    Comment

    • mbsit
      Senior Member
      • Sep 2012
      • 130

      #17
      OK,
      Michał check if on Debian distro Zabbix looks for external scripts to /usr/local/share/zabbix/externalscripts ....
      What is in log? /var/log/zabbix/zabbix_server.log (or any other location).

      Look in zabbix config where the logs are, and where external scripts should be.
      Pozdrawiam
      Grzegorz Grabowski
      ____
      Wdrożenia, szkolenia, umowy serwisowe
      Warszawa - Polska

      Comment

      • pad19
        Junior Member
        • Jul 2013
        • 22

        #18
        Originally posted by mbsit
        OK,
        Michał check if on Debian distro Zabbix looks for external scripts to /usr/local/share/zabbix/externalscripts ....
        What is in log? /var/log/zabbix/zabbix_server.log (or any other location).

        Look in zabbix config where the logs are, and where external scripts should be.
        By default there wasnt 'externalscript' folder so I create one.
        In config was only comment
        Code:
        # ExternalScripts=${datadir}/zabbix/externalscripts
        So I add line:
        Code:
        ExternalScripts=/etc/zabbix/externalscripts/
        I uploaded zbxsmokeping to /etc/zabbix/externalscripts/ and changed its code to:
        Code:
        # where is fping tool?
        FPING=/usr/bin/fping
        # where is zabbix_sender tool?
        ZBXSENDER=/usr/bin/zabbix_sender
        I also chmod to 755

        There are no errors when I run ./zbxsmokeping and it works, It send values and I see them in Zabbix latests data.

        But Zabbix 'auto job' dont run script automaticly every x minutes...
        Last edited by pad19; 11-07-2013, 14:19.

        Comment

        • mbsit
          Senior Member
          • Sep 2012
          • 130

          #19
          Simple Q: did you restart zabbix server
          Pozdrawiam
          Grzegorz Grabowski
          ____
          Wdrożenia, szkolenia, umowy serwisowe
          Warszawa - Polska

          Comment

          • pad19
            Junior Member
            • Jul 2013
            • 22

            #20
            Originally posted by mbsit
            Simple Q: did you restart zabbix server
            Yes, I did many times

            Comment

            • mbsit
              Senior Member
              • Sep 2012
              • 130

              #21
              What "Latest data" shows?
              In the column 'Last check' the time is changing at item 'Smoke Inicjator'?

              Try to set debug mode (zabbix config file), restart the server and look into to the logs.
              Pozdrawiam
              Grzegorz Grabowski
              ____
              Wdrożenia, szkolenia, umowy serwisowe
              Warszawa - Polska

              Comment

              • pad19
                Junior Member
                • Jul 2013
                • 22

                #22
                Originally posted by mbsit
                What "Latest data" shows?
                In the column 'Last check' the time is changing at item 'Smoke Inicjator'?

                Try to set debug mode (zabbix config file), restart the server and look into to the logs.
                Yes, column 'Last check' time change every 10min. I did a little debugging and Zabbix run automaticly script but have some problem with it.

                I change your script to something like this:
                Code:
                echo "$IP $COUNT $INTERVAL $BYTES $HOSTNAME" >> /etc/zabbix/externalscripts/log.txt
                ...
                ...
                # debug
                echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLoos -o ${tab[0]} >> /etc/zabbix/externalscripts/log.txt
                echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyMin -o ${tab[1]} >> /etc/zabbix/externalscripts/log.txt
                echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyMax -o ${tab[3]} >> /etc/zabbix/externalscripts/log.txt
                echo $ZBXSENDER -z $ZBXSERVER -p 10051 -s $HOSTNAME -k SmokLatencyAvg -o ${tab[2]} >> /etc/zabbix/externalscripts/log.txt
                And changed chmod of folder to 777.

                I create script in administrator->scripts
                Code:
                /etc/zabbix/externalscripts/zbxsmokeping {HOST.IP} 6 1000 68 {HOST.HOST}
                And when I clicked on host and choosed from popup menu this script everythink works ok and in log.txt I see:
                Code:
                10.100.80.1 6 1000 68 10.100.80.1
                /usr/bin/zabbix_sender -z 127.0.0.1 -p 10051 -s 10.100.80.1 -k SmokLoos -o 0
                /usr/bin/zabbix_sender -z 127.0.0.1 -p 10051 -s 10.100.80.1 -k SmokLatencyMin -o 0.35
                /usr/bin/zabbix_sender -z 127.0.0.1 -p 10051 -s 10.100.80.1 -k SmokLatencyMax -o 0.61
                /usr/bin/zabbix_sender -z 127.0.0.1 -p 10051 -s 10.100.80.1 -k SmokLatencyAvg -o 0.49
                But when Zabbix starts script automatically, there is only this in log.txt:
                Code:
                10.100.80.1 6 1000 68 10.100.80.1
                So it crashes on this line I think:
                Code:
                OUTPUT=`$FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1 | awk '{print $5,$8}' | tr -d "%|," | tr -s " " "/" | awk -F"/" '{print $3,$4,$5,$6}'`
                tab=( $OUTPUT )
                Last edited by pad19; 11-07-2013, 15:23.

                Comment

                • pad19
                  Junior Member
                  • Jul 2013
                  • 22

                  #23
                  Yes there is crash

                  Code:
                   echo $FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1 >> /etc/zabbix/externalscripts/log.txt
                  echo "tutaj1" >> /etc/zabbix/externalscripts/log.txt
                  
                  OUTPUT=`$FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1 | awk '{print $5,$8}' | tr -d "%|," | tr -s " " "/" | awk -F"/" '{print $3,$4,$5,$6}'`
                  echo "tutaj2" >> /etc/zabbix/externalscripts/log.txt
                  This is log when I run it:
                  Code:
                  10.100.80.1 6 1000 68 10.100.80.1
                  /usr/bin/fping -b 68 -c 6 -q -p 1000 10.100.80.1
                  tutaj1
                  tutaj2
                  and this is log when Zabbix runs it:
                  Code:
                  10.100.80.1 6 1000 68 10.100.80.1
                  /usr/bin/fping -b 68 -c 6 -q -p 1000 10.100.80.1
                  tutaj1

                  Comment

                  • mbsit
                    Senior Member
                    • Sep 2012
                    • 130

                    #24
                    Of course, user 'zabbix' has no rights to command fping.

                    ALWAYS !! Check scripts on user zabbix not root!

                    # su - zabbix

                    and then try to run my scripts.
                    Or you don't have 'fping' utility because this is not standard tool.
                    Last edited by mbsit; 11-07-2013, 16:39.
                    Pozdrawiam
                    Grzegorz Grabowski
                    ____
                    Wdrożenia, szkolenia, umowy serwisowe
                    Warszawa - Polska

                    Comment

                    • pad19
                      Junior Member
                      • Jul 2013
                      • 22

                      #25
                      Originally posted by mbsit
                      Of course, user 'zabbix' has no rights to command fping.

                      ALWAYS !! Check scripts on user zabbix not root!

                      # su - zabbix

                      and then try to run my scripts.
                      Or you don't have 'fping' utility because this is not standard tool.
                      YES YES I KNOW! I did it from beginning. I run as zabbix and zabbix have rights to fping. And also zabbix user run script with no errors. Also zabbix user via script.php runs your script well. But when zabbix tries automatically runs it every 10min it gives crash as I showed in previous post...

                      So I think it can't handle something from this "| awk '{print $5,$8}' | tr -d "%|," | tr -s " " "/" | awk -F"/" '{print $3,$4,$5,$6}"
                      Last edited by pad19; 11-07-2013, 17:04.

                      Comment

                      • mbsit
                        Senior Member
                        • Sep 2012
                        • 130

                        #26
                        Wrrr.. still thinking ...

                        Did you find any messages in zabbix_server log file in zabbix debug mode?
                        Pozdrawiam
                        Grzegorz Grabowski
                        ____
                        Wdrożenia, szkolenia, umowy serwisowe
                        Warszawa - Polska

                        Comment

                        • pad19
                          Junior Member
                          • Jul 2013
                          • 22

                          #27
                          Originally posted by mbsit
                          Wrrr.. still thinking ...

                          Did you find any messages in zabbix_server log file in zabbix debug mode?
                          Yes I know that it is very strange... It runs via script.php as zabbix user, but automatically as also zabbix user it cant... WTF?!?

                          even more strange that the input parameters to your script in both cases are the same and are ok...

                          In debug=4 I found something like this:

                          Code:
                          21728:20130711:171913.577 In substitute_key_macros() data:'zbxsmokeping[{HOST.IP},6,1000,68,{HOST.HOST}]'
                           21728:20130711:171913.577 In substitute_simple_macros() data:'{HOST.IP}'
                           21728:20130711:171913.578 End substitute_simple_macros() data:'10.100.80.1'
                           21728:20130711:171913.578 In substitute_simple_macros() data:'{HOST.HOST}'
                           21728:20130711:171913.578 End substitute_simple_macros() data:'10.100.80.1'
                           21728:20130711:171913.578 End of substitute_key_macros():SUCCEED data:'zbxsmokeping[10.100.80.1,6,1000,68,10.100.80.1]'
                           21728:20130711:171913.578 In get_value() key:'zbxsmokeping[{HOST.IP},6,1000,68,{HOST.HOST}]'
                           21728:20130711:171913.578 In get_value_external() key:'zbxsmokeping[{HOST.IP},6,1000,68,{HOST.HOST}]'
                           21728:20130711:171913.578 In zbx_popen() command:'/etc/zabbix/externalscripts//zbxsmokeping "10.100.80.1" "6" "1000" "68" "10.100.80.1"'
                           21727:20130711:171913.580 In get_values()
                           21727:20130711:171913.580 In DCconfig_get_poller_items() poller_type:0
                           21727:20130711:171913.580 End of DCconfig_get_poller_items():0
                           21727:20130711:171913.580 End of get_values():0
                           21727:20130711:171913.580 poller #1 spent 0.000483 seconds while updating 0 values
                           21727:20130711:171913.580 In DCconfig_get_poller_nextcheck() poller_type:0
                           21727:20130711:171913.580 End of DCconfig_get_poller_nextcheck():1373555954
                           21727:20130711:171913.580 sleeping for 1 seconds
                           21728:20130711:171913.581 End of zbx_popen():7
                           21783:20130711:171913.582 zbx_popen(): executing script
                           21730:20130711:171913.588 In get_values()
                           21730:20130711:171913.588 In DCconfig_get_poller_items() poller_type:0
                           21730:20130711:171913.588 End of DCconfig_get_poller_items():0
                           21730:20130711:171913.588 End of get_values():0
                           21730:20130711:171913.588 poller #4 spent 0.000476 seconds while updating 0 values
                           21730:20130711:171913.588 In DCconfig_get_poller_nextcheck() poller_type:0
                           21730:20130711:171913.588 End of DCconfig_get_poller_nextcheck():1373555954
                           21730:20130711:171913.589 sleeping for 1 seconds
                          command:'/etc/zabbix/externalscripts//zbxsmokeping "10.100.80.1" "6" "1000" "68" "10.100.80.1"'

                          I see there is extra quotes added "" maby this is wrong

                          no, I just run with extra "" from console and it is ok...
                          Last edited by pad19; 11-07-2013, 17:35.

                          Comment

                          • mbsit
                            Senior Member
                            • Sep 2012
                            • 130

                            #28
                            What about double // ? Remove last '/' in zabbix config file... where you set external scrript path ...

                            No ... it cant be .. the script is run correctly ...
                            Pozdrawiam
                            Grzegorz Grabowski
                            ____
                            Wdrożenia, szkolenia, umowy serwisowe
                            Warszawa - Polska

                            Comment

                            • mbsit
                              Senior Member
                              • Sep 2012
                              • 130

                              #29
                              Originally posted by mbsit
                              What about double // ? Remove last '/' in zabbix config file... where you set external scrript path ...

                              No ... it cant be .. the script is run correctly ...
                              Try to cut my OUTPUT to sections one, by one ...
                              like:
                              OUTPUT=`$FPING -b $BYTES -c $COUNT -q -p $INTERVAL $IP 2>&1`

                              Set the item Inicjator to text mode, and look what will be the output.
                              Pozdrawiam
                              Grzegorz Grabowski
                              ____
                              Wdrożenia, szkolenia, umowy serwisowe
                              Warszawa - Polska

                              Comment

                              • pad19
                                Junior Member
                                • Jul 2013
                                • 22

                                #30
                                SOLVED

                                After all day I solved it... ;p

                                Script 'zbxsmokeping' in default configuration needs about 6 sec to execute.
                                In Debian default Zabbix configuration from repository looks like this:
                                Code:
                                ### Option: Timeout
                                #	Specifies how long we wait for agent, SNMP device or external check (in seconds).
                                #
                                # Mandatory: no
                                # Range: 1-30
                                # Default:
                                # Timeout=3
                                So I just add line:
                                Code:
                                Timeout=7
                                Restart zabbix-server and everything works perfectly

                                I want to thank Grzegorz - mbsit for writing the script and a lot of help in this topic thx

                                Two more question:
                                I want to monitor and make graphs for about 400 routers by this script. Do you think it can kill Zabbix performance?
                                Now scripts runs every 10min, where can I change it? I am thinking about 5min
                                Last edited by pad19; 11-07-2013, 21:11.

                                Comment

                                Working...