Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
dualt1.pl
Package: mrtg-2.13.2.zip [view]
Upload User: shbosideng
Upload Date: 2013-05-04
Package Size: 1555k
Code Size: 2k
Category:
SNMP
Development Platform:
C/C++
- #!c:perlbin
- # dualt1.pl
- #
- #
- # Created by Eric Billeter
- # returns:
- # Modems in use (value1)
- # Chassis capacity (value2)
- use SNMP_Session;
- use BER;
- use Socket;
- use strict;
- %snmpget::OIDS = ( 'value1' => '1.3.6.1.4.1.429.1.5.4.1.3',
- );
- my($community,$router) = split /@/, $ARGV[0];
- die <<USAGE unless $community && $router;
- USAGE: hiperdsp.pl 'SNMP_community'@'aaa.bbb.ccc.ddd'
- Where 'aaa.bbb.ccc.ddd' is the ip address for the Network Management Card.
- USAGE
- my($sysName,$sysUptime,$interfaces,$value1,$value2) =
- snmpgettable($router,$community,'value1');
- exit(0);
- sub snmpgettable{
- my($host,$community,$var) = @_;
- my($next_oid,$enoid,$orig_oid,
- $response, $bindings, $binding, $value, $inoid,$outoid,
- $upoid,$oid,@table,$tempo);
- die "Unknown SNMP var $varn"
- unless $snmpget::OIDS{$var};
- $orig_oid = encode_oid(split /./, $snmpget::OIDS{$var});
- $enoid=$orig_oid;
- srand();
- my $session = SNMP_Session->open ($host ,
- $community,
- 161);
- for(;;) {
- if ($session->getnext_request_response(($enoid))) {
- $response = $session->pdu_buffer;
- ($bindings) = $session->decode_get_response ($response);
- ($binding,$bindings) = decode_sequence ($bindings);
- ($next_oid,$value) = decode_by_template ($binding, "%O%@");
- # quit once we are outside the table
- last unless BER::encoded_oid_prefix_p($orig_oid,$next_oid);
- my $bulkindex = 2;
- while( $bulkindex < "50" ){
- $tempo = substr ($value,$bulkindex,1);
- $bulkindex=$bulkindex+2;
- if( ord($tempo) eq '5' or ord($tempo) eq '3' or ord($tempo) eq '22' ){$value1=$value1 + 1 ;
- }
- if( ord($tempo) eq '2' or ord($tempo) eq '5' or ord($tempo) eq '3' or ord($tempo) eq '22' ){$value2=$value2 + 1 ;
- }
- }
- push @table, $tempo;
- } else {
- die "No answer from $ARGV[0]n";
- }
- $enoid=$next_oid;
- }
- $session->close ();
- if( $value1 eq ''){$value1 = 0 };
- if( $value2 eq ''){$value2 = 0 };
- print "$value1n";
- print "$value2n";
- return (@table);
- }