I am running some code in a for loop to read temperature sensors inside our network at various locations in KY.
I am using snmpget to read the sensor. It reads fine most of the time.
I send an email if there was a problem reading the sensors, otherwise I build a string I am writing to a table using an sql statement.
My problem is that I do not know how to "trap" the error code if the read fails. I would like to log all failures and why in a log file for analysis.
My thought was that I should have a line inside the if using getErrno that would return the last snmp error but this did not work. I have not had much luck finding a working example.
All I want is the error number returned if I am sending an error message so I know what the problem may be.
Any suggestions would be appreciated.