#!/usr/bin/perl -w use strict; #modules used use XML::Simple; use Data::Dumper; use Net::SNMP; our ($data, $xml, $e, $Host, $OID, $port, $value, $IPAddressA, $session, $error); #create object $xml = new XML::Simple; # MIB Hard value taken from parameters of the DC1 fab port pairs script 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 XML input file in the future $Host = "10.2.125.110"; # read the XML file $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"; $IPAddressA = $e->{DeviceA}->{IPAddress} ; print "Var name for IpAddressA is " . $IPAddressA . "\n"; } ##test SNMP code print "SNMP test run \n"; ($session,$error) = Net::SNMP->session(Hostname => $Host, Community => "public"); die "session error: $error" unless ($session); $value = $session->get_request($OID); die "request error " . session->error unless (defined $value); $session->close; print "port info: " . $value . "\n";