Monitoring sipX Server Performance with MRTG

From SIPfoundry sipx, The Open Source SIP PBX for Linux - Calivia

Jump to: navigation, search

Note: Starting with the 3.9 / 3.10 release MRTG statistics are integrated into sipXconfig and manual config as described here is no longer needed.

Contents

Installation

The following was done on FC5 after installing using the sipXecs Single CD installation CD.

yum install net-snmp-utils mrtg

On a newly installed sipX sytem (from CD), the following packages are pulled in: gd, lm.sensors, net-snmp, net-snmp-libs, net-snmp-utils. mrtg, fontconfig, freetype, libXpm, libjpeg, libpng

Configuration

Configure SNMP

cd /etc/snmp
mv snmpd.conf snmpd.conf.old
File: snmp.conf
rocommunity sipxtest

disk /var

Start SNMP:

chkconfig snmpd on
service snmpd start

Test:

snmpwalk -v 1 -c sipxtest localhost system

Configure MRTG

cd /etc/mrtg
mv mrtg.cfg mrtg.cfg.old
cfgmaker --output=/etc/mrtg/mrtg.cfg --global "workdir: /var/sipxdata/mrtg" -ifref=ip \
    --global 'options[_]: growright,bits' sipxtest@localhost 

mkdir /var/sipxdata/mrtg

Copy the MRTG icons from where they got installed:

cp /var/www/mrtg/* /var/sipxdata/mrtg

Run twice:

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
indexmaker --output=/var/sipxdata/mrtg/index.html /etc/mrtg/mrtg.cfg

Configure the Apache Web server

File: /etc/sipxpbx/httpd-mrtg.conf
#
# This configuration file maps the mrtg output (generated daily)
# into the URL space.  By default these results are only accessible
# from the local host.
#
Alias /mrtg /var/sipxdata/mrtg

<Location /mrtg>
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1 192.168.5.0/24
   Allow from ::1
   Allow from .example.com
</Location>
File: /etc/sipxpbx/httpd.conf
# Add the following line at the end of the file:
# sipx mrtg configuration includes
Include /etc/sipxpbx/httpd-mrtg.conf

Now restart sipxpbx:

service sipxpbx restart

Now point your browser at:

http://sipx.example.com/mrtg

Adding additional statistics

Additional statistics can be added by extending the MRTG configuration file at /etc/mrtg/mrtg.cfg.

Replace the current file mrtg.cfg with this one.

After updating the configuration file re-run the indexmaker command.

Monitoring the DNS Server

Download the DNS monitoring script:

cd /etc/mrtg
wget http://www.megalinux.net/dnsstats.pl .
chmod +x dnsstats.pl

Update the location of the DNS stats file (this path is defined in /etc/named.conf): Edit the file dnsstats.pl:

my $newstatfile = "/var/named/data/named_stats.txt";

Note: Change permissions on named_stats.txt so that user named can write to it. Otherwise the command rndc stats returns a permission denied error.

Add this to the mrtg.cfg file (replace public@localhost with your community string):

 Target[mydomain_DNS]: `/etc/mrtg/dnsstats.pl`
 Options[mydomain_DNS]: gauge,growright,nopercent,integer,unknaszero
 Title[mydomain_DNS]: DNS Server
 RouterUptime[mydomain_DNS]: public@localhost
 MaxBytes[mydomain_DNS]: 32000
 AbsMax[mydomain_DNS]: 64000
 WithPeak[mydomain_DNS]: wmy
 Colours[mydomain_DNS]: YELLOW #F9C000,RED #F90000,LIGHT YELLOW #FFFFBB,LIGTH RED #FF8080
 ShortLegend[mydomain_DNS]:queries/m
 YLegend[mydomain_DNS]: Qs per Minute
 Legend1[mydomain_DNS]: Queries received over 1 minute
 Legend2[mydomain_DNS]: Failed Queries received over 1 minute
 Legend3[mydomain_DNS]: Maximal Queries over 5 minutes
 Legend4[mydomain_DNS]: Maximal Failed Queries over 5 minutes
 LegendI[mydomain_DNS]:  Queries: 
 LegendO[mydomain_DNS]:  Failures: 
 PageTop[mydomain_DNS]: <H1>DNS Info</H1>
 

Monitoring the DHCP Server

Download the DHCP monitoring script:

cd /etc/mrtg
wget http://www.net-track.ch/php/d.php?f=/opensource/dhcp-leasecount/dhcp-leasecount-0.1.tar.gz .
tar xvzf dhcp-leasecount-0.1.tar.gz

Add this to the mrtg.cfg file (replace public@localhost with your community string):

#
# DHCP Lease Count
#

Target[mydomain_DHCP]: `/etc/mrtg/dhcp-leasecount-0.1/dhcp-leasecount 192.168.5.180-192.168.5.253`
Options[mydomain_DHCP]: gauge,growright,nopercent,integer,unknaszero
Title[mydomain_DHCP]: DHCP Server
RouterUptime[mydomain_DHCP]: sipxtest@localhost
MaxBytes[mydomain_DHCP]: 32000
#AbsMax[mydomain_DHCP]: 64000
#WithPeak[mydomain_DHCP]: wmy
Colours[mydomain_DHCP]: YELLOW #F9C000,RED #F90000,LIGHT YELLOW #FFFFBB,LIGTH RED #FF8080
ShortLegend[mydomain_DHCP]: addresses
YLegend[mydomain_DHCP]: Number of addresses
Legend1[mydomain_DHCP]: Total available addresses
Legend2[mydomain_DHCP]: Active leases
Legend3[mydomain_DHCP]: Expired leases
Legend4[mydomain_DHCP]: Still available addresses
LegendI[mydomain_DHCP]:  Total Available addresses:
LegendO[mydomain_DHCP]:  Active leases:
PageTop[mydomain_DHCP]: <H1>DHCP Info</H1>
 

Converting to RRDTool

The following describes an alternative way of generating the performance graphics. Instead of MRTG generating new graph image files every 5 minutes, graphs are generated only on demand. MRTG now only stores the performance data in RRDTool, which is a database optimized for this application. The actual graphs are generated by a CGI, separate from MRTG.

Motivation: Better performance, nicer graphs.

yum install rrdtool rrdtool-perl

Pulls in rrdtool, libart_lgpl

Copy the mrtg configuration (/etc/mrtg/mrtg.conf) file to mrtg-rrd.cfg and add the following lines at the top:

LogFormat: rrdtool
PathAdd: /usr/bin
LibAdd: /usr/lib/perl5/5.8.8/i386-linux-thread-multi

Test:

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg-rrd.cfg

Download and Install 14all.cgi

wget http://superb-east.dl.sourceforge.net/sourceforge/my14all/14all-1.1p25.tar.gz
tar xzf 14all-1.1p25.tar.gz
mkdir /var/sipxdata/mrtg/cgi-bin
cp 14all/14all.cgi /var/sipxdata/mrtg/cgi-bin

Replace the library path in 14all.cgi line 14 with:

use lib qw(/usr/lib/mrtg2); 

Add the path to the mrtg-rrd.cfg file on line 58 and comment out line 63.

Copy the mrtg.cfg file:

cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg-rrd.cfg

Change the cron job entry:

MRTG still needs to run evey 5 minutes to collect the data from snmpd and other monitored services. Instead of creating image files of the graphs, it will now just store the data in RRDTool. The cron entry needs to be changed so that MRTG is started with the new config file mrtg-rrd.cfg. Edit file /etc/cron.d/mrtg to accomplish this.

Change the Apache config to allow CGI scripts

Add the following:

File: /etc/sipxpbx/httpd-mrtg.conf
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/sipxdata/mrtg/cgi-bin/"

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/sipxdata/mrtg/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

Restart sipxpbx:

service sipxpbx restart

Point your browser at:

http://sipx.example.com/cgi-bin/14all.cgi

More Info

Personal tools