Need help with SNMP perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with SNMP perl script
# 1  
Old 08-19-2011
Need help with SNMP perl script

I want to have a script that takes the following:

Code:
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
SNMPv2-SMI::mib-2.10.1.1.3.62.52.28.51 = INTEGER: 2
SNMPv2-SMI::mib-2.10.1.1.3.101.8.248.5 = INTEGER: 6

I want the script to check if the Integer values are 6, if they are then I want to return:

Code:
OK: all values = 6

If the value is not a 6, then I would like it to return the Integer value and have the script truncate the last 4 octects of the script and return:

Code:
"Problem Integer value = 2 for 62.52.28.51


Any help is appreciated
# 2  
Old 08-19-2011
Not sure if you want to use perl for that, but maybe you do..anyhow here is an awk version just for kicks:

Code:
snmpwalk -v 1 -c public devicename 1.3.2.1.15.1.1.3|gawk '$NF==2{++i;a[i]=$0} END {if($i != 0){ for(var in a) print "problem found " a[var]}}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need to transfer all kernel logs (var/log/messages) to the snmp listener as snmp trap

i am working with embedded system -Dell DCS management sub system. my question is as below: currently we are using linux kernel 2.6.30 build and we have a kernel logs stored to the /var/log/messages path. now we have to transfer all this logs to the specified SNMP target as a part of SNMP... (4 Replies)
Discussion started by: vipul_prajapati
4 Replies

2. Shell Programming and Scripting

Perl snmp script problem

does anyone know why this isn't showing me any output? #!/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,... (0 Replies)
Discussion started by: SkySmart
0 Replies

3. Infrastructure Monitoring

SNMP traps to SNMP server

Dear Champs, I am new to unix, and need to configure linux server to send below traps to a SNMP server. Monitoring TRAP Disk Space Low Monitoring TRAP Memory Low Monitoring TRAP CPU high Monitoring TRAP Admin login/Logoff Please help me how to send this information to my SNMP server... (2 Replies)
Discussion started by: stavar
2 Replies

4. 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

5. 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

6. Red Hat

Sending data from DELL OMSA SNMP and Custom SNMP MIB to same UDP port 161

Hi , Currently DELL OMSA SNMP sends data through default udp port 161.I want my custom SNMP MIB also to send data in the same udp port 161.Whether its possible.If yes where to configure .I tried starting my custom MIB in udp port 161,but it throws port already in use.Kindly guide. (1 Reply)
Discussion started by: prabakar4all
1 Replies

7. IP Networking

Sending data from DELL OMSA SNMP and Custom SNMP MIB to same UDP port 161

Hi , Currently DELL OMSA SNMP sends data through default udp port 161.I want my custom SNMP MIB also to send data in the same udp port 161.Whether its possible.If yes where to configure .I tried starting my custom MIB in udp port 161,but it throws port already in use.Kindly guide. (0 Replies)
Discussion started by: prabakar4all
0 Replies

8. 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

9. Infrastructure Monitoring

Shell Script - Generate SNMP Traps

Good morning to you all I´m kinda of a noob to scripting, and my knowledge is still very basic: anyway, I´ve developed a small .sh script with the following purpose: - it will check a result file, checking if it has any values, or if it´s empty - if it´s empty it will send an email What... (0 Replies)
Discussion started by: zarahel
0 Replies

10. Infrastructure Monitoring

HPUX net-SNMP interpreter "/bin/perl" not found

I am trying to install net-snmp on an HPUX box. I am getting the fallowing error message when I try to run the snmpconf file. I installed the fallowing version of net-snmp net-snmp-5.0.10.2-HP-UX_B.11.11_9000_800.tar and my HPUX box is version HP-UX commnms B.11.11 U 9000/800... (2 Replies)
Discussion started by: krisarmstrong
2 Replies
Login or Register to Ask a Question