Thanks to everyone that helped me get aroudn the pointer to arrays and hashes of array references and all that mutha jazz.
I post my result here. Thsi is my first real foray into arrays and as such I hope is received kindly. Thanks to masem for that lovely snippet just above me. I am going to need a glass fo hogfat to wash that down my mental gullet, so to speak.
#!/usr/bin/perl
use SNMP_util;
$nameOID = ".1.3.6.1.4.1.2021.2.1.2";
@addOID = qw(.1.3.6.1.4.1.2021.2.1.3 .1.3.6.1.4.1.2021.2.1.4 .1.3.6.1.
+4.1.2021.2.1.5 .1.3.6.1.4.1.2021.2.1.101);
$IP = "127.0.0.1";
(@tempNameArray) = &snmpwalk($IP,$nameOID);
foreach $a (@tempNameArray) {
($throw, $name) = split(/:/,$a,2);
push(@arrayNames, $name);
}
$control = 0;
foreach $i (@arrayNames) {
foreach $j (@addOID) {
(@breakMe) = &snmpwalk($IP,$j);
($throw, $value) = split(/:/,$breakMe[$control
+],2);
$resultHash{$i} .= $value.",";
}
$control++;
}
foreach $key (keys %resultHash) {
($svcMax, $svcMin, $svcActual, $svcErr) = split(/,/,$resultHas
+h{$key});
print "-----------------------\n",$key, " values are:\n";
print "Maximum Services: ", $svcMax, "\n";
print "Minimum Services: ", $svcMin, "\n";
print "Actual Services Running: ", $svcActual, "\n";
print "Error Message: ", $svcErr, "\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.