Ad Widget

Collapse

Not receive value from script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hulk45
    Member
    • Aug 2008
    • 33

    #1

    Not receive value from script

    why zabbix does not recive value from this script? (for windows).

    Code:
    #!/usr/bin/perl
    
    use Time::Local;
    
    sub rInit(*) {
    	my ($f) = @_;
    	seek($f, 0, 2);
    }
    
    sub rReadLn(*) {
    	my ($f) = @_;
    	my ($r, $p, $c);
    	if (tell($f) == 0) { return undef }
    	do {
    		if (!(seek($f, -2, 1))) {
    			seek($f, 0, 0);
    			goto OUT;
    		}
    		read($f, $c, 1);
    	} while ($c ne "\n");
    	OUT:
    	$p = tell($f);
    	$r = <$f>;
    	seek($f, $p, 0);
    	$r;
    }
    
    $starttime = time();
    
    if (@ARGV != 1) {
    	#print "Usage: $0 <file.log>\n";
    	print "1";
    	exit(1);
    }
    
    system(qq!c:\\agrep.exe "next file without completing the file" $ARGV[0] > $ARGV[0].tmp1!);
    
    if (!open(LOG, "$ARGV[0].tmp1")) {
    	#print "Cannot open file $ARGV[0]. Exitting.\n";
    	print "1";
    	exit(2);
    }
    
    rInit(LOG);
    binmode(LOG);
    while (defined($_ = rReadLn(LOG))) {
    	if (m!^(\d+)/(\d+)/(\d+) (\d+):(\d+):(\d+)\.(\d+)!) {
    		my ($mon, $mday, $year, $hour, $min, $sec, $msec) = ($1, $2, $3, $4, $5, $6, $7);
    		$unixtime = timelocal($sec, $min, $hour, $mday, $mon-1, $year);
    		if ($starttime - $unixtime <= 86400) {
    			if (m!next file without completing the file!) {
    				print 1;
    				close LOG;
    				exit(0);
    			} 
    		} else {
    			last;
    		}
    	}
    }
    print 0;
    close LOG;
    Last edited by hulk45; 29-08-2008, 14:18.
  • hulk45
    Member
    • Aug 2008
    • 33

    #2
    I the fool instead of zabbix
    All thanks.

    Comment

    Working...