|Keep It Simple, Stupid|
Net::SNMP::Interfaces how to print the error()by thanos1983 (Parson)
|on Jun 04, 2014 at 12:16 UTC||Need Help??|
thanos1983 has asked for the wisdom of the Perl Monks concerning the following question:
Thank you for your time and effort in advance. Well my question can be extremely simple to someone who has figure this out, but is seems a bit complicated to someone who is not familiar.
Two days ago I discovered this powerful module Net::SNMP::Interfaces.
The uniqueness and beauty of this tool is that it can detect non sequential interfaces. Which at my case is exactly what I was looking for.
While I was trying to experiment with the tool I read:
From: Net::SNMP::InterfacesThere is a also a fourth optional argument 'RaiseError' which determines the behaviour of the module in the event there is an error while creating the SNMP. Normally new() will return undef if there was an error but if RaiseError is set to a true value it will die() printing the error string to STDERR. If this is not set and an error occurs undef will be return and the variable $Net::SNMP::Interfaces::error will contain the test of the error. Because the interfaces are discovered in the constructor, if the module is to be used in a long running program to monitor a host where interfaces might be added or removed it is recommended that the object returned by new() is periodically destroyed and a new one constructed.
Well while I was trying to play around to see the error in case that I am using the RaiseError option active, I would expect to see the error printed.
Sample of working code displayed under:
For testing purposes I have changed on the code the port to 1161, on the effort to produce an error and display it.
I assume that I am using wrong syntax on the RaiseError => 1 option so I also tried RaiseError => 'TRUE' but unfortunately not printing the error.
The output that I am getting is the following:
So my question is am I doing something wrong? Or I am asking too much details when it come to printing the error?
Thanks again for everyone's time and effort.
Seeking for Perl wisdom...on the process...not there...yet!