Ad Widget

Collapse

UserParameter problems in 1.4.4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • azilber
    Member
    • Apr 2005
    • 33

    #1

    UserParameter problems in 1.4.4

    I recently upgraded from zabbix 1.2 to 1.4.4 and have been having a big issue one of my script. Basically, the script it a wrapper to innotop. You pass it a value and it uses innotop to see if any ongoing transactions are happening that are longer then this value. It's worked fine for zabbix 1.2.

    Example:

    UserParameter=innotop[*],/etc/zabbix/innonice.pl $1

    29062:20080422:233315 Processing request.
    29062:20080422:233315 In check_security()
    29062:20080422:233315 Requested [innotop[20]]
    29062:20080422:233315 Before
    29062:20080422:233315 Run remote command [/etc/zabbix/innonice 20] Result [1] [0]...
    29062:20080422:233315 Sending back [0]


    When run manually, as user zabbix, the script returns a '1'.

    I have another perl script, one that doesn't take a command line argument, that prints out the exit code in the exact same manner as the script above, and zabbix reports that one fine:

    (when there's an error):

    2476:20080423:000223 Requested [fschk]
    2476:20080423:000223 Before
    2476:20080423:000223 Run remote command [/etc/zabbix/fscheck.pl] Result [1] [1]...
    2476:20080423:000223 Sending back [1]

    Script:

    Code:
    #!/usr/bin/perl
    
    use POSIX qw(strftime);
    use strict;
    
    
    if(!$ARGV[0]){ print "Usage: innonice <min time: ex: 30>\n"; exit 1; }
    my $limit=0;
    $limit=0 + $ARGV[0];
    
    
    my $DDAY=strftime("%a %b %e %H:%M:%S %Y",localtime());
    open DATA, "/usr/bin/innotop --count 1 -n -m T 2>/dev/null |" or die "Aaahhhh!!";
    
    my $logfile="/var/log/zabbix/innotop-slow.log";
    my $logfile2="/var/log/zabbix/innodb-status.log";
    my $lines=0;
    my $lines2=0;
    my $time=0;
    my $crap;
    my $array=0;
    my $line="";
    my $line2="";
    my $DEBUG=0;
    
    while ($line=<DATA>) {
    if($DEBUG==1){ print "loop: $lines\n"; }
            if($lines==0){ if($DEBUG==1){ print "lines==0";} $lines++; next; }
            chomp($line);
            if(!$line){ if($DEBUG==1){ print "no lines";} next; }
                    $crap=$1.$2;
                    $time=$crap;
                    if($time>=$limit){
                            open (LOGA, ">>$logfile") or die "Cannot open $logfile";
                            print LOGA "\nDate: " . $DDAY . "\nOver: " . $limit . " seconds.\n" . $line . "\n";
                            close LOGA;
    
                            open (LOGB, ">>$logfile2") or die "Cannot open $logfile2";
                            print LOGB ">> " . $DDAY . "\n";
                            close LOGB;
                            system("echo 'SHOW INNODB STATUS;' | /opt/chroot/mysql64/usr/bin/mysql -S /opt/chroot/mysql64/tmp/mysql.sock --user=xxxxx --pass=xxxxxx -E >> $logfile2");
                            close DATA;
    
                     print "1\n"; exit;
                    }
                    if($lines==10){ print "2\n"; exit; }
    $lines++;
    if($DEBUG==1){ print "end of main loop"; }
    }
    
    
    close DATA;
    
    print "0\n";
    exit;
  • xs-
    Senior Member
    Zabbix Certified Specialist
    • Dec 2007
    • 393

    #2
    Originally posted by azilber
    29062:20080422:233315 Run remote command [/etc/zabbix/innonice 20] Result [1] [0]...
    29062:20080422:233315 Sending back [0]
    AFAIK, if it sees 2 results [1] and [0], it means it is seeing two values instead of one. This might be a seperate linefeed or cariage return (try a wordcount on it). I've had similar 'mysteries' on a with a windows tool which gave an extra non-printable charater.

    Comment

    • azilber
      Member
      • Apr 2005
      • 33

      #3
      Originally posted by xs-
      AFAIK, if it sees 2 results [1] and [0], it means it is seeing two values instead of one. This might be a seperate linefeed or cariage return (try a wordcount on it). I've had similar 'mysteries' on a with a windows tool which gave an extra non-printable charater.
      I don't know where it's seeing the other value from. My other script also shows up as two values, but it gets the right one. I took off the \n's off the print statements and nothing's changed.

      Comment

      • azilber
        Member
        • Apr 2005
        • 33

        #4
        Example...

        Code:
        18416:20080423:231324 Requested [fschk]
         18416:20080423:231324 Run remote command [/etc/zabbix/fscheck.pl] Result [1] [0]...

        File:
        Code:
        #!/usr/bin/perl
        
        $TESTFILE="/opt/fstest/zabtest.txt";
        
        open(FILE,"> $TESTFILE") or report_failure();
        close FILE;
        
        unlink($TESTFILE);
        
        print "0\n";
        exit;
        
        sub report_failure(){
        
        print "1\n";
        exit;
        }

        Comment

        • xs-
          Senior Member
          Zabbix Certified Specialist
          • Dec 2007
          • 393

          #5
          have you tried to remove the \n's ?

          Comment

          • azilber
            Member
            • Apr 2005
            • 33

            #6
            yes

            Originally posted by xs-
            have you tried to remove the \n's ?
            I've tried no \n's, I've tried using \r's. I've tried with nothing, with quotes, without quotes. Same thing.

            The funny thing is, this script above, even though it shows 2 items returned, works fine, the previous one, does not.

            I'm pretty sure this is a bug in the agent. It was never this difficult getting things working on the old agents. I may have to switch back to the old agent if I can't get this working properly. It worked fine with the previous Zabbix version.

            Thanks,
            Alex

            Comment

            • azilber
              Member
              • Apr 2005
              • 33

              #7
              Got it working..

              After much testing, I realized I had stderr turned off. There were errors in the upstream script, so the result code never propagated. So the issue wasn't with Zabbix.

              Comment

              Working...