Ad Widget

Collapse

Help with an external script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bmclaughlin
    Junior Member
    • Oct 2008
    • 10

    #1

    Help with an external script

    I'm having a terrible time getting external scripts to work.

    I had one working, then after a reboot it suddenly quit working, and I haven't been able to get them working again. I was able to get around needing that script with simple checks, but now I'm in need of a script again, and can't get it working.

    What I need is a count of waiting e-mails on a pop account. I came up with the following scripts (don't laugh, I'm a scripting newbie! go easy on me!)

    Code:
    [root@Zabbix externalscripts]# cat test1.sh
    /etc/zabbix/externalscripts/test.sh xxx.xxx.xxx.xxx [email protected] xxxxxxx | grep messages | gawk '{print $5;}'
    Code:
    [root@Zabbix externalscripts]# cat test.sh
    #!/usr/bin/expect
    spawn telnet [lindex $argv 0] 110
    expect "POP server ready"
    send "user "
    send [lindex $argv 1]
    send "\n"
    expect "password required for user"
    send "pass "
    send [lindex $argv 2]
    send "\n"
    expect "messages"
    send "quit\n"
    Here's what's in the log:
    Code:
    3666:20091112:155728 Parameter [test1.sh] is not supported by agent on host [tpmail] Old status [0]
    Attached is a screenshot of the item in Zabbix.

    What am I doing wrong?

    The script works perfectly from the command line as user Zabbix.
    Attached Files
    Last edited by bmclaughlin; 13-11-2009, 01:01.
  • bmclaughlin
    Junior Member
    • Oct 2008
    • 10

    #2
    A genius friend of mine came up with this:

    checkpop.pl
    Code:
    #!/usr/bin/perl
    use Net::POP3;
    
    my $pop = Net::POP3->new($ARGV[0]);
    
    if ($pop->login($ARGV[1],$ARGV[2])) {
            my @count = $pop->popstat();
            print $count[0]."\n";
            $pop->quit();
    }
    else {
            print "ERROR!\n";
            exit 1;
    }
    
    exit 0;
    Item: checkpop.pl[username password]

    For the host you have to use the e-mail server name or IP.

    Works great! I have the smartest friends in the world!

    Comment

    Working...