Simple load monitoring

First time I met task to monitor the server load. It is time when I started to think about how long I wont need new server? orWill I know when my users will start suffering from site load latency?.

I wanted to know precisely answers to my questions. Therefore started with few simple steps: log server avg load data every minute and visualize this data.

  1. We need a a script to log the load data. It’s now very simple.
#!/bin/bash
r=$(cat /proc/loadavg | awk -F' ' '{print $1}')
dt=$(date '+%s')
echo $dt $r >> load.log

2. Then add line to your crontab

* * * * * load.sh

This will log your load data every minute.

3. We need visuale our data. The simpliest way is to use gnuplot util with just few commands:

gnuplot -e "set terminal dumb; set xdata time;set timefmt '%s';set
format x '%M';plot 'load.log' using 1:2 with lp;"

This command will give you console visualisation. Like next.

For me it’s enough on start. I do not need any picture generated. I just need to know the dynamic of changing my server load.