  USR56K
join:2000-05-20 Seattle, WA clubs:
·Charter Pipeline
| [Perl] SNMP scripting data off
Basically the data that is in my arrays is one off when I go to display the results. I can't seem to figure out why. By no means is the script finished, I just want to get this problem out of the way before I continue.
syntax colored pl code:# ---------------------------------------------------------------------------- # Output for Motherboard Monitor 5 via SNMP for RRDTool / Cacti # # File: snmp_mbm5.pl # Author: BSOD2600 # Version: 1.0 # Date: 1/04/2005 # # Purpose: This script reports Motherboard Monitor 5 data via SNMP # to rrdtool / Cacti. Both MBM5 and SNMP Informant are freeware. # MBM5: http://mbm.livewiredev.com/ # SNMP Informant: http://www.wtcs.org/informant/mbm/overview.htm # #-------- Don't edit below --------------------------------------------------
use strict; use Net::SNMP;
if ($#ARGV < 4) { usage(); }
#-------- Connect to Host -------------------------------------------------- my ($session, $error) = Net::SNMP->session( -version => $ARGV[1], -community => $ARGV[2], -hostname => $ARGV[3], -port => $ARGV[4] );
if (!defined($session)) { printf("ERROR: %s.\n", $error); exit 1; } my @MBM_RESULTS = (); my @MBM_OIDS = ( "1.3.6.1.4.1.9600.1.10.6.1.6.1", "1.3.6.1.4.1.9600.1.10.6.1.6.2", "1.3.6.1.4.1.9600.1.10.6.1.6.3", "1.3.6.1.4.1.9600.1.10.6.1.6.4", "1.3.6.1.4.1.9600.1.10.6.1.6.5", "1.3.6.1.4.1.9600.1.10.6.1.6.6", "1.3.6.1.4.1.9600.1.10.6.1.6.7", "1.3.6.1.4.1.9600.1.10.6.1.6.8", "1.3.6.1.4.1.9600.1.10.6.1.6.9", "1.3.6.1.4.1.9600.1.10.6.1.6.10", "1.3.6.1.4.1.9600.1.10.6.1.6.11", "1.3.6.1.4.1.9600.1.10.6.1.6.12", "1.3.6.1.4.1.9600.1.10.6.1.6.13", "1.3.6.1.4.1.9600.1.10.6.1.6.14", "1.3.6.1.4.1.9600.1.10.6.1.6.15", "1.3.6.1.4.1.9600.1.10.6.1.6.16", "1.3.6.1.4.1.9600.1.10.6.1.6.17", "1.3.6.1.4.1.9600.1.10.6.1.6.18", "1.3.6.1.4.1.9600.1.10.6.1.6.19", "1.3.6.1.4.1.9600.1.10.6.1.6.20", "1.3.6.1.4.1.9600.1.10.6.1.6.21", "1.3.6.1.4.1.9600.1.10.6.1.6.22", "1.3.6.1.4.1.9600.1.10.6.1.6.23", "1.3.6.1.4.1.9600.1.10.6.1.6.24", "1.3.6.1.4.1.9600.1.10.6.1.6.25", "1.3.6.1.4.1.9600.1.10.6.1.6.26", "1.3.6.1.4.1.9600.1.10.6.1.6.27", "1.3.6.1.4.1.9600.1.10.6.1.6.28", "1.3.6.1.4.1.9600.1.10.6.1.6.29", "1.3.6.1.4.1.9600.1.10.6.1.6.30", "1.3.6.1.4.1.9600.1.10.6.1.6.31", "1.3.6.1.4.1.9600.1.10.6.1.6.32", "1.3.6.1.4.1.9600.1.10.6.1.6.33", "1.3.6.1.4.1.9600.1.10.6.1.6.34", "1.3.6.1.4.1.9600.1.10.6.1.6.35", "1.3.6.1.4.1.9600.1.10.6.1.6.36", "1.3.6.1.4.1.9600.1.10.6.1.6.37", "1.3.6.1.4.1.9600.1.10.6.1.6.38", "1.3.6.1.4.1.9600.1.10.6.1.6.39", "1.3.6.1.4.1.9600.1.10.6.1.6.40", "1.3.6.1.4.1.9600.1.10.6.1.6.41", "1.3.6.1.4.1.9600.1.10.6.1.6.42", "1.3.6.1.4.1.9600.1.10.6.1.6.43", "1.3.6.1.4.1.9600.1.10.6.1.6.44", "1.3.6.1.4.1.9600.1.10.6.1.6.45", "1.3.6.1.4.1.9600.1.10.6.1.6.46", "1.3.6.1.4.1.9600.1.10.6.1.6.47", "1.3.6.1.4.1.9600.1.10.6.1.6.48", "1.3.6.1.4.1.9600.1.10.6.1.6.49", "1.3.6.1.4.1.9600.1.10.6.1.6.50", "1.3.6.1.4.1.9600.1.10.6.1.6.51", "1.3.6.1.4.1.9600.1.10.6.1.6.52", "1.3.6.1.4.1.9600.1.10.6.1.6.53", "1.3.6.1.4.1.9600.1.10.6.1.6.54", "1.3.6.1.4.1.9600.1.10.6.1.6.55", "1.3.6.1.4.1.9600.1.10.6.1.6.56", "1.3.6.1.4.1.9600.1.10.6.1.6.57", "1.3.6.1.4.1.9600.1.10.6.1.6.58", "1.3.6.1.4.1.9600.1.10.6.1.6.59", "1.3.6.1.4.1.9600.1.10.6.1.6.60", "1.3.6.1.4.1.9600.1.10.6.1.6.61", "1.3.6.1.4.1.9600.1.10.6.1.6.62", "1.3.6.1.4.1.9600.1.10.6.1.6.63", "1.3.6.1.4.1.9600.1.10.6.1.6.64" );
my ($i,$tempstart,$tempstop,$voltstart,$voltstop,$fanstart, $fanstop,$start,$stop) = (0,1,33,33,49,49,65);
#print ("mib50:$MBM_OIDS[50]\n");
if ($ARGV[0] =~ /temperature/i) { for ($i= $tempstart; $i < $tempstop; $i++) { $MBM_RESULTS[$i] = $session->get_request( -varbindlist => [$MBM_OIDS[$i]]); } } elsif ($ARGV[0] =~ /voltage/i) { for ($i= $voltstart; $i < $voltstop; $i++) { $MBM_RESULTS[$i] = $session->get_request( -varbindlist => [$MBM_OIDS[$i]]); } } elsif ($ARGV[0] =~ /fan/i) { for ($i= $fanstart; $i < $fanstop; $i++) { $MBM_RESULTS[$i] = $session->get_request( -varbindlist => [$MBM_OIDS[$i]]); } }
if (!defined(@MBM_RESULTS)) { printf("ERROR: %s.\n", $session->error); $session->close; exit 1; }
printf("fan3 on '%s' is %s\n", $session->hostname, $MBM_RESULTS[50]->{$MBM_OIDS[50]} ); $session->close;
if ($ARGV[0] =~ /temperature/i) { $start = $tempstart; $stop = $tempstop; } elsif ($ARGV[0] =~ /voltage/i) { $start = $voltstart; $stop = $voltstop; } elsif ($ARGV[0] =~ /fan/i) { $start = $fanstart; $stop = $fanstop; }
for ($i= $start; $i < $stop; $i++) { print("value[$i]:$MBM_RESULTS[$i]->{$MBM_OIDS[$i]}\n"); }
sub usage { print("\nUSAGE: snmp_mbm5.pl {MBM5 Catagory} {SNMP Version} {Community} {Host} *{Port} \n\n"); print(" MBM5 Catagory\t Valid options are: fan, voltage, or temperature \n"); exit(-1); }
(*) WARNING 1 long line(s) split
C:\Documents\Scripts\Cacti>perl snmp_mbm5.pl fan 1 public 127.0.0.1 161 fan3 on '127.0.0.1' is 2445. value[49]:255. value[50]:2445. value[51]:255. value[52]:255. When I walk it with GetIF, this is what I get:
enterprises.wtcs.informant.motherBoardMonitor.mbmSensorTable.mbmSensorEntry.mbmSensorCurre *ntS.49 : 255. enterprises.wtcs.informant.motherBoardMonitor.mbmSensorTable.mbmSensorEntry.mbmSensorCurre *ntS.50 : 255. enterprises.wtcs.informant.motherBoardMonitor.mbmSensorTable.mbmSensorEntry.mbmSensorCurre *ntS.51 : 2445.
(*) WARNING 3 long line(s) split Any idea how to adjust the data?
-- If it's not on Google, then it doesn't exist.
**DC++ FAQ** |