<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:10pt"><div>For starters, why is use strict commented out?<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> "Huber, Melissa" <mhuber@ascentdata.com><br><b><span style="font-weight: bold;">To:</span></b> nagios-users@lists.sourceforge.net<br><b><span style="font-weight: bold;">Sent:</span></b> Tue, August 17, 2010 2:41:23 PM<br><b><span style="font-weight: bold;">Subject:</span></b> [Nagios-users] nagios plugins return code issue<br></font><br>
<div dir="ltr" align="left"><span class="577394520-16082010"><font face="Arial" size="2">Hello all,</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div>
<div><span class="577394520-16082010"><font face="Arial" size="2">I've googled around
everywhere trying to find an answer here and came up unsuccessful, so if anyone
has had experience in this situation, I'd appreciate help!
</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div>
<div><span class="577394520-16082010"><font face="Arial" size="2">Basically, the issue
that I'm having is that I have a couple of temperature plugins that are
reporting errors in Nagios and at the command line they're exiting in
0:</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div><span class="577394520-16082010">
<div><span class="577394520-16082010"><font face="Arial" size="2"><a target="_blank" href="http://check7204temp.pl">check7204temp.pl</a> - Return code of 255 is out of
bounds</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2">and</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"><a target="_blank" href="http://checkciscotemp.pl">checkciscotemp.pl</a> -
Return code of 9 is out of bounds</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div>
<div><span class="577394520-16082010"><font face="Arial" size="2">If I run a "echo $?"
at the command line after running the command successfully, I get
0.</font></span></div>
<div><span class="577394520-16082010"><span class="577394520-16082010"><font face="Arial" size="2"></font></span></span> </div>
<div><span class="577394520-16082010"><span class="577394520-16082010"><font face="Arial" size="2">Thanks for any help anyone can provide!! My perms are 755 and
nagios user owns the plugins and I've run successfully with nagios user and got
0 output. I'm really stumped!!</font></span></span></div></span>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div>
<div><span class="577394520-16082010"><font face="Arial" size="2">Here's the code for
the plugins:<br></font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2">*******************************************</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2">check7204temp.pl:</font></span></div>
<div><span class="577394520-16082010"><font face="Arial" size="2"></font></span> </div>
<div><span class="577394520-16082010"><span lang="EN">
<p><font face="Arial" size="2">#!/usr/bin/perl -w</font></p>
<p><font face="Arial" size="2"># <a target="_blank" href="http://check_ciscotemp.pl">check_ciscotemp.pl</a></font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># Copyright (C) 2000 Leland E. Vandervort
<leland@mmania.com> # # This program is free software; you can
redistribute it and/or # modify it under the terms of the GNU General Public
License # as published by the Free Software Foundation; either version 2 # of
the License, or (at your option) any later version.</font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># This program is distributed in the hope that it
will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty #
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General
Public License for more details.</font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># you should have received a copy of the GNU General
Public License # along with this program (or with Nagios); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA
02111-1307, USA ####################################</font></p>
<p><font face="Arial" size="2"># Nagios pluging to check inlet and outlet
temperatures on # Cisco router platforms which support environmental monitoring
# (7200, 7500, GSR12000...) ####################################</font></p>
<p><font face="Arial" size="2"># default temperature thresholds are 30C for inlet,
40C outlet.</font></p>
<p><font face="Arial" size="2"># if input or output is less than thresholds, returns
OK # if equal to (the temps don't change that rapidly) returns WARNING # if
greater than threshold, returns CRITICAL # if undetermined, or cannot access
environmental, returns UNKNOWN # (in accordance with the plugin coding
guidelines) ####################################</font></p>
<p><font face="Arial" size="2">use Net::SNMP;</font></p>
<p><font face="Arial" size="2">use Getopt::Long;</font></p>
<p><font face="Arial" size="2">#use strict;</font></p>
<p><font face="Arial" size="2">&Getopt::Long::config('auto_abbrev');</font></p>
<p><font face="Arial" size="2">#my $critical_vals;</font></p>
<p><font face="Arial" size="2">#my $warning_vals;</font></p>
<p><font face="Arial" size="2">#my $inlet_warn;</font></p>
<p><font face="Arial" size="2">#my $outlet_warn;</font></p>
<p><font face="Arial" size="2">#my $status;</font></p>
<p><font face="Arial" size="2">my $response = "";</font></p>
<p><font face="Arial" size="2">my $timeout = 10;</font></p>
<p><font face="Arial" size="2">my $community = "<span class="577394520-16082010">blah"</span>;</font></p>
<p><font face="Arial" size="2">my $port = 161;</font></p>
<p><font face="Arial" size="2">my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1"; my
$OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3"; my $in_temp; my $out_temp; my
$inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session;
#my $state; #my $error;</font></p>
<p><font face="Arial" size="2">my %STATUSCODE = ( 'UNKNOWN' => '-1',</font></p>
<p><font face="Arial" size="2">'OK' => '0',</font></p>
<p><font face="Arial" size="2">'WARNING' => '1',</font></p>
<p><font face="Arial" size="2">'CRITICAL' => '2');</font></p>
<p><font face="Arial" size="2">my $state = "UNKNOWN";</font></p>
<p><font face="Arial" size="2"> </font></p>
<p><font face="Arial" size="2">$SIG{'ALRM'} = sub {</font></p>
<p><font face="Arial" size="2">print "ERROR: No snmp response from $hostnm
(sigALRM)\n";</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{"UNKNOWN"});</font></p>
<p><font face="Arial" size="2">};</font></p>
<p><font face="Arial" size="2">Getopt::Long::Configure('bundling');</font></p>
<p><font face="Arial" size="2">$status = GetOptions</font></p>
<p><font face="Arial" size="2">("community=s", \$community,</font></p>
<p><font face="Arial" size="2">"C=s", \$community,</font></p>
<p><font face="Arial" size="2">"H=s", \$hostnm,</font></p>
<p><font face="Arial" size="2">"hostname=s", \$hostnm,</font></p>
<p><font face="Arial" size="2">"port=i", \$port,</font></p>
<p><font face="Arial" size="2">"timeout=i", \$timeout,</font></p>
<p><font face="Arial" size="2">"c=s", \$critical_vals,</font></p>
<p><font face="Arial" size="2">"w=s", \$warning_vals,</font></p>
<p><font face="Arial" size="2">"ithresh=i", \$inlet_thresh,</font></p>
<p><font face="Arial" size="2">"othresh=i", \$outlet_thresh);</font></p>
<p><font face="Arial" size="2"></font></p>
<p><font face="Arial" size="2">if($status == 0) {</font></p>
<p><font face="Arial" size="2">&show_help;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">unless (defined($hostnm)) {</font></p>
<p><font face="Arial" size="2">$hostnm = shift || &show_help;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if (defined($critical_vals)) {</font></p>
<p><font face="Arial" size="2">if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/)
{</font></p>
<p><font face="Arial" size="2">($inlet_thresh,$outlet_thresh) = ($1, $2);</font></p>
<p><font face="Arial" size="2">} else {</font></p>
<p><font face="Arial" size="2">die "Cannot Parse Critical Thresholds\n";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if (defined($warning_vals)) {</font></p>
<p><font face="Arial" size="2">if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/)
{</font></p>
<p><font face="Arial" size="2">($inlet_warn,$outlet_warn) = ($1, $2);</font></p>
<p><font face="Arial" size="2">} else {</font></p>
<p><font face="Arial" size="2">die "Cannot Parse Warning Thresholds\n";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}else{</font></p>
<p><font face="Arial" size="2">$inlet_warn=$inlet_thresh;</font></p>
<p><font face="Arial" size="2">$outlet_warn=$outlet_thresh;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">alarm($timeout); </font></p>
<p><font face="Arial" size="2">$in_temp = &SNMPGET($INTAKE_TEMP);</font></p>
<p><font face="Arial" size="2">$out_temp = &SNMPGET($OUTLET_TEMP);</font></p>
<p><font face="Arial" size="2">if (($in_temp < $inlet_thresh) &&
($out_temp < $outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "OK";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">elsif (($in_temp == $inlet_thresh) || ($out_temp ==
$outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">if(($in_temp > $inlet_thresh) || ($out_temp >
$outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "CRITICAL";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">else {</font></p>
<p><font face="Arial" size="2">$state = "WARNING";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">elsif (($in_temp > $inlet_thresh) || ($out_temp
> $outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "CRITICAL";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">else {</font></p>
<p><font face="Arial" size="2">$state = "WARNING";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">print "$state Inlet Temp: $in_temp Outlet Temp:
$out_temp\n"; exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">sub show_help {</font></p>
<p><font face="Arial" size="2">printf("\nPerl envmon temperature plugin for
Nagios\n");</font></p>
<p><font face="Arial" size="2">printf("Usage:\n");</font></p>
<p><font face="Arial" size="2">printf("</font></p>
<p><font face="Arial" size="2">check_ciscotemp [options] <hostname></font></p>
<p><font face="Arial" size="2">Options:</font></p>
<p><font face="Arial" size="2">-C snmp-community</font></p>
<p><font face="Arial" size="2">-p snmp-port</font></p>
<p><font face="Arial" size="2">-i input temperature threshold</font></p>
<p><font face="Arial" size="2">-o output temperature threshold</font></p>
<p><font face="Arial" size="2">");</font></p>
<p><font face="Arial" size="2">printf("Copyright (C)2000 Leland E.
Vandervort\n");</font></p>
<p><font face="Arial" size="2">printf("check_ciscotemp comes with absolutely NO
WARRANTY either implied or explicit\n");</font></p>
<p><font face="Arial" size="2">printf("This program is licensed under the terms of
the\n");</font></p>
<p><font face="Arial" size="2">printf("GNU General Public License\n(check source
code for details)\n\n\n");</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{"UNKNOWN"});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">sub SNMPGET {</font></p>
<p><font face="Arial" size="2">$OID = shift;</font></p>
<p><font face="Arial" size="2">($session,$error) = Net::SNMP->session(</font></p>
<p><font face="Arial" size="2">Hostname => $hostnm,</font></p>
<p><font face="Arial" size="2">Community => $community,</font></p>
<p><font face="Arial" size="2">Port => $port</font></p>
<p><font face="Arial" size="2">);</font></p>
<p><font face="Arial" size="2">if(!defined($session)) {</font></p>
<p><font face="Arial" size="2">printf("$state %s\n", $error);</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if(!defined($response =
$session->get_request($OID))) {</font></p>
<p><font face="Arial" size="2">printf("$state %s\n",
$session->error());</font></p>
<p><font face="Arial" size="2">$session->close();</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">$session->close();</font></p>
<p><font face="Arial" size="2">return($response->{$OID});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial"><font size="2"><span class="577394520-16082010">*******************************************************<br></span></font></font><font face="Arial"><font size="2"><span class="577394520-16082010">code for
checkciscotemp.pl</span> </font></font></p></span></span><span lang="EN">
<p><font face="Arial" size="2">#!/usr/bin/perl -w</font></p>
<p><font face="Arial" size="2"># check_ciscotemp.pl</font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># Copyright (C) 2000 Leland E. Vandervort
<leland@mmania.com> # # This program is free software; you can
redistribute it and/or # modify it under the terms of the GNU General Public
License # as published by the Free Software Foundation; either version 2 # of
the License, or (at your option) any later version.</font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># This program is distributed in the hope that it
will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty #
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General
Public License for more details.</font></p>
<p><font face="Arial" size="2">#</font></p>
<p><font face="Arial" size="2"># you should have received a copy of the GNU General
Public License # along with this program (or with Nagios); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA
02111-1307, USA ####################################</font></p>
<p><font face="Arial" size="2"># Nagios pluging to check inlet and outlet
temperatures on # Cisco router platforms which support environmental monitoring
# (7200, 7500, GSR12000...) ####################################</font></p>
<p><font face="Arial" size="2"># default temperature thresholds are 30C for inlet,
40C outlet.</font></p>
<p><font face="Arial" size="2"># if input or output is less than thresholds, returns
OK # if equal to (the temps don't change that rapidly) returns WARNING # if
greater than threshold, returns CRITICAL # if undetermined, or cannot access
environmental, returns UNKNOWN # (in accordance with the plugin coding
guidelines) ####################################</font></p>
<p><font face="Arial" size="2">use Net::SNMP;</font></p>
<p><font face="Arial" size="2">use Getopt::Long;</font></p>
<p><font face="Arial" size="2">#use strict;</font></p>
<p><font face="Arial" size="2">&Getopt::Long::config('auto_abbrev');</font></p>
<p><font face="Arial" size="2">#my $critical_vals;</font></p>
<p><font face="Arial" size="2">#my $warning_vals;</font></p>
<p><font face="Arial" size="2">#my $inlet_warn;</font></p>
<p><font face="Arial" size="2">#my $outlet_warn;</font></p>
<p><font face="Arial" size="2">#my $status;</font></p>
<p><font face="Arial" size="2">my $response = "";</font></p>
<p><font face="Arial" size="2">my $timeout = 10;</font></p>
<p><font face="Arial" size="2">my $community = "<span class="577394520-16082010">blah</span>";</font></p>
<p><font face="Arial" size="2">my $port = 161;</font></p>
<p><font face="Arial" size="2">my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1"; my
$OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3"; my $in_temp; my $out_temp; my
$inlet_thresh = 22; my $outlet_thresh = 32; my $hostnm; #my $OID; #my $session;
#my $state; #my $error;</font></p>
<p><font face="Arial" size="2">my %STATUSCODE = ( 'UNKNOWN' => '-1',</font></p>
<p><font face="Arial" size="2">'OK' => '0',</font></p>
<p><font face="Arial" size="2">'WARNING' => '1',</font></p>
<p><font face="Arial" size="2">'CRITICAL' => '2');</font></p>
<p><font face="Arial" size="2">my $state = "UNKNOWN";</font></p>
<p><font face="Arial" size="2"> </font></p>
<p><font face="Arial" size="2">$SIG{'ALRM'} = sub {</font></p>
<p><font face="Arial" size="2">print "ERROR: No snmp response from $hostnm
(sigALRM)\n";</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{"UNKNOWN"});</font></p>
<p><font face="Arial" size="2">};</font></p>
<p><font face="Arial" size="2">Getopt::Long::Configure('bundling');</font></p>
<p><font face="Arial" size="2">$status = GetOptions</font></p>
<p><font face="Arial" size="2">("community=s", \$community,</font></p>
<p><font face="Arial" size="2">"C=s", \$community,</font></p>
<p><font face="Arial" size="2">"H=s", \$hostnm,</font></p>
<p><font face="Arial" size="2">"hostname=s", \$hostnm,</font></p>
<p><font face="Arial" size="2">"port=i", \$port,</font></p>
<p><font face="Arial" size="2">"timeout=i", \$timeout,</font></p>
<p><font face="Arial" size="2">"c=s", \$critical_vals,</font></p>
<p><font face="Arial" size="2">"w=s", \$warning_vals,</font></p>
<p><font face="Arial" size="2">"ithresh=i", \$inlet_thresh,</font></p>
<p><font face="Arial" size="2">"othresh=i", \$outlet_thresh);</font></p>
<p><font face="Arial" size="2"></font></p>
<p><font face="Arial" size="2">if($status == 0) {</font></p>
<p><font face="Arial" size="2">&show_help;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">unless (defined($hostnm)) {</font></p>
<p><font face="Arial" size="2">$hostnm = shift || &show_help;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if (defined($critical_vals)) {</font></p>
<p><font face="Arial" size="2">if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/)
{</font></p>
<p><font face="Arial" size="2">($inlet_thresh,$outlet_thresh) = ($1, $2);</font></p>
<p><font face="Arial" size="2">} else {</font></p>
<p><font face="Arial" size="2">die "Cannot Parse Critical Thresholds\n";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if (defined($warning_vals)) {</font></p>
<p><font face="Arial" size="2">if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/)
{</font></p>
<p><font face="Arial" size="2">($inlet_warn,$outlet_warn) = ($1, $2);</font></p>
<p><font face="Arial" size="2">} else {</font></p>
<p><font face="Arial" size="2">die "Cannot Parse Warning Thresholds\n";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}else{</font></p>
<p><font face="Arial" size="2">$inlet_warn=$inlet_thresh;</font></p>
<p><font face="Arial" size="2">$outlet_warn=$outlet_thresh;</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">alarm($timeout); </font></p>
<p><font face="Arial" size="2">$in_temp = &SNMPGET($INTAKE_TEMP);</font></p>
<p><font face="Arial" size="2">$out_temp = &SNMPGET($OUTLET_TEMP);</font></p>
<p><font face="Arial" size="2">if (($in_temp < $inlet_thresh) &&
($out_temp < $outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "OK";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">elsif (($in_temp == $inlet_thresh) || ($out_temp ==
$outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">if(($in_temp > $inlet_thresh) || ($out_temp >
$outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "CRITICAL";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">else {</font></p>
<p><font face="Arial" size="2">$state = "WARNING";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">elsif (($in_temp > $inlet_thresh) || ($out_temp
> $outlet_thresh)) {</font></p>
<p><font face="Arial" size="2">$state = "CRITICAL";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">else {</font></p>
<p><font face="Arial" size="2">$state = "WARNING";</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">print "$state Inlet Temp: $in_temp Outlet Temp:
$out_temp\n"; exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">sub show_help {</font></p>
<p><font face="Arial" size="2">printf("\nPerl envmon temperature plugin for
Nagios\n");</font></p>
<p><font face="Arial" size="2">printf("Usage:\n");</font></p>
<p><font face="Arial" size="2">printf("</font></p>
<p><font face="Arial" size="2">check_ciscotemp [options] <hostname></font></p>
<p><font face="Arial" size="2">Options:</font></p>
<p><font face="Arial" size="2">-C snmp-community</font></p>
<p><font face="Arial" size="2">-p snmp-port</font></p>
<p><font face="Arial" size="2">-i input temperature threshold</font></p>
<p><font face="Arial" size="2">-o output temperature threshold</font></p>
<p><font face="Arial" size="2">");</font></p>
<p><font face="Arial" size="2">printf("Copyright (C)2000 Leland E.
Vandervort\n");</font></p>
<p><font face="Arial" size="2">printf("check_ciscotemp comes with absolutely NO
WARRANTY either implied or explicit\n");</font></p>
<p><font face="Arial" size="2">printf("This program is licensed under the terms of
the\n");</font></p>
<p><font face="Arial" size="2">printf("GNU General Public License\n(check source
code for details)\n\n\n");</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{"UNKNOWN"});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">sub SNMPGET {</font></p>
<p><font face="Arial" size="2">$OID = shift;</font></p>
<p><font face="Arial" size="2">($session,$error) = Net::SNMP->session(</font></p>
<p><font face="Arial" size="2">Hostname => $hostnm,</font></p>
<p><font face="Arial" size="2">Community => $community,</font></p>
<p><font face="Arial" size="2">Port => $port</font></p>
<p><font face="Arial" size="2">);</font></p>
<p><font face="Arial" size="2">if(!defined($session)) {</font></p>
<p><font face="Arial" size="2">printf("$state %s\n", $error);</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">if(!defined($response =
$session->get_request($OID))) {</font></p>
<p><font face="Arial" size="2">printf("$state %s\n",
$session->error());</font></p>
<p><font face="Arial" size="2">$session->close();</font></p>
<p><font face="Arial" size="2">exit($STATUSCODE{$state});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><font face="Arial" size="2">$session->close();</font></p>
<p><font face="Arial" size="2">return($response->{$OID});</font></p>
<p><font face="Arial" size="2">}</font></p>
<p><span class="577394520-16082010"><font face="Arial" size="2">*********************************************</font></span></p>
<p><span class="577394520-16082010"><font face="Arial" size="2">Thanks,</font></span></p></span></div>
<div align="left"><span lang="EN"><strong><font face="Verdana" size="2"></font></strong><font face="Verdana" size="2"></font></span></div>
<p style="margin: 0in 0in 0pt;" class="MsoNormal" align="left"><font face="Verdana" size="2"><b style=""><span style="font-family: Arial;"><font size="3">M<span class="577394520-16082010">issy</span></font></span></b></font></p></div></div>
</div><br>
</body></html>