Solved

snmpwalk - limit output to 1st line

Posted on 2011-09-13
2
750 Views
Last Modified: 2012-05-12
Hi Guys,

Is there a way to limit the output of snmpwalk to only display the first 1 or 2 lines?
I only need to test whether snmpwalk is successful or not (I don't need the full output of the snmpwalk command).

We have to test snmp connectivity for all our different clients' devices.

I use the following from our CentOS 4.9 server to test:

snmpwalk -c s3cret -v 2c 10.10.10.123:161
<This produces large amounts of output>

I'll script it to test a 100 random IPs.
I don't want the full OID to be dumped to screen, as this exersice is purely to determine if the device responds to snmp.

I've tried options like:
snmpwalk -O q -n 3
snmpwalk -Oq

But they all still return the whole OID.

Adding  "| head -2"  still causes the full command to run and takes very long.

Thank you,

J
0
Comment
Question by:m0nk3yza
2 Comments
 
LVL 3

Accepted Solution

by:
sameer_dubey earned 500 total points
Comment Utility
Some options for you:

1. Check the return code

2. Don't use snmpwalk, use snmpget instead
0
 
LVL 1

Author Closing Comment

by:m0nk3yza
Comment Utility
Awesome!
snmpget is exactly what I needed.
Thank you.

snmpget -v 2c -c public -m IF-MIB 10.10.10.123 ifDescr.1 ifSpeed.1
IF-MIB::ifDescr.1 = STRING: Ethernet Interface
IF-MIB::ifSpeed.1 = Gauge32: 100000000
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now