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? or Will 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.
- 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- Then add line to your crontab
* * * * * load.shThis will log your load data every minute.
- We need visuale our data. The simpliest way is to use
gnuplotutil 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
0.7 +-++--+--+---+--+--+--+--+--+--+---+--+--+--+--+--+--+--+---+--+--++-+
A + + + + + + + + + + +
| 'load.log' using 1:2 +--A--+ |
0.6 +-+ A A-- +-+
|| A || + A |
|A + | | | + |
0.5 +-+ + | | | A +-+
|A A | | A | |
| + -- | | + -A | |
0.4 +-+A-- - A + A A- | | +-+
| -A A | | | | | |
| A- | | | | | | |
| | | | | | A |
0.3 +-+ | | | | | A | +-+
| A || | + | | |
| A |+ | | |
0.2 +-+ A | | +-+
| | | |
+ + + + + + + + + A + + +
0.1 +-++--+--+---+--+--+--+--+--+--+---+--+--+--+--+--+--+--+---+--+--++-+
00 02 04 06 08 10 12 14 16 18 20 22For 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.