in reply to Windows SNMP Querying?

Instead of modifying the MRTG config file each time, I would suggest you use the "back-tick" option to run an external perl script. This script needs to do the digging into the OID's and retrieve the values. Read the section on "External Monitoring Scripts" in MRTG.

Here is some skeleton SNMP access code, to get you started: (Stripped - to reduce complexity - version of working code).

use strict; use Net::SNMP qw(snmp_dispatcher ticks_to_time oid_lex_sort); my ($session, $error) = Net::SNMP->session( -hostname => $_, ## -version => 'snmpv2c', ## E7 Gen 2 supports only V1 ##-nonblocking => 1, -translate => [ -timeticks => 0x0 # Turn off so sysUpTime is nume +ric ], -community => $ARGV[1] || 'public', -port => $ARGV[2] || 161, -timeout => 20 # Seconds ); if (!defined($session)) { printf("ERROR for %s: %s.\n",$_, $error); exit 1; } &Get_Session_Data($session); ################################################################# sub Get_Session_Data { my $session = shift; my $result = $session->get_request( -varbindlist => [$sysUpTime, $dot1dStpTopChanges, $dot1dStpDesignatedRoot, $dot1dBaseNumPo +rts, $dot1dStpTimeSinceTopologyChange ]); ## ,$dot1dTpFdbTable] ); if (!defined($result)) { printf("ERROR: %s.\n", $session->error); next; } # my $uptime = $session->var_bind_list()->{$sysUpTime}; #printf("%-15s Ok (%s)\n", # $session->hostname, ticks_to_time($uptime) ); print( $session->hostname . " " . &showinfo($session,"TC_count",$dot1dStpTopChanges) . &showinfo($session,"rootBridge",$dot1dStpDesignatedRoot) . &showinfo($session,"ports",$dot1dBaseNumPorts) . &showinfo($session,"TC_Time",$dot1dStpTimeSinceTopologyCha +nge). "\n" ); $x->TC_Count ($session->var_bind_list()->{$dot1dStpTopChanges} +); $x->RootBridge($session->var_bind_list()->{$dot1dStpDesignatedR +oot}); $x->MaxPorts ($session->var_bind_list()->{$dot1dBaseNumPorts}) +; $x->TC_Time ($session->var_bind_list()->{$dot1dStpTimeSinceTo +pologyChange}); ##&print_results_cb($session); } } ################################################################# sub showinfo(){ my ($session,$varname,$oid) = @_; my $format="%5d"; # Default format, if numeric my $val = $session->var_bind_list()->{$oid}; if (length($val)> 5 or $val > 9999){ return $varname . "=" . $val . "; "; } return $varname . "=" . sprintf("%6d", $val) . "; "; } ###########################################

Offense, like beauty, is in the eye of the beholder, and a fantasy.
By guaranteeing freedom of expression, the First Amendment also guarntees offense.

Replies are listed 'Best First'.
Re: Re: Windows SNMP Querying?
by Dante_Graves (Initiate) on Apr 12, 2004 at 22:37 UTC
    Ah, thank you very much! Although I don't have the slightest idea on how to use this, I'll find out how! All I really needed was a little bit of a roadmap to point me in the direction I should go.