Ad Widget

Collapse

External Scripts don't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emvectra
    Junior Member
    • Jul 2014
    • 5

    #1

    External Scripts don't work

    Hi,
    I have a Agent-Problem on my new Zabbix-Server:

    Zabbix 2.2.4 / Agent 2.2.4
    CentOS 6.5 x86_64
    Perl 5.10.1 x86_64
    MySQL 5.1.73 x86_64

    ----------

    I want to use external scripts, like "mail-server-check".
    But if I start the Agent, following error appears:

    Starting Zabbix agent: zabbix_agentd [8158]: invalid entry [use warnings;] (not following "parameter=value" notation) in config file [/etc/zabbix/zabbix_agentd.d//smtp.check.pl], line 3

    Here's the script (smtp.check.pl):

    --------------

    #!/usr/bin/perl

    use warnings;
    use Net::SMTP;
    sub controll;
    close STDERR;
    open(STDERR, '>',\$debug_out);

    # Connect to the mailserver
    $smtp = Net::SMTP->new($ARGV[0],Debug=>1,Timeout=>20) or ( print 'CONNECTION FAILED' );
    controll();
    # Try if mailserver would accept a mail FROM a given address
    # if second paramter is a FROM mailadress
    if( $ARGV[1] =~ /@.*\.[a-z]/)
    {
    $smtp->mail($ARGV[1]);
    controll();
    # Try if mailserver would accept a mail FOR a given address
    # if third paramter is a TO mailadress
    if( $ARGV[2] =~ /@.*\.[a-z]/)
    {
    $smtp->to($ARGV[2]);
    controll();
    }
    }
    $smtp->quit();
    print $result."\n";
    sub controll
    {
    if( $smtp->ok() == 1 )
    {
    $result = "OK";
    }
    else
    {
    $debug_out = ((split /\n/ , $debug_out)[-1]);
    $debug_out = ((split /<<< /, $debug_out)[-1]);
    print $debug_out."\n";
    exit;
    }
    }

    --------------

    If I start the script at the console, it works correct:

    [root@server]# ./smtp.check.pl localhost
    OK

    I´ve also that Problem with all other external Zabbix-Scripts from the web.

    Thanks for your replay,
    emvectra
  • jvalenzani
    Member
    Zabbix Certified Specialist
    • Sep 2010
    • 53

    #2
    The problem is not at your Perl Script, it's on the Zabbix Agent configuration file. More precisely, at line 3.

    Starting Zabbix agent: zabbix_agentd [8158]: invalid entry [use warnings;] (not following "parameter=value" notation) in config file [/etc/zabbix/zabbix_agentd.d//smtp.check.pl], line 3

    Comment

    • emvectra
      Junior Member
      • Jul 2014
      • 5

      #3
      Hmh,
      here are my first lines of
      /etc/zabbix/zabbix_agentd.conf:

      ---------------

      # This is a config file for the Zabbix agent daemon (Unix)
      # To get more information about Zabbix, visit http://www.zabbix.com

      ############ GENERAL PARAMETERS #################

      ### Option: PidFile
      # Name of PID file.
      #
      # Mandatory: no
      # Default:
      # PidFile=/tmp/zabbix_agentd.pid

      PidFile=/var/run/zabbix/zabbix_agentd.pid

      ### Option: LogFile
      # Name of log file.
      # If not set, syslog is used.
      #
      # Mandatory: no
      # Default:
      # LogFile=

      LogFile=/var/log/zabbix/zabbix_agentd.log

      ### Option: LogFileSize
      # Maximum size of log file in MB.
      # 0 - disable automatic log rotation.
      #
      # Mandatory: no
      # Range: 0-1024
      # Default:
      # LogFileSize=1

      LogFileSize=0

      ---------------

      I´ve tested it with a new Installation:
      - VM with CentOS 6.5, Zabbix 2.2.4, same Perl and MySQL Versions
      Same Error!

      Thanks,
      emvectra

      Comment

      • emvectra
        Junior Member
        • Jul 2014
        • 5

        #4
        OK, solved:

        1) New Directory for the pl-Scripts

        2) /etc/zabbix/zabbix_server.conf modified:
        ExternalScripts=/etc/zabbix/... (to the new Directory)

        3) Move the pl-Scripts to the new directory

        4) Restart Agent & Server = OK

        Comment

        Working...