Perl snmp script problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl snmp script problem
# 1  
Old 12-20-2013
Perl snmp script problem

does anyone know why this isn't showing me any output?

Code:
#!/usr/bin/perl

use strict;
use Net::SNMP;

my $host = 'localhost';
my $community = 'public';
my $session;
my $error;
my $response = undef;  

($session, $error) = Net::SNMP->session(
  -hostname => $host,
  -version => 2,
  -community =>$community,
  -port => 161,
  -timeout => 10
);

my $oid_ifTable = '1.3.6.1.2.1.2.2';

if( !defined( $response = $session->get_next_request($oid_ifTable)))
{
  if( $session->error_status == 2)
  {
    my $sessionError = $session->error;
    print ("($sessionError) OID not supported ($oid_ifTable).\n");
  }
}
else
{
  print ("$response");
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

SNMP Problem - SNMP not getting to the agent.

I am having a problem with an SNMP event, and I am not sure where I should be looking to solve this problem. Description: There is an SNMP event in our system that for one reason or another is not getting sent out as an email because it is never getting to our SNMP agent. I see where the... (0 Replies)
Discussion started by: broberts
0 Replies

2. Programming

Problem with my perl script

hiii alll i wrote a prgm which would take position and strand from file 1 and tries to locate a string 250 characters ahead/before that position in anothe file (based on strand 0 or 1) open my $fhConditions, "<", "1.txt" or die "Epic Fail: $!"; open my $fhCharacters, "<", "2.txt" or die "OMG... (1 Reply)
Discussion started by: anurupa777
1 Replies

3. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

4. Programming

Perl SNMP set pdu with multiple values

Hi, I'm trying to set two OID's in the same PDU (so both OIDs and values are sent in the same packet) at present I am only able to send one at a time which does not trigger the hardware response as the two specific OID's need to be set simultaneously in order to work. I'm using perl along... (0 Replies)
Discussion started by: MCLASS
0 Replies

5. Shell Programming and Scripting

Need help with SNMP perl script

I want to have a script that takes the following: Runs this Command: snmpwalk -v 1 -c public devicename 1.3.2.1.15.1.1.3 which returns the following: SNMPv2-SMI::mib-2.10.1.3.3.54.124.178.134 = INTEGER: 6 SNMPv2-SMI::mib-2.10.1.1.3.62.52.16.38 = INTEGER: 6... (1 Reply)
Discussion started by: streetfighter2
1 Replies

6. Shell Programming and Scripting

perl Net::SNMP version getting info from cisco switch

I am having trouble working with SNMP module with perl. I am trying to get SNMP version of target system. I use following code to get it however it resturns error as "Argument "v6.0.1" isn't numeric in numeric lt (<) at ./chk_env_upd.pl line 447." Get load table my $resultat =... (1 Reply)
Discussion started by: dynamax
1 Replies

7. IP Networking

SNMP Problem

Hi, basically I'm just looking at the O'Reilly book 'Essential SNMP' and am following one of the examples. The code in the example is: #!/usr/bin/perl use SNMP::Util; my $MIB1 = $ARGV; my $HOST = $ARGV; ($MIB1) && ($HOST) || die "Usage: $0 MIB_OID HOSTNAME"; my $value =... (0 Replies)
Discussion started by: cabaiste
0 Replies

8. Infrastructure Monitoring

SNMP problem

Hi all I had the server, when i run the below snmp command in the server (CNORA4/10.86.33.18), it cant give me the result. # snmpwalk -v1 -ctestuser 10.86.33.18 hrProcessorLoad Timeout: No Response from 10.86.33.18 but when i run another command, it seem like ok # snmpwalk -v1 -ctestuser... (1 Reply)
Discussion started by: SmartAntz
1 Replies

9. Infrastructure Monitoring

Facing problem while configuring snmp

HI, I am facing these two errors while configuring snmp can any body guide me. vi /var/log/snmpd.log Error opening specified endpoint "udp:161" Server Exiting with code 1 i also tried bash-3.00# netstat -a | grep snm *.snmpd Idle bash-3.00# lsof -i :161 bash: lsof: command not... (2 Replies)
Discussion started by: nir1785
2 Replies

10. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies
Login or Register to Ask a Question
net-snmp-config(1)						     Net-SNMP							net-snmp-config(1)

NAME
net-snmp-config - returns information about installed net-snmp libraries and binaries SYNOPSIS
net-snmp-config [OPTIONS] DESCRIPTION
The net-snmp-config shell script is designed to retrieve the configuration information about the libraries and binaries dealing with the Simple Network Management Protocol (SNMP), built from the net-snmp source package. The information is particularily useful for applications that need to link against the SNMP libraries and hence must know about any other libraries that must be linked in as well. OPTIONS
--version displays the net-snmp version number --indent-options displays the indent options from the Coding Style --debug-tokens displays a example command line to search to source code for a list of available debug tokens SNMP Setup commands: --create-snmpv3-user [-ro] [-a authpass] [-x privpass] [-X DES|AES] [-A MD5|SHA] [username] These options produce the various compilation flags needed when building external SNMP applications: --base-cflags lists additional compilation flags needed for external applications (excludes -I. and extra developer warning flags, if any) --cflags lists additional compilation flags needed --libs lists libraries needed for building applications --agent-libs lists libraries needed for building subagents --netsnmp-libs lists netsnmp specific libraries --external-libs lists libraries needed by netsnmp libs --netsnmp-agent-libs lists netsnmp specific agent libraries --external-agent-libs lists libraries needed by netsnmp libs Automated subagent building (produces an OUTPUTNAME binary file): [This feature has not been extensively tested, use at your own risk.] --compile-subagent OUTPUTNAME [--norm] [--cflags flags] [--ldflags flags] mibmodule1.c [...]] --norm leave the generated .c file around to read. --cflags flags extra cflags to use (e.g. -I...). --ldflags flags extra ld flags to use (e.g. -L... -l...). Details on how the net-nsmp package was compiled: --configure-options Display original configure arguments --snmpd-module-list Display the modules compiled into the agent --prefix Display the installation prefix 4.2 Berkeley Distribution 16 Nov 2006 net-snmp-config(1)