How to monitor Apache HTTP Server
Apache HTTP Server comes with a handy mod_status for monitoring current status and performance of itself. However, mod_status doesn't show the performance in the past. I like the historical data because it would help me to find problem occured since last crash.
In this post, I assume below directory structure.
/usr/local/www/apache22/data/server-monitor
+- data
|- graph
|- scripts
| +- apache-monitor
| |- apache-monitor-graph
| `- run
|- day.html
|- hour.html
`- index.html
Follow below steps to create directories.
cd /usr/local/www/apache22/data
mkdir server-monitor
cd server-monitor
mkdir data
mkdir graph
mkdir scripts
And then create additional components.
Apache httpd Tools
I extensively use Apache httpd Tools as the main tool for retrieving status of httpd
and plotting graphs.
wget http://www.apachesecurity.net/download/snapshot/apache_tools-snapshot.tar.gz
tar xzvf apache_tools-snapshot.tar.gz
cp apache_tools/apache-monitor /usr/local/www/apache22/data/server-monitor/scripts
cp apache_tools/apache-monitor-graph /usr/local/www/apache22/data/server-monitor/scripts
scripts/run
#!/bin/sh
NAME=cz
URL=http://www.mydomain.com/server-status
DURATIONS="3600 86400"
APACHE_PATH=/usr/local/www/apache22/data
BASE_PATH=$APACHE_PATH/server-monitor
SCRIPT_PATH=$BASE_PATH/scripts
DATA_PATH=$BASE_PATH/data
GRAPH_PATH=$BASE_PATH/graph
rm -f "$DATA_PATH/$NAME.dat"
$SCRIPT_PATH/apache-monitor "$DATA_PATH/$NAME" "$URL"
for duration in $DURATIONS; do
$SCRIPT_PATH/apache-monitor-graph "$DATA_PATH/$NAME" "$GRAPH_PATH" "$duration"
done
Don't forget to let it executable.
chmod +x /usr/local/www/apache22/data/server-monitor/scripts/run
day.html
Day
hour.html
Hour
index.html
/etc/crontab
Add below line at the bottom of /etc/crontab
.
*/1 * * * * root /usr/local/www/apache22/data/server-monitor/scripts/run
Tags: apache, monitoring
- sugree's blog
- 4194 reads
Post new comment