Please visit these two links for the most up to date version of this script, and information:
Report any bugs/suggestions to the issue tracker on github, or via e-mail to justyn [at] justynshull.com
This script will take a snapshot of the following information every 60 seconds(changeable) and input it into a sqlite database:
- netstat -nat
- ps aux
- mysql processlist
- apache's /server-status
- Server load
It is not a complete replacement for sar or the systat package, but compliments it nicely since you will be able to see exactly what processes were running or what connections were open at specific times making troubleshooting server issues easier. watchview.php also uses the GoogleChart api to create nice graphs to view this information.
- Root access to the server you want to monitor(possibly not required)
- php
- php-pdo (with sqlite support)
- php safe_mode must be off
Just clone the repository to a web-accessible directory:
git clone git://github.com/justyns/phpSysWatch.git
If you don't have git:
wget 'https://github.com/justyns/phpSysWatch/tarball/master' -O phpsyswatch.tar.gz
- Open watch.php and configure it:
- $dbfile needs to be in a path accessible by the webserver user
- $interval is set to 60 seconds by default, but can be changed
- $serverstatusurl may need to be changed if you do not have server-status acessible on localhost
- $mysql['pass'] should be updated to the mysql root password, or another user created for this script with the necessary permissions
- Copy/move watch.php pretty much anywhere
- chmod +x watch.php
- Run it to create the database: ./watch.php
- Open watch.sh and add the full path to watch.php. Add watch.sh to crontab:
*/5 * * * * /path/to/watch.sh &
- Open watchview.php and change $dbfile to match watch.php's $dbfile
- Copy/move watchview.php to a web-accessible directory
- (Optional) configure .htaccess to restrict access to watchview.php by IP
- Enable Apache server-status with something like this in the conf:
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
- README.md - readme with markup for github
- watch.php - php script that does all of the logging
- watch.sh - bash wrapper script to be called from cron and ensure watch.php is running
- watchview.php - php script that views/graphs the data logged by watch.php
- watch.py - original python script that does something similar but logs to separate files
- watchuploader.sh - my first attempt at uploading the data from watch.py to a remote server for graphing/viewing