Ad Widget

Collapse

Zabbix 2.2 doesn't accept returned values from external check

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • masierovinicius
    Junior Member
    • Feb 2015
    • 8

    #1

    Zabbix 2.2 doesn't accept returned values from external check

    Hello Fellas!

    Im having a problem with a external check. My script returns all tha values correctly, without problems. But zabbix shows me a error to each item.

    An Example: Received value [1] is not suitable for value type [Numeric (float)]

    in case, i think "1" is a Numeric(Float). But Zabbix doesn't thinks the same.

    Follow a print from error in attachment.

    Can someone help me?
    Attached Files
  • tchjts1
    Senior Member
    • May 2008
    • 1605

    #2
    1 is not a float. It is an integer.

    Comment

    • masierovinicius
      Junior Member
      • Feb 2015
      • 8

      #3
      hmm, ok, thanks for reply.

      Which option i choose then? Numeric Unsigned shows me the same error...

      Comment

      • filipp.sudanov
        Senior Member
        Zabbix Certified Specialist
        • May 2014
        • 137

        #4
        1 should be fine for both Unsigned and Float.

        Can you run the following command, may be your script returns some additional characters:
        Code:
        $./our_script.sh | hexdump -C
        If the result is just 1, the output should be like this:
        Code:
        00000000  31 0a                                             |1.|
        00000002
        Also check the output of this script under "zabbix" user.

        Comment

        • masierovinicius
          Junior Member
          • Feb 2015
          • 8

          #5
          Thanks Filipp!

          The output with hexdump -C:
          Code:
          00000000  0a 0a 31 0a                                       |..1.|
          00000004
          Can i use custom multiply to resolve? Is ..1. the same as 0,01?

          Comment

          • filipp.sudanov
            Senior Member
            Zabbix Certified Specialist
            • May 2014
            • 137

            #6
            Your script is outputting new line character (0a) twice before the value. On the right hexdump prints it as dot (.), since it prints all control characters in this way.
            You have to get rid from that double 0a 0a.

            Comment

            • masierovinicius
              Junior Member
              • Feb 2015
              • 8

              #7
              Thanks for your reply!

              how i can remove this newlines?

              i tried some ways (preg_replace, trim) but no one worked.

              follow my script:

              Code:
              #!/usr/bin/php
              
              <?php
              
              require('mtapi.php');
              
              list($script, $user, $pass, $host, $key) = $argv;
              
              $API = new routeros_api();
              
              $API->debug = false;
              
              
              if ($API->connect($host,$user,$pass)) {
              
              
                $output = $API->comm("/interface/wireless/registration-table/getall",false);
              
              
                $return = 0;
              
              
                switch($key) {
              
                  case "rx-rate":
              
                  case "tx-rate":
              
                  case "tx-ccq":
              
                  case "signal-strength":
              
                    $column = array_column($output,$key);
              
                    $return = array_sum($column)/sizeof($column);
               break;
              
                  case "noise":
              
                    $signal = array_column($output,"signal-strength");
              
                    $snr = array_column($output,"signal-to-noise");
              
                    $return = (array_sum($signal) - array_sum($snr)) / sizeof($snr);
              
                    break;
              
              
                  case "clients":
              
                    $return = sizeof($output);
              
                    break; }
              
                $trimmed = preg_replace('/\s/',' ', $return);
              
                printf("%d\n",$trimmed);
              
              
              
              
                $API->disconnect();
              
              
              
              }

              Comment

              • Parasin
                Member
                Zabbix Certified Specialist
                • Dec 2014
                • 53

                #8
                The problem is in this line:
                printf("%d\n",$trimmed);
                Just change it to this:
                printf (%d, $trimmed);

                Comment

                • masierovinicius
                  Junior Member
                  • Feb 2015
                  • 8

                  #9
                  Thank you for your reply Parasin.

                  My problem is the two newlines before the variable.

                  The line:
                  Code:
                  printf (%d, $trimmed);
                  Doesn't worked because there is not quotation marks. With "" the problem remains the same.

                  Comment

                  • masierovinicius
                    Junior Member
                    • Feb 2015
                    • 8

                    #10
                    I belive the problem in my script is the API function. In your execution, The interpreter put two newlines before the output.

                    Code:
                    $API = new routeros_api();
                    
                    $API->debug = false;
                    
                    
                    if ($API->connect($host,$user,$pass)) {
                    
                    $API->disconnect();
                    
                    
                    }
                    I tested without return of any values and the script continued to put the two newlines.

                    Someone have a idea?

                    Comment

                    • masierovinicius
                      Junior Member
                      • Feb 2015
                      • 8

                      #11
                      Hello Everybody!

                      I resolved the mystery.

                      The problem was blanklines after "#!/usr/bin/php" in my script and blanklines in mtapi.php, which was in require on my script, after the "?>" in the final.

                      Simple problem, but was resolved.

                      Thanks for your help guys, you helped me so much.

                      Good work for all!

                      Regards!

                      Comment

                      Working...