Hello Monks,


I beleive my question is more of an SNMPd question than a perl question, though I have been unable to find the answer on my own, or on more general linux forums; I am asking here in a desparate hope someone has done before what I am atempting to do now.

My goal: Create a custom SMTP monitor that returns the results of `exim -bpc` to my SNMP monitor. I would like to create an agent that responds to request to a cusom OID. That being said, another solution has been proposed to set a cron job to dump the return value of `exim -bpc` to a log file then have an snmp agent watch the log file. The second solution though less preferred seems like it would be 'easier'... what do you think?

here's what I've got so far:

#!/usr/bin/perl # place this in a .pl file, and then in your snmpd.conf file put: # perl do '/path/to/file.pl'; use NetSNMP::agent; my $agent; sub myhandler { my ($handler, $registration_info, $request_info, $requests) = @_; my $request; $request->setValue(ASN_OCTET_STRING, "hello\n"); } $agent = new NetSNMP::agent( 'Name' => 'my_agent_name', ); $agent->register( "my_agent_name", ".1.3.6.1.4.1.8072.9999.9999.9999", \&myhandler ); $agent->main_loop();

This is essentially the example in the documentation on CPAN.
When I attempt to run this from the command line I receive the error:

Warning: no access control information configured. It's unlikely this agent can serve any useful purpose in this state. Run "snmpconf -g basic_setup" to help you configure the my_agent_name.conf file for this agent.

this is highly confusing as running this command does not provide the ability to configure a agent.conf file, nor am I able to find any documentation on agent.conf files. Perhaps I am not googling for this correctly (SNMP agent.conf file, directives, configuration), I would greatly appreciate any hints on where to find this documentation.

additionally when run from a perl do /foo/test_agent.pl directive it causes snmpd to hang (become unresponsive). (either when started via init/services or from the commandline via snmpd -f)

Then I've tried registering the agent itself via my_agent_name .1.3.6.1.4.1.8072.9999.9999.9999 /root/snmp/test_agent.pl which appears to have no affect on functionality. (this directive I pulled out of the SNMP::Server::Logtail docs. (realizing this is a hail mary, I figured it couldn't hurt my dev box to wave a dead chicken...)

I really feel like I am just missing a simple piece of this puzzle... no matter how simple it seems to be the obsticle that is blocking my progress... If any one can even poing me in the general direction I'm sure it would help me get the wheels moving again.


In reply to Perl and SNMP (or how to create a custom SNMP agent.) by PyrexKidd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.