wruehl has asked for the wisdom of the Perl Monks concerning the following question:
Ideally what I'd like to be able to do is Run the SNMPget command within the foreach loop and report the findings to a seperate file. Eventually this code will be used by NetIQ to run a port monitoring script and will have calls to the their libraries for the reporting.
Also if anyone could give me tips on the proper input to the Net::SNMP snmpget function that would be appreciated, all of the examples I've seen have used some form of variable to extract the target. What I'd like to do is be able to use the IP address and port from the foreach statement in my request, and store the results in variables to either be logged or reported in some way. I already have the OID that I'll need to be accessing, so if possible I'd like to know the syntax for that sort of request.
Data dump output of one iteration of the file:#!/usr/bin/perl -w #use strict; #modules used use XML::Simple; use Data::Dumper; use Net::SNMP; our ($data, $xml, $e, $Host, $OID, $port, $CMD, $value, $SNMP_TARGET , + $SNMP_GET_CMD); #create object $xml = new XML::Simple; # MIB Hard value taken from parameters of the DC1 fab port pairs scrip +t appended a 1 to test port #1 $OID = ".1.3.6.1.4.1.289.2.1.1.2.3.1.1.152.1"; #checking against PD110 as a test run will probably be read from an XM +L input file in the future $Host = "10.2.125.110"; # read the XML file #$CMD = "snmpget -v1 -c public -Ovq -m "; #chomp($value = '${CMD} ${Host} .1.3.6.1.4.1.289.2.1.1.2.3.1.1.152.1') +; #print $value; $data = $xml->XMLin("FabPortPairs.xml"); #print Dumper($data); foreach $e (@{$data->{PairedDevices}}) #Do actions that require use of XML data in this loop possibly #call SNMP data gathering and reporting { print "Pairname is: " . $e->{PairName} . "\n "; print "Hosted Apps are: " . $e->{HostedApplication} . "\n" ; print "HostOS is: " . $e->{HostOS} . "\n"; }
Thanks, Bill$VAR1 = { 'PairedDevices' => [ { 'DeviceB' => { 'SNMPCommunity' => 'public +', 'DeviceNickName' => 'SD131 +', 'SNMPPortIndex' => '19', 'IPAddress' => '10.2.125.1 +31', 'PathName' => '01', 'RealPort' => '18' }, 'ExclusionIndicator' => {}, 'PairName' => 'Chestnut', 'MetricSeverity' => '34', 'MinPercent' => '20', 'HostOwningGroup' => 'AIX Team', 'StatusAlertThisPair' => 'Y', 'DeviceA' => { 'SNMPCommunity' => 'public +', 'DeviceNickName' => 'SD130 +', 'SNMPPortIndex' => '19', 'IPAddress' => '10.2.125.1 +30', 'PathName' => '00', 'RealPort' => '18' }, 'StatusSeverity' => '31', 'HostedEnvironment' => 'Test', 'MetricAlertThisPair' => 'Y', 'MaxPercent' => '80', 'HostedApplication' => 'IEOR', 'HostOS' => 'AIX' },
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
by FunkyMonk (Bishop) on Jul 31, 2007 at 12:58 UTC | |
by wruehl (Acolyte) on Jul 31, 2007 at 13:05 UTC | |
by radiantmatrix (Parson) on Jul 31, 2007 at 14:01 UTC | |
by wruehl (Acolyte) on Jul 31, 2007 at 17:03 UTC | |
|
Re: Accessing 2nd level elements in XML::Simple and using the data in an SNMP call
by oha (Friar) on Jul 31, 2007 at 12:47 UTC |