|
Dear Sir, I got some problems while running SNMP perl module in
WIN2K. Referring to the example async1.pl, I write a sample
code to query a snmp agent in 100 seconds. It works well in my linux PC, but hangs up in the WIN2K
platform. The program will enters an infinite loop when executing
in WIN2K. The behaviors of the SNMP modules in the WIN2K are
different from the Linux. For example, the timeout argument in the SNMP::MainLoop method seems useless in
WIN2K. Do I need to modify my program to Could you kindly help me to solve this problem? Thank
you. The package installed to run perl in WIN2K ====================================================================== ActivePerl- Net-snmp- My test sampe code ====================================================================== #! /usr/bin/perl # This code is for Faraday Wi-Fi ASD test use strict; use warnings; use SNMP; $SNMP::auto_init_mib = 0; my $value = 0; my $req_num = 0; my $rep_num = 0; my $los_num = 0; my $duration = 2; my $dest_host = shift || '192.168.131.254'; my $time_out = shift || 200000; if (!defined($dest_host)) { die "No target
host.....\n"; } my $sess = new SNMP::Session(
DestHost => $dest_host,
Timeout => $time_out); if (!defined($sess)) { die "Cannot open SNMP
session:\n"; } sub poller { $req_num++; #print "Polling\n"; # VarList is undefined if TIMEOUT occured if (!defined($_[1])) { #print "lost
packet\n"; $los_num++; } else { #print "Get
packet\n"; $rep_num++; } # Restart the request $_[0]->get([[". } sub finish { my $los_per; print "finsih\n"; if ($los_num == 0) { $los_per =
0; } else { $los_per =
($los_num/$req_num) *100; } print "snmp: Reqest
Sent = $req_num\n"; print "snmp: Response
Receive = $rep_num\n"; print "snmp: Packet
Loss = $los_num\n"; print
"snmp: Loss Percentage = $los_per %\n"; print "\n"; SNMP::finish(); } #$sess->{Timeout} = 20; print "\n\n"; print " FARADAY
TECH SNMP TEST TOOL\n"; print
"====================================================\n"; print "snmp: Target Host =
$sess->{DestHost}
\n"; print "snmp: Timeout =
$sess->{Timeout}
\n"; print "snmp: Duration =
$duration
\n"; $sess->get([[". #$sess->get([[". SNMP::MainLoop($duration,\&finish); Best
Regards, Peter Lin
(林嘉璋) ===
Faraday Technology Corporation, Headquarters TW === =
智原科技股份有限公司 =
Dept.: APD/IPL/IPS =
Tel : 886-3-578-7888 Ext:4026 =
Fax : 886-3-666-3958 =
Email: [EMAIL PROTECTED] =
WWW : www.faraday-tech.com ======================================================= ***************** Confidentiality Notice ***************** This electronic message and any attachments may contain confidential and legally privileged information or information which is otherwise protected from disclosure. If you are not the intended recipient,please do not disclose the contents, either in whole or in part, to anyone,and immediately delete the message and any attachments from your computer system and destroy all hard copies. Thank you for your cooperation. ************************************************************* |
