mod_apache_snmp, net-SNMP (给apache2添加SNMP支持)

2012 - 04 - 18

Tested on platform:

  • vmware
  • Linux ubuntu 2.6.32-38-generic #83-Ubuntu SMP Wed Jan 4 11:13:04 UTC 2012 i686 GNU/Linux
  • httpd-2.0.64.tar.bz2; net-snmp-5.4.4; mod_ap2_snmp_1.04.
  • sudo -s;
  • apt-get remove lamp-server^ snmpd # if you have already installed apache or snmp-server.

Just do it:

(below is a summary)

1) Install Apache Web Server with DSO support enabled.

./configure --enable-so; make; make install

2) Unzip NET-SNMP sources.

3) Unzip Mod-APACHE-SNMP sources.

4) Copy files into Net-SNMP directory to support Apache's MIB:

- Copy net-snmp-module\ -->PATH-SOURCES-NET-SNMP\agent\mibgroup\apache2\ (create apache2)

  • Copy extra\ap2_snmp.h --> PATH-SOURCES-NET-SNMP\agent\mibgroup\
  • Copy mib\APACHE2-MIB.txt --> PATH-SOURCES-NET-SNMP\mibs\

5) Install Net-SNMP

./configure --with-mib-modules=ap2_snmp make make install

6) Compile and install SNMP module for Apache.

- Edit and modify the variables with the correct path of Apache and Net-SNMP libraries.



  • Step-1, Have to compile apache2 from source code, otherwise step-6 could not find the DSO-related file (the apache2-dev has conflict with other package(s) while using apt-get).
  • Step-4, when copying net-snmp-module, rename this folder to apache2 (or copying the content), instead of putting it as a sub-folder in apache2.
  • Step-5, delete the spaces before and after the '=' equal sign. (just like bash).


  • 1)_ ld_ Cannot find _crypto_ dynamic libriary_._
  • _locate libcrypto ; then usually: ln -s //??? why not which exists on some guys' machines._* 2) _cp_ APACHE2-MIB.TXT to /usr/local/share/snmp/mibs/ and _chmod +r _//seems the author forgets to cp.
  • 3) The config part is confusing, just do these:

#httpd.conf example (using the module's directives)

LoadModule **ap2_snmp_module** modules/

#seems "ExtendedStatus" does not matter // TODO???

# though also write in the <Location server-status> </> .

#test result: these 'status' things do not matter.

#ExtendedStatus On #default: Off


Sethandler ap2_snmp # handler managed by snmp module.

Order Deny,Allow

Deny from all

Allow from

snmp_community public snmp_agent_address localhost snmp_tmp_dir /tmp/

#version 1 or 2, does not matter. (though choose 1 when ./configure the net-snmp)
snmp_version 1

i do not use v3

#snmpv3_user user1 pass1
snmp_http_address 8080

  • 4) To run:
  • cd /usr/local/sbin; ./snmpd #run snmpd before apache2
  • cd /usr/local/apache2/bin; ./httpd* 5) Finally, Test the system using 'snmpget' command:
  • snmpget -v1 -c public localhost APACHE2-MIB::serverUptime.0
  • snmpget -v2c -c public localhost APACHE2-MIB::httpError404.0
  • #seems both versions work.* 6) To stop:
Write a Comment