[article_overview]
Monitor Debian Lenny
Software to install:
Munin
phpSysInfo
vnStat
Webalizer
top alternatives
[/article_overview]
File paths used:
/home/domains/<main domain>/www/htdoc - where web accessible files are stored
/home/domains/<main domain>/www/stat - where web accessible web statistics are stored
/home/domains/<main domain>/admin4/ - where server web accessible files are stored
/home/domains/<main domain>/admin4/mon/ - where server monitoring web accessible files are stored
The directory /home/domains/<main domain>/admin4/ should be password protected using .htacsess or other methods. You should also choose a somewhat unique directory name to minimize your exposure to the automated script kiddies.
Now on to the monitoring packages
munin gathers and graphs "everything" on your system
1
|
aptitude install munin munin-node
|
Configure munin
1
|
vi /etc/munin/munin.conf
|
Update
1
2
3
4
5
6
7
8
|
dbdir /var/lib/munin
htmldir /home/domains/<main domain>/admin4/mon/munin
logdir /var/log/munin
rundir /var/run/munin
tmpldir /etc/munin/templates
[server]
address 127.0.0.1
use_node_name yes
|
Create the directories in which munin will store its graphs
1
2
3
|
mkdir /home/domains/<main domain>/admin4/mon/munin
chown munin:munin /home/domains/<main domain>/admin4/mon/munin
/etc/init.d/munin-node restart
|
Alias this directory to your <main domain>/admin4/mon/munin
1
|
vi /etc/apache2/sites-enabled/<main domain>
|
Add below <VirtualHost <your ip>:80>
1
|
alias /admin4/mon/munin /home/domains/<main domain>.com/admin4/mon/munin/
|
Restart apache
1
|
/etc/init.d/apache2 restart
|
So now you can access from
http://<main domain>.com/admin4/mon/munin
phpSysInfo is a PHP script that displays information about the host being accessed.
It will displays things like Uptime, CPU, Memory, SCSI, IDE, PCI, and Ethernet.
mbmon is a hardware monitoring program usable by phpSysInfo
1
|
aptitude install phpsysinfo mbmon
|
Change the config
1
|
vi /etc/phpsysinfo/config.php
|
Update
1
2
3
|
define('useVhost', true);
define('sensorProgram', 'mbmon');
define('loadBar', true);
|
mbmon reports the temperatures, voltages and rpm of cooling fans
Update
By default, installed in /var/www/phpsysinfo/
Ao alias this directory to your <main domain>/admin4/mon/phpsysinfo
1
|
vi /etc/apache2/sites-enabled/<main domain>
|
Add below <VirtualHost <your ip>:80>
1
|
alias /admin4/mon/phpsysinfo /var/www/phpsysinfo/
|
Restart apache
1
|
/etc/init.d/apache2 restart
|
so now you can access from
http://<main domain>.com/admin4/mon/phpsysinfo
vnStat is a simple bandwidth monitor which uses very little resources
1
|
aptitude install vnstat
|
Initialize vnstat
View a few web pages on your site and monitor
Download php front end at http://www.sqweek.com/sqweek/index.php?p=1
1
2
3
4
5
6
7
|
cd /tmp
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz
tar -xvzf vnstat_php_frontend-1.4.1.tar.gz
mkdir /home/domains/<main domain>.com/admin4/vnstat
cp vnstat_php_frontend-1.4.1/* /home/domains/<main domain>.com/admin4/mon/vnstat/
cd /home/domains/<main domain>.com/admin4/vnstat/
vi config.php
|
Update
1
2
3
4
|
$iface_list = array('eth0');
$iface_title[ 'eth0'] = 'Internet';
$vnstat_bin = 'vnstat';
$data_dir = '';
|
Alias this directory to your <main domain>/admin4/mon/vnstat
1
|
vi /etc/apache2/sites-enabled/<main domain>
|
Add below <VirtualHost <your ip>:80>
1
|
alias /admin4/mon/vnstat /home/domains/<main domain>.com/admin4/mon/vnstat/
|
Restart apache
1
|
/etc/init.d/apache2 restart
|
So now you can access from
http://<main domain>.com/admin4/mon/vnstat
Monitor apache logs using webalizer
1
2
3
|
chown www-data:www-data /home/domains/<main domain>.com/www/stat/
aptitude install webalizer
|
Yo get individual stats per domain, create a custom webalizer config per domain
1
|
cp /etc/webalizer/webalizer.conf /etc/webalizer/<domain>.com.conf
|
Change the following per domain
1
2
3
4
5
6
7
8
|
LogFile /home/domains/<domain>/www/log/access.log
OutputDir /home/domains/<domain>/www/stat/
HistoryName webalizer.hist
Incremental yes
IncrementalName webalizer.current
HostName <domain>.com
DNSCache /var/lib/webalizer/dns_cache.db
DNSChildren 10
|
Create the common directory to store dns cache results
1
|
mkdir /var/lib/webalizer/
|
Configure the non virtual host config
1
|
vi /etc/webalizer/webalizer.conf
|
Update
1
|
LogFile /var/log/apache2/access.log
|
Alias this directory to your <main domain>/stats
/stats shoud also be password secured
1
|
vi /etc/apache2/sites-enabled/<main domain>
|
Add below <VirtualHost <your ip>:80>
1
|
alias /stats /home/domains/mymediastash.com/www/stat/
|
Restart apache
1
|
/etc/init.d/apache2 restart
|
Test run
1
|
./etc/cron.daily/webalizer
|
http://<domain>.com/stats/
Monitor your server from command line uisng top alternatives
atop - Monitor for system resources and process activity
atop shows the most active processes not only related to CPU or memory, but disk and network usage are also calculated into the resource usage statistics
http://debaday.debian.net/2009/01/18/atop-an-ascii-full-screen-performance-monitor/
apachetop - Realtime Apache monitoring tool
Apachetop is a curses-based top-like display for Apache information, including requests per second, bytes per second, most popular URLs, etc.
http://www.webta.org/projects/apachetop/
dnstop - console tool to analyze DNS traffic
dnstop is a libpcap application (ala tcpdump) that displays various tables of DNS traffic on your network.
http://dns.measurement-factory.com/tools/dnstop/
htop - interactive processes viewer
htop, an interactive process viewer for Linux
http://htop.sourceforge.net/
iftop - displays bandwidth usage information on an network
iftop does for network usage what top(1) does for CPU usage.
http://www.ex-parrot.com/pdw/iftop/
jnettop - View hosts/ports taking up the most network traffic
Jnettop is a traffic visualiser, which captures traffic going through the host it is running from and displays streams sorted by bandwidth they use.
http://jnettop.kubs.info/wiki/
mytop - top like query monitor for MySQL
mytop is a console-based (non-gui) tool for monitoring the threads and overall performance of a MySQL
http://jeremy.zawodny.com/mysql/mytop/
1
|
aptitude install atop apachetop dnstop htop iftop jnettop mytop
|
Configure apachetop
Add
1
2
3
4
|
#!/bin/bash
LOGS="-f /home/domains/*/www/log/*access.log
-f /var/log/apache2/access.log"
apachetop $LOGS
|
Configure atop
By default, atop starts a daemon which is useful to analyze processes in the past
If you do not want this, and only want to monitor 'now'
1
|
update-rc.d -f atop remove
|
As always, check your logs
Most logs are in /var/log/
Open the logs and read them.
Correct any errors you find.
Research anything you do not understand.
Get to know what a your logs look like normally to make it easier to notice changes/problems
Check what is running
Use top, htop, atop
You can also look at all the processes running via
See the current network connections
References:
http://www.howtoforge.com/admin4_monitoring_with_munin_monit_debian_etch
http://www.debianhelp.co.uk/webalizer.htm
7