Mod-Apache-Snmp - Documentation
   
 
Features
  Instalation
  Configuration
  MIB´s
  Examples
  MRTG graphs for Apache values
  FAQ's
 
Features

Apache 2.0.x Compatible.
It uses an independent snmp agent (Net-SNMP).
Supports SNMPv1, SNMPv2, SNMPv3.
Supports Notifications.
Allow you to monitor principal configuration and status values of Apache
.

 
Instalation

Requirements:

Apache Web Server 2.0.xx - (http://www.apache.org)
Net-SNMP 5.1 (o superior) - (http://www.net-snmp.org)

Mod-APACHE-SNMP

1) Install Apache Web Server with DSO support enabled.

./configure --enable-so [..otras opciones..]
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


Configuration

There are two principal things that you have to do in the configuration stage:

a) Configure the SNMP agent setting the communities and grants that you willl use for the managed objects.

b) Load SNMP module in Apache (with LoadModule) and set which agent it´s going to use.

For point a), you should configure snmpd.conf (NET-SNMP agent configuration file) as you do normally. (See http://www.net-snmp.org/man/snmpd.conf.html).

For point b), there are some configuration directives detailed below:

Inside httpd.conf you should set the following directives:

Load and Activate SNMP module, using the following:

- LoadModule ap2_snmp_module modules/mod_ap2_snmp.so

Then you must specify a Location named "ap2_snmp" (See example) and use the following directives to configure the module.

snmp_community specify the snmp community that Apache will use to communicate with SNMP agent.
snmp_agent_address Agent SNMP IP address.
snmp_tmp_dir Temporal directory that´s used to interchange information between Apache and the SNMP agent. Apache must have write permission in that directory.
snmp_version SNMP version used by Apache to communicate with the SNMP Agent.
snmpv3_user If you use SNMPv3, you must specify the user and password here.
snmp_http_address IP address and port used by the SNMP agent to make requests to Apache.

- Enable mod_status module

Enable ExtendedStatus directive (ExtendedStatus On)

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

LoadModule ap2_snmp_module modules/mod_ap2_snmp.so

ExtendedStatus On

<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/
snmp_version 3
snmpv3_user user1 pass1
snmp_http_address 127.0.0.1 8080


MIB´s

This module use it´s own MIB for the managed objects.

SeeAPACHE2-MIB

 

FAQ´s
Type
Question
Solution
Compiling / Linking I get "cannot find -lcrypto collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
" error at linking time..
it can`t find libcryto.so file in the libs directory. Please check that you have that file in the path that you set in libs_net_snmp
var. If you don`t have that file there, make a symlink to that file.

And If you don`t have that library in your system, try to install an open-ssl package (for example:. openssl 0.9.7a-20.2).


Configuration Should I start SNMP agent BEFORE Apache? Yes, you must have SNMP agent (Net-SNMP) started before Apache because the module needs to initialize some mib objects when start.
Configuration

In my access_log file there are a lot of requests like this "GET /ap2_snmp/status" 200 2"

Is that correct? How can avoid them?

Yes, it´s correct because the snmp module check apache status and use that kind of request. But you can avoid them to get logged using the following directives in httpd.conf:

SetEnvIfNoCase Request_URI /ap2_snmp agent_snmp
CustomLog logs/access_log common env=!agent_snmp

 
MRTG graphs for Apache values

Using MOD-APACHE-SNMP and MRTG you can graph any of the APACHE2-MIB objects. For example, it´s possible to get graphs for KBytes / Secs (APACHE2-MIB::serverKBytesPerSec.0), the number of busy Workers (APACHE2-MIB::busyWorkers.0) or any other mib object that you want to graph.

Download docs, examples and some scripts to use MRTG with MOD-APACHE-SNMP Here

Busy Idle Workers
Bytes Per Request
Bytes Per Second

 

 

Examples

Using Net-SNMP (http://www.net-snmp.org) applications (snmpget in this example) you can get the information of the objects defined in the mib (APACHE2-MIB.txt).

 

Getting total traffic (in kb) of Apache:
snmpget -v1 -c public localhost APACHE2-MIB::totalTraffic.0 (for example, using SNMP v1)

Getting Server Status:
snmpget -v1 -c public localhost APACHE2-MIB::serverStatus.0
Getting Server Uptime:
snmpget -v1 -c public localhost APACHE2-MIB::serverUptime.0
Getting HTTP 404 errors count:
snmpget -v1 -c public localhost APACHE2-MIB::httpError404.0