I'm working with NetSNMP and hoping to use it to return some useful info on my machines. I have entered the example module from http://docs.fedoraproject.org/en-US/Fedora/16/html/System_Administrators_Guide/sect-System_Monitoring_Tools-Net-SNMP-Extending.html and this works just fine.
If I add a use dbsize.pm; line to this file to import my additional module it stops working. Below I have included the module and some test code to show that the module works ok.
Here is my extension module:
package dbsize; sub new { my $package = shift; my $self = bless ({}, $package); return $self; } sub getseq { return 25; } 1;

If I use dbsize.pm in the sample code it stops working. I don't even have to call the getseq() function. No error messages.

If I use dbsize.pm in a piece of test code it works fine.

Example:
#!/usr/bin/perl -w use dbsize; $dbs = new dbsize(); print $dbs->getseq(); print "\n"; root@plugpc-002:/usr/local/bin# ./dbtest.pl 25
Question: Is there something in SNMP or NetSNMP that prevents importing a module? I can't imagine why there would be.. so the problem must be in my implementation.

EDIT: It was a path issue. My module was in /usr/local/bin (as was the main file). When I added this to the path it worked out ok. Never did see any error messages though.

In reply to NetSNMP - writing some agent code by ethrbunny

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.