
This is the default output of the munin load plugin.
I’ve patched it to add a permanent blue line indicating the number of cpu of the server. The resulted graph looks like this :

You can download the patched plugin here. It is tested with Linux and FreeBSD.
This entry was written by , posted on December 3, 2009 at 12:21 pm, filed under Monitoring and tagged load, munin. Leave a comment or view the discussion at the permalink.
While monitoring a http/php server, I needed to do some statistics about php-cgi memory usage.
Playing with memory_limit in PHP, we wanted to know the average memory usage per php-cgi process. This is easily calculated with our best friend awk.
First, get the number of php running processes:
# ps aux | grep php-cgi | grep -v grep | wc -l 126
Then, use awk to calculate the average memory usage for these processes:
# ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'
33987.8
The number used in the calculation is the field RSS given by ps. The ps manual page says:
rss: resident set size, the non-swapped physical memory that a task has used (in kiloBytes)
You can also calculate the total memory used by all php-cgi processes:
# ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s;}'
4302028
If you need to watch the trend of this average memory usage, a little shell loop does the trick:
# while [ 1 ]; do ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'; sleep 2; done
34401.3
34405.1
34408.4
34409.4
34414.2
34417
This entry was written by , posted on March 13, 2009 at 4:14 pm, filed under Benchmarks, Command line, Monitoring and tagged awk, memory, php, shell. Leave a comment or view the discussion at the permalink.
On some of freshly installed servers (Debian Etch), I encountered these error messages in /var/log/munin/munin-node.log:
Use of uninitialized value in eval {block} exit at /usr/sbin/munin-node line 456, <CHILD> line 8.
What a great error message
After digging into Google results, I found it was just a problem with host_name variable in the configuration. Default value is hostname.localdomain. I’ve replaced it with a valid hostname and it works!
This entry was written by , posted on March 11, 2009 at 8:51 am, filed under Monitoring and tagged debian, etch, munin. Leave a comment or view the discussion at the permalink.
I encountered a problem last week with cron. crond was running but the jobs seems to not work. After debugging the crontab, I saw that on one job, the username was missing.
Nothing was written in the logs to say that there was a problem.
To avoid future problems, I wrote an alert for monit.
In my crontab, I’ve added the following job:
*/5 * * * * root touch /tmp/check_cron
This job will update the timestamp of the file /tmp/check_cron every 5 minutes.
And in monit configuration (/etc/monit/monitrc), I’ve added the following alert:
check file check_cron with path /tmp/check_cron if timestamp > 10 minutes then alert
If the crontab is not working, monit will send you an alert email like this:
Subject: monit alert -- Exists check_cron Exists Service check_cron Date: Thu, 27 Nov 2008 21:21:53 +0100 Action: alert Host: myhost Description: 'check_cron' file exist Your faithful employee, monit
This entry was written by , posted on November 27, 2008 at 10:27 pm, filed under Monitoring and tagged cron, monit. Leave a comment or view the discussion at the permalink.