A shell script, named monitor.
cd /path/to/your/script/ ./loadAverage
A shell script, named loadAverage.
uptime | sed -e 's/.* load average: \(.*\), \(.*\), \(.*\)/INSERT INTO loadAverage (load1,load5,load15) VALUES (\1,\2,\3);/' | mysql -u root system ./gnuplot loadAverage load1 load5 load15
A shell script, named gnuplot.
cd /path/to/your/script/ lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=hour&c1=$2&c2=$3&c3=$4" | gnuplot lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=day&c1=$2&c2=$3&c3=$4" | gnuplot lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=week&c1=$2&c2=$3&c3=$4" | gnuplot if date "+%M" | grep "00" then lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=month&c1=$2&c2=$3&c3=$4" | gnuplot fi if date "+%H%M" | grep "0005" then lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=year&c1=$2&c2=$3&c3=$4" | gnuplot elif date "+%H%M" | grep "0006" then lynx -dump "http://localhost/monitor/gnuplot.php?table=$1&time=year&c1=$2&c2=$3&c3=$4" | gnuplot fi
Crontab
*/5 * * * * /path/to/your/script/monitor >> /dev/null 2>&1
A basic template for data retrieval.
A simple webpage to display these graphs.
Want to graph another category? Create another MySQL table and create another shell script, both named diskFree.
df -k / | grep "% /" | sed -e 's/.* \(.*\)%.*/INSERT INTO diskFree (root) VALUES (\1);/' | mysql -u root system ./gnuplot diskFree root
Modify the monitor script to include diskFree.
cd /path/to/your/script/ ./loadAverage ./diskFree