• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 876
  • Last Modified:

snmpwalk - limit output to 1st line

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
m0nk3yza
Asked:
m0nk3yza
1 Solution
 
sameer_dubeyCommented:
Some options for you:

1. Check the return code

2. Don't use snmpwalk, use snmpget instead
0
 
m0nk3yzaAuthor Commented:
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now