mod_apache_snmp, net-SNMP (给apache2添加SNMP支持)
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
-
DISTRIB_ID=Ubuntu; DISTRIB_RELEASE=10.04; DISTRIB_DESCRIPTION=“Ubuntu 10.04.4 LTS”
-
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: #
http://mod-apache-snmp.sourceforge.net/english/docs.htm
(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 install.sh and modify the variables with the correct path of Apache and Net-SNMP libraries.
- \PATH-SOURCES-MOD-APACHE-SNMP\install.sh
Notice: #
- 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).
Hints: #
-
1)_ ld_ Cannot find crypto dynamic libriary_._
-
locate libcrypto ; then usually: ln -s libcrypto.so.1.0.0 libcrypto.so //??? why not libcrypto.so.3.x.x 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.
-
- The config part is confusing, just do these:
#httpd.conf example (using the module’s directives)
LoadModule ap2_snmp_module modules/mod_ap2_snmp.so
#seems “ExtendedStatus” does not matter // TODO???
# though also write in the <Location server-status> </> http://httpd.apache.org/docs/2.2/mod/mod_status.html .
#test result: these ‘status’ things do not matter.
#ExtendedStatus On #default: Off
<Location /ap2_snmp>
Sethandler ap2_snmp # handler managed by snmp module.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
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 127.0.0.1 8080
-
- 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: