Hello
That is my question for now...I have used mainly the examples of the Nagios::Plugin and Net::SNMP to build the script..
The object returned by Net::SNMP get_request is a hash how can I make arithmetic operation on the values returned by those. the only workaround I found was to extract the value in a temporary variable..
I am in my first baby steps in Perl. | [reply] |
You are receiving a hash reference as a result. So if the call is $result = $session->get_request(<arguments>), then instead of a temporary variable you can use the expression $result->{key} instead. The last argument in the call should be a reference to array of OIDs, rather than calling get_request (blocking) for every individual OID! An example of arithmetic using referenced hash values:-
my $AminusBminusC = $result->{A} - $result->{B} - $result->{C};
The A B and C are actual keys. Actually any expression can go inside the braces (e.g. variable, function call, array element, yet another hash value) and the value of the expression will be used as the key to look up its corresponding hash value. If instead you were directly accessing a hash called %result instead of a hash reference $result, you'd remove the -> (dereference) operator from each expression that gets the value for a key. Hope this helps!
| [reply] [d/l] |