in reply to Perl and SNMP (or how to create a custom SNMP agent.)

UPDATE

Ok, I borrowed from the tutorial and came up with the following code

#!/usr/bin/perl # # for this to work place this file in: /usr/share/snmp/exim_queue_mo +nitor.pl # insert the following line in /usr/share/snmp/snmpd.conf # perl do "/usr/share/snmp/exim_queue_monitor.pl # use strict; use warnings; # Global Vars: our $agent; # Private vars my $regat = '.1.3.6.1.4.1.8072.9999.9999'; my $running; # set to 1 to get extra debugging information my $debugging = 1; # if we're not embedded, this will get auto-set below to 1 my $subagent = 0; BEGIN { print STDERR "starting exim_queue_monitor.pl\n"; } use NetSNMP::OID (':all'); use NetSNMP::agent (':all'); use NetSNMP::ASN (':all'); print STDERR "exim_queue_monitor.pl loaded ok\n"; # where we are going to hook onto my $regoid = new NetSNMP::OID($regat); print STDERR "registering at ",$regoid,"\n" if $debugging; # we register ourselves with the master agent we're embedded in. The # global $agent variable is how we do this: $agent->register('exim_queue_monitor',$regoid, \&exim_queue_monitor); # processes system command and updates request obj. sub process_mail_queue{ my $request = shift; my $queue_len = `exim -bpc`; chomp $queue_len; print STDERR " -> queue length = $queue_len\n" if $debugging; $request->setValue(ASN_INTEGER, $queue_len); } ###################################################################### # define a handler for incoming SNMP requests for our part of the OID +tree. # This subroutine will get called for all # requests within the OID space under the registration OID made above. # however, in its current form, this will -only- return # for requests to our full OID sub exim_queue_monitor { my ($handler, $registration_info, $request_info, $requests) = @_; my $request; #debug messages do { print STDERR "refs: ",join(", ", ref($handler), ref($registrat +ion_info), ref($request_info), ref($requests)),"\n"; print STDERR "processing a request of type " . $request_info-> +getMode() . "\n"; } if $debugging; for($request = $requests; $request; $request = $request->next()) { my $oid = $request->getOID(); print STDERR " processing request of $oid\n" if $debugging; if ($request_info->getMode() == MODE_GET) { # if the requested oid is equals to ours, then return the +data if ($oid == new NetSNMP::OID($regat . ".1.2.1")) { process_mail_queue $request; } } elsif ($request_info->getMode() == MODE_GETNEXT) { # if the requested oid is equals to ours, then return the +data if ($oid == new NetSNMP::OID($regat . ".1.2.1")) { process_mail_queue $request; } } }# end for loop print STDERR " finished processing\n" if $debugging; }

Great, works locally... But not remotely... Any thoughts?
Thanks in advance