Check if cron is working with monit

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 CharlyBr, posted on November 27, 2008 at 10:27 pm, filed under Monitoring and tagged , . Leave a comment or view the discussion at the permalink.

Amazon is moving into CDN market

As read in Diamond Notes, Amazon is moving into CDN market with CloudFront.

Some Content Delivery Network providers

This entry was written by CharlyBr, posted on November 25, 2008 at 11:46 pm, filed under http and tagged . Leave a comment or view the discussion at the permalink.

Install gem without documentation

If you need to install your gems without extra documentation, use flags –no-rdoc and –no-ri

Example:

$ gem install --no-rdoc --no-ri rails

This entry was written by CharlyBr, posted on November 21, 2008 at 4:18 pm, filed under Ruby and tagged . Leave a comment or view the discussion at the permalink.

Fix nginx increase server_names_hash_bucket_size error

When adding new virtual hosts in your nginx configuration file, you can experience this error message:

# nginx -t
2008/11/13 09:37:03 [emerg] 12299#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
2008/11/13 09:37:03 [emerg] 12299#0: the configuration file /etc/nginx/nginx.conf test failed

server_names_hash_bucket_size controls the maximum length of a virtual host entry (ie the length of the domain name).

In other words, if your domain names are long, increase this parameter.

You need to add this flag in the http context:

http {
    server_names_hash_bucket_size 64;
    ...
}

After increasing the value, test your configuration file and reload nginx:

# nginx -t
2008/11/13 09:48:06 [info] 12315#0: the configuration file /etc/nginx/nginx.conf syntax is ok
2008/11/13 09:48:06 [info] 12315#0: the configuration file /etc/nginx/nginx.conf was tested successfully
# kill -HUP `cat /var/run/nginx.pid`

This entry was written by CharlyBr, posted on November 14, 2008 at 11:28 am, filed under http and tagged . Leave a comment or view the discussion at the permalink.

Install Sun Java Runtime Environment (JRE) on Debian Etch

Sun JRE is available in the non-free repository. You need to update your repositories configuration file (/etc/apt/sources.list).

Add the following line:

deb http://ftp.us.debian.org/debian/ etch main contrib non-free

Update apt with apt-get update command and you’re ready to install the JRE.

$ apt-get install sun-java5-jre

Check your java binary:

$ java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)

This entry was written by CharlyBr, posted on November 13, 2008 at 1:07 pm, filed under Java and tagged , , , . Leave a comment or view the discussion at the permalink.