Ad Widget

Collapse

External Check works once then says not supported

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omicron
    Junior Member
    • Jul 2010
    • 6

    #1

    External Check works once then says not supported

    Hello,

    I am having a problem trying to get the fan speed in my bladecenter.

    I first tried to use SNMP but the problem is that the value returned is a string (which contains characters). So, I can't use it to graph or trigger on this item.

    I then decided to use external check, with a script containing the SNMP querry. That script is parsing the result of the query in order to get only the numeric value I need, and not the rest.
    And it works! ... but just once.

    After the value is displayed once on the frontend, the second time the external check is executed, the item disables itself (it is marked as "not supported") and says that my script "returned nothing".

    Here is my script :

    Code:
    #!/bin/sh
    
     TEST=$(/usr/bin/snmpget -v1 -c public 10.202.200.1 .1.3.6.1.4.1.2.3.51.2.2.3.1.0 | /bin/sed "s/[^0-9]//g");
             
              
            function test(){   
                    
                    declare -i TEST2=${TEST:10};
    
                    return $((TEST2)); 
    
            }
        
            test;
    In that script,
    Code:
    snmpget -v1 -c public 10.202.200.1 .1.3.6.1.4.1.2.3.51.2.2.3.1.0
    returns the following as a string:

    SNMPv2-SMI::enterprises.2.3.51.2.2.3.1.0 = STRING: "46% of maximum"
    Once the script is executed, I get the value I need (in my exemple, it is 46).

    I already tried to change the Timeout value in the zabbix-server config file setting it to 30, but it didn't work.

    Help on this issue would be much appreciated
    Last edited by omicron; 08-07-2010, 17:30.
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    Have you tried to simplify your script ?

    I think that the script below should work
    #!/bin/sh
    /usr/bin/snmpget -v1 -c DLNEGOCE 10.202.200.1 .1.3.6.1.4.1.2.3.51.2.2.3.1.0 | /bin/sed "s/[^0-9]//g"
    Regards,
    Alixen
    http://www.alixen.fr/zabbix.html

    Comment

    • omicron
      Junior Member
      • Jul 2010
      • 6

      #3
      Thank you for your answer.

      It tried as you said, and it works, except what I get is "223512231046" instead of 46. Indeed, as you can see in the following, there's 10 digits before 46:

      Code:
      SNMPv[B][I]2[/I][/B]-SMI::enterprises.[B][I]2.3.51.2.2.3.1.0[/I][/B] = STRING: "46% of maximum"
      That was why I had to substring the SNMP string in my script.

      Can you help me adapt your script to retrieve only the digits after the 10 firsts?

      Comment

      • omicron
        Junior Member
        • Jul 2010
        • 6

        #4
        I managed to modify the script you gave me to suit my needs.
        It seems to work.

        Here is the script :

        Code:
        #!/bin/sh
        snmp_string=$(/usr/bin/snmpget -v1 -c public 10.202.200.1 .1.3.6.1.4.1.2.3.51.2.2.3.1.0 | /bin/sed "s/[^0-9]//g");
        echo ${snmp_string:10};
        Again, thank you Alixen for your help!
        Last edited by omicron; 08-07-2010, 17:30.

        Comment

        • omicron
          Junior Member
          • Jul 2010
          • 6

          #5
          One more thing please:

          I would like to pass the snmp oid as a parameter.
          I tried the following:

          Code:
          #!/bin/sh
          
          snmp_string=$(/usr/bin/snmpget -v1 -c public 10.202.200.1 $1 | /bin/sed "s/[^0-9]//g");
          
          echo ${snmp_string:10};
          (I also tried $2 instead of $1 as seen on other posts).

          On the frontend, I changed the item as in the following:

          script.sh[.1.3.6.1.4.1.2.3.51.2.2.3.1.0]
          It didn't work. I have the same problem as with my previous script.

          It seems like I am not getting the parameter in the $1 (or $2) variable.
          This was working perfectly with the snmp oid directly inserted in the script (without the variable).
          What did I do wrong? Can you help me?
          Last edited by omicron; 08-07-2010, 17:31.

          Comment

          • alixen
            Senior Member
            • Apr 2006
            • 474

            #6
            Hi,

            External scripts get your arguments starting from $2, $1 is Zabbix host name.
            Check the manual for details : http://www.zabbix.com/documentation/...xternal_checks

            Using -Ov option of snmpget would also help parsing the result since it removes OID part:

            #! /bin/sh
            /usr/bin/snmpget -v1 -c $3 -Ov $1 $2 | /bin/sed "s/[^0-9]//g"
            You could then call it as:
            script.sh[.1.3.6.1.4.1.2.3.51.2.2.3.1.0 DLNEGOCE]
            Regards,
            Alixen
            http://www.alixen.fr/zabbix.html

            Comment

            • omicron
              Junior Member
              • Jul 2010
              • 6

              #7
              Here is my new script:

              Code:
              #!/bin/sh
              
              snmp_string=$(/usr/bin/snmpget -v1 -c public -Ov $1 $2 | /bin/sed "s/[^0-9]//g");
              
              echo $snmp_string;
              ... But it didn't change anything (I'm still having the "not supported" error).
              I really don't get why it's always working the first time, and then ... nothing.
              It's really weird.

              Any other idea?

              Comment

              • alixen
                Senior Member
                • Apr 2006
                • 474

                #8
                Hi,

                I suggest to add some debug messages to your script, it may give you a clue about what is going wrong.
                I would start with:
                #!/bin/sh
                LOG=/tmp/script.log
                echo start: $0 `date` >> $LOG
                echo args: $* >> $LOG

                snmp_string=$(/usr/bin/snmpget -v1 -c public -Ov $1 $2 | /bin/sed "s/[^0-9]//g");

                echo $snmp_string;

                echo snmp_string: $snmp_string >> $LOG
                echo end: $0 `date` >> $LOG
                Regards,
                Alixen
                http://www.alixen.fr/zabbix.html

                Comment

                • omicron
                  Junior Member
                  • Jul 2010
                  • 6

                  #9
                  Thank to your help I finally managed to determine what was the problem.

                  Indeed, when I'm executing the script by hand it's writting some info in the log file, whereas when it's executed by zabbix,there is no log entry.

                  So I looked carefully to the chmod and modified them.

                  Now it's working perfectly.

                  But I still don't get why it was always working the first time, and then nothing ... strange.

                  But my problem is solved.

                  Thank you Alixen, and sorry for having wasted your time.

                  Comment

                  • matjing
                    Junior Member
                    • Jun 2012
                    • 5

                    #10
                    external check works only for first argument

                    I am running zabbix 2.0. and for external checks I have the following:

                    Code:
                    #!/bin/sh
                    LOG=/tmp/zabbix_external.log
                    echo start: $0 `date` >> $LOG
                    echo args: $* >> $LOG
                    
                    ttl=$(snmpwalk -v 2c -c wrongcomm 41.222.XX.XX ifOutOctets.$1  | awk '{print$4}');
                    
                    echo $ttl;
                    
                    echo ttl: $ttl >> $LOG
                    echo end: $0 `date` >> $LOG
                    the log files show the following:
                    Code:
                    start: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:32 EAT 2012
                    args: 503
                    ttl: 8348368
                    end: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:32 EAT 2012
                    start: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:37 EAT 2012
                    args: 939
                    ttl: 2914065543
                    end: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:39 EAT 2012
                    start: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:50 EAT 2012
                    args: 717
                    ttl: 2425176665
                    end: /usr/local/share/zabbix/externalscripts/zabbix_external.sh Sun Jun 17 16:51:50 EAT 2012
                    On the gui I configured ->numeric unsigned, decimal,multiplier = 8, and units as bps.

                    However only the first one with args 939 registers any value on the front end for graphing. It also happens to be the first one I configured.

                    when checking the GUI,
                    Code:
                     
                    history: Configuration of items » Latest data » Configuration of hosts » Configuration of items » Latest data
                    there are converted values for the one then zeros for all the others. On one I can see a value was picked once then it all went back to the zeroes.

                    If I try running multiple scripts one for each OID, again the first one works, the others all become 'not supported'
                    [code]
                    15817:20120615:211432.166 item [Zabbix server:ifOut.939] became not supported: Received value [IF-MIB::ifInOctets.939 = C
                    ounter32: 1068503185] is not suitable for value type [Numeric (unsigned)] and data type
                    [code]
                    What could I be missing?

                    Mat
                    Attached Files
                    Last edited by matjing; 17-06-2012, 16:04. Reason: Update: I changed the ifOutOctets to ifHCInOctets and I seem to be ok, It is a Gigabit ethernet interface

                    Comment

                    • matjing
                      Junior Member
                      • Jun 2012
                      • 5

                      #11
                      external check works only for first argument -seems to work

                      damn its weird when you fix/answer your own post:
                      I changed from the 32bit to 64bit for high speed interfaces on cisco and seem to be okay now.

                      Code:
                      #ttl=$(snmpwalk -v 2c -c wrongcom 41.222.xx,x ifOutOctets.$1  | awk '{print$4}');
                      ttl=$(snmpwalk -v 2c -c wrongcom 41.222.xx.x [b] ifHCInOctets[/b].$1  | awk '{print$4}');

                      Comment

                      • matjing
                        Junior Member
                        • Jun 2012
                        • 5

                        #12
                        external check works only for first argument

                        Code:
                        ttl=$(snmpwalk -v 2c -c wrongcom 41.222.xx.x  [B]ifHCOutOctets[/B].$1  | awk '{print$4}');
                        okay now I have the same (original) problem for the outbound interface. Any takers? just show's zeroes. These are virtual interfaces with traffic shaping applied

                        Comment

                        Working...