I actually figured out the sub. All that it does is check list of active IP's pulled in from SNMP against the hash and adds the new ones. I still need to add the part to strip out the old ones.
anyway, the working code is:
sub loadIPs {
my $datahashref = shift;
my $parmhashref = shift;
my $IPs = '1.3.6.1.2.1.10.127.1.3.3.1.3';
my ($session, $error) = Net::SNMP->session(%$parmhashref);
my $reply = $session->get_table(-baseoid=> $IPs);
my %reply = %$reply;
while ( my ($oid, $ip) = each(%reply) ) {
my %tmpHash = ('rx'=>undef, 'tx'=>undef);
$$datahashref{$ip} = %tmpHash unless exists $$datahashref{$ip};
}
}
it was the $$ reference I wasn't grasping.
When I mentioned stale data, I didn't mean it as a bad thing; just a word to differentiate it from the new stuff, and I want the script to just update the hash on the fly. No clearing out the whole thing and starting fresh.
I was actually hoping to keep the GUI refresh rate higher then the time it takes to query all the modems. On a large plant, the query process can take a full minute or two, and I'd like to be able to watch the changes trickle in.
I'll have to read up on the threads::shared mod
thanks
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.