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:
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;
Comment