Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to deal with an SNMP Error message 1

Status
Not open for further replies.

InDenial

Technical User
Aug 1, 2003
191
NL
Hi everyone,

I am writing a script that does the following:

ping ip-address
if reachable check device type using an snmpget
if it is devicetype A then do something
if it is devicetype B then do something else
and so on..

The problem however is that not all devices use the same community string. So when I do an snmpget on devicetype C with another community string than A and/or B it returns an SNMP error.

How do I tell my script to do something else when I get an SNMP Error?. I am using SNMP_util.pm



InDenial

 
From the snmp::util dox #
Code:
 if ($snmp->error){
        $error = $snmp->errmsg;
        $error_detail = $snmp->errmsg_detail;
        print "snmp error = $error\n";
        print "snmp error detail = $error_detail\n";
    }
check $snmp->errmsg, or $error to match the error you're getting, after your snmpget, if it matches the error then do something else

--Paul
 
Thanks for the reply. I am not using that module but I think it is time I should... right now I was using the following SNMP standalone module:


wich does not contain the SNMP error handling. Thanks again... The above is exactly what I need...

InDenial
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top