- 论坛徽章:
- 0
|
本帖最后由 west5211 于 2015-03-11 15:58 编辑
回复 4# johnsz
已解决。原因是snmpwalk使用的oid与最终获得值的oid有差异,导致无数。
[root@cacti ~]# snmpwalk -v 2c -c xxx 10.1.1.27 1.3.6.1.4.1.2011.5.25.111.4.1.1.26.1.49.1.49
SNMPv2-SMI::enterprises.2011.5.25.111.4.1.1.26.1.49.1.49.8044.1 = Gauge32: 2
后来写了个脚本直接获取数值就好了。
#use strict;
use Socket qw( EFAULT :crlf);
use Fcntl;
sub main
{
my ($argc,@argv)=@_;
my $ip=$argv[0];
my $comm=$argv[1];
#print "$host\n$comm\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time-24*3600);
$year+=1900;
++$mon;
my $time= $year.$mon.$mday;
my $time1;
my $cmd="snmpwalk -v 2c -c $comm $ip 1.3.6.1.4.1.2011.5.25.111.4.1.1.26.1.49.1.49";
my $result_string=`$cmd`;
#SNMPv2-SMI::enterprises.2011.5.25.111.4.1.1.26.1.49.1.49.8084.1 = Gauge32: 20
#print "$result_string\n";
my $result;
if ($result_string=~/Gauge32\:\s+(\d+)/) {
$result=$1;
print "$result\n";
}
}
main($#ARGV,@ARGV);
|
|