SNMPTT 内嵌处理模式的应用

The embedded handler is a small Perl program that is loaded directly into snmptrapd when snmptrapd is started.  The limitations of this handler are:
  • Requires embedded Perl for snmptrapd

  • Only works with daemon mode

The benefits of using this handler are:
  • The handler is loaded and initialized when snmptrapd is started, so there is less overhead as a new process does not need to be created and initialization is done only once (loading of snmptt.ini).

  • SNMPv3 EngineID and names variables are available in snmptt (B* variables)

1.  Read this entire file to understand how snmptt works

2.  Make sure snmptrapd has embedded Perl support enabled.  When compiling from source, use the '--enable-embedded-perl' configuration option.  

     Type snmptrapd -H 2>&1 | grep perl.  It should give perl   PERLCODE if embedded Perl is enabled.  

     If it's not available, you need to compile Net-SNMP using the --enable-embedded-perl configure option.

3.  Copy snmptt to /usr/sbin/ and ensure it is executable (chmod +x snmptt)

4.  Copy snmptthandler-embedded to /usr/sbin/.  It does not need to be executable as it is called directly by snmptrapd.

5.  Copy snmptt.ini to /etc/snmp/ or/etc/ and edit the options inside the file.

6.  Either copy examples/snmptt.conf.generic to/etc/snmp/snmptt.conf(renaming the file during the copy) or use the touch command to create the file (touch /etc/snmp/snmptt.conf).

7.  Create the log folder /var/log/snmptt/. And execute the script:

        chown snmptt:snmptt -R /var/log/snmptt/
        chmod ug+rw -R /var/log/snmptt/


8.  Configure snmptrapd and install the service:

Modify (or create) the Net-SNMP snmptrapd.conf file by adding the following line:

perl do "/usr/sbin/snmptthandler-embedded";
Create the spool folder/var/spool/snmptt/.
A startup script is included which can be used to start and stop snmptt on Mandrake, RedHat and other systems.  Copy the script to the init.d directory (renaming the file during the copy):

cp snmptt-init.d /etc/rc.d/init.d/snmptt

Add the service using chkconfig:

chkconfig --add snmptt

Configure the service to start at runlevel 2345:

chkconfig --level 2345 snmptt on

Snmptt will be started at the next reboot, or can be started immediately with:

service snmptt start

or

/etc/rc.d/init.d/snmptt start

To manually start snmptt, use:

snmptt --daemon

9.       A log rotation script is included which can be used to rotate the log files on Mandrake, RedHat and other systems.  Copy the file to the logrotate.d directory (renaming the file during the copy):

cp snmptt.logrotate /etc/logrotate.d/snmptt

Edit the /etc/logrotate.d/snmptt and update the paths and rotate frequency as needed.

10.     Start snmptrapd using the command line: snmptrapd -On.


You should be able to edit the /etc/rc.d/init.d/snmptrapdscript if you have one and change
the OPTIONS to "-On".


Note:  The -On is recommended.  This will make snmptrapd pass OIDs in numeric form and prevent SNMPTT from having to translate the symbolic name to numerical form.  If the UCD-SNMP / Net-SNMP Perl module is not installed, then you MUST use the -On switch.  Depending on the version of UCD-SNMP / Net-SNMP, some symbolic names may not translate correctly.  See the FAQ for more info.

As an alternative, you can edit your snmp.conf file to include the line: printNumericOids 1.  This setting will take effect no matter what is used on the command line.

你可能感兴趣的:(snmptt)