Ad Widget

Collapse

Problem with an external script integration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crillus
    Junior Member
    • Jun 2013
    • 20

    #1

    Problem with an external script integration

    Hello,

    I've just migrated from Zabbix 1.8.2 to 2.2.2 with an installation from scratch.

    I've succeeded except for a specific external script I used to check MIB on the network devices, here it is :

    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use SNMP;
    
    # requires a hostname and a community string as its arguments
    
    my $session = new SNMP::Session(DestHost => $ARGV[0], Community => $ARGV[1],UseSprintValue => 1, Version => 2 );
    
    if(!defined $session){
        print "0";
        exit 0;
        }
    
    my $request="$ARGV[2]";
    
    my $result = $session->get($request);
    
    if ($session->{ErrorStr}){
        print "0";
        }
    else{
       my $val = substr $result, 0, 1;
       if ($val eq "0") {
          $val=1;
       } else {
          $val = do { no warnings; int($result); };
          if ($val>0) {$val=1;}
       }
        print $val;
    #    print $result
        }
    exit 0;
    It perfectly worked on 1.8.2 but does not work on 2.2.2 anymore.

    It's on chmod 777 on my zabbix proxy.

    The key is like that : checkmib.pl[public .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x]

    When I launch the command ./checkmib @ip public .x.x.x.x.x.x.x.x.x.x.x.x.x.x] in a terminal it returns 1 (what I want) but zabbix using it constantly returns 0


    As a way to solve, I have a problem with my controller (a remote machine for wich I make a constant ping using "icmpping" as key, and wich fail despite the fact that I can ping it perfectly from a terminal)
    Last edited by crillus; 10-04-2014, 15:43.
  • tatapoum
    Senior Member
    • Jan 2014
    • 185

    #2
    Verify that the script is in the external scripts folder as configured in /etc/zabbix/zabbix_server.conf. Check also that the zabbix user is the owner of the script (but 777 should do it). Put Zabbix in debug level 4 and have a look at the logs.

    Comment

    • crillus
      Junior Member
      • Jun 2013
      • 20

      #3
      Hello,

      I permit myself to up this problem. Actually I've resolved it a few days ago (I abandoned the project for few months and I've reactualized it.)

      So ! the problem was just under my eyes : the syntaxe between 1.8 and 2.2 has changed, and I've modified the item using the external script pasted above.

      I had this in my item :
      checkmib.pl[public .x.x.x.x.x.x.x.x.x]
      I've changed it into :
      checkmib.pl["{HOST.IP1}", "public", ".x.x.x.x.x.x.x.x.x"]

      So ! finally it's resolved.
      but now I have a problem for only one switch which has a problem of timeout while executing this script... too bad. But now I can use the script.

      It took a few months but thank you

      Comment

      Working...