分类: Python/Ruby
2011-03-29 23:04:53
#!/usr/bin/perl
use strict;
use POSIX qw( strftime);
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime(time));
my $date = strftime("%Y-%m-%d", localtime(time));
my $logfile = "/home/zhoucg/logs/check_bond_drop_$date.log";
open(FH, ">>", "$logfile") or die "Cannot open the log file: $!\n";
while() {
chomp;
my $ip = $_;
my @result = `snmpwalk -Os -v 2c -c L97iDuba $ip If`;
foreach(@result) {
if(/ifInDiscards\.5 = Counter32: (\d+)/) {
if($1 > 0) {
print FH "$time\t$ip\t$1\n";
}
}
}
}