Monitor CPU via Hudson
This is a tutorial to have cpu of a server monitored via Hudson. Is intented to be a guide line, not all the aspect are detailed.
To achieve this you need the following software installed:
- Hudson system working
- Hudson Plot Plugin, to install this, from your Hudson instance go to “Configure Hudson”>”Plugin” and search for the plot plugin from the available software.
- On the machine monitored you need a cpu sampling program, we use Ubuntu Linux so we decided to use sar software, to install this:
- aptitude install sysstat
- edit the file /etc/default/sysstat change “ENABLED” to “true”.
Now we need to give to the plot plugin a csv file of the interested measures. Every build add one Y value for every measure. In the example we have 5 measure, so we need 5 values.
With a shell script we get the sampled rate we need, for example assume the following is a script called “cpu.sh” (the script need to be adjusted to feet your needs):
1 2 |
echo %user,%nice,%system,%iowait,%steal echo $(sar -f /var/log/sysstat/sa$day $delta | tail -n 2 | head -n 1 | awk '{print $3 "," $4 "," $5 "," $6 "," $7}') |
put the output of the script to a file like:
1 |
cpu.sh >cpu.csv |
and then the configuration of the plot plugin is:
Finish! You now get a graph like the one in the beginning of the article… With sar you can also measure memory, swap, network, processes.
Note that you can also monitor remote machine, suppose to distribute your cpu.sh and have your server configured to login via ssh and public key authentication, then you can get sampling rate like this
1 |
ssh username@remotemachine 'cpu.sh' > cpu.csv |
Hope this helps
maybe next time i will show you how to be alerted via mail if the cpu exceed a given threshold
2 risposte
great, now i know what are you doing…
i also write you an email about…