Ad Widget

Collapse

External check item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike13
    Member
    • Apr 2010
    • 30

    #1

    External check item

    Hi,

    I'm currently having an issue with External check item. I've written a perl script to ping my hosts in mpls vrf.
    When i call it from zabbix as an External check type i have the following error messages:
    sh: /etc/zabbix/externalscripts/sw_ping.pl: Permission denied
    Item [test:sw_ping.pl[172.17.148.182,xyz,password,VRF-182-TEST1, 192.168.15.16]]error: Script /etc/zabbix/externalscripts/sw_ping.pl returned nothing.

    Although the script has correct permission(-rwxrwxrwx 1 root zabbix 1267 May 5 06:57 sw_ping.pl) i can't figure out this problem.

    Here are the parameters of my item:

    Host:test
    Description: switch ping
    Type: External check
    Key:sw_ping.pl[172.17.148.182,xyz,password,VRF-182-TEST1, 192.168.15.16]


    My script do the following:
    1) login to a router via telnet
    2) do a ping vrf
    3) return 1(when ping successes) or 0 (unsuccessful)

    Here is my script:
    #!/usr/bin/perl
    if ($#ARGV != 4) {
    print "usage: ip useer pwd vf host";
    exit;
    }
    use strict;
    use warnings;
    use Net::Telnet::Cisco;
    my $ip= $ARGV[0];
    my $user= $ARGV[1];
    my $pwd= $ARGV[2];
    my $vf= $ARGV[3];
    my $host= $ARGV[4];
    my $result =0;
    my $session = Net::Telnet::Cisco->new(Host => $ip);
    $session->login($user, $pwd);
    # Execute the ping command
    my @output = $session->cmd("ping vrf $vf $host");
    # print @output;
    my $info ="";
    foreach $info (@output) {
    chomp($info);
    #print $info;
    if ($info =~ /Success rate is 100/) {
    $result=1; #print "-ok";
    }
    else{
    $result=0; #print"-nok";
    }
    #print "\n";
    }
    #print "\n";
    print $result;
    $session->close;


    How to resolve it?
    Any suggestions would be appreciated.

    Many Thanks
    Mike13
    Last edited by mike13; 05-05-2010, 16:37.
  • simonc
    Member
    • Jul 2009
    • 73

    #2
    did you find a solution ?
    zabbix user must have execute permissions on the script.
    Did you try :
    su zabbix
    /etc/zabbix/externalscripts/sw_ping.pl

    ?

    Simon

    Comment

    • mike13
      Member
      • Apr 2010
      • 30

      #3
      The script has 777 rights. But the error message still remains.

      Thanks,
      Mike13

      Comment

      • Murilex
        Senior Member
        • Nov 2009
        • 124

        #4
        Hello mike13. Although your script has 777 rights, Simon might be right. Maybe zabbix agent doesn't have permissions on /etc/zabbix/externalscripts/ directory. Try this:

        chown zabbix.zabbix -R /etc/zabbix/

        Comment

        Working...