Monthly Archives: October 2010

N900 PR1.3 is a screamer

Just installed the OTA (over the air) update on my N900 and the difference in speed is actually user-perceptible. Animations are smoother, rotation happens much more quickly and I could swear applications are starting faster as well. Many people are reporting improved battery life too.

There are no new major features that I’ve noticed, so of PR1.2 was a feature release, PR1.3 is very much a fine-tuning release. And despite what the few whiners on the maemo forums might say – that is not a bad thing!

More at the Nokia conversations blog and pocketables.net.

Bash script to alert when memory gets low

We have a web server that’s running out of memory about once every couple of weeks. The problem is that when it happens the swap file is totally full, the system is unresponsive and it usually needs a hard reboot. So it’s a bit difficult to debug. To avoid digging through log files I don’t understand I elected to put a script in /etc/cron.hourly which checks the total amount of free memory (including swap and physical). If there is less than 256mb free (this server has 512mb of ram and a 1gb swap so at this point the situation is serious), it dumps the process list to /tmp/processes.txt and sends me an email with it attached.

Note that mutt must be installed (‘apt-get install mutt’ on Debian/Ubuntu, or ‘yum install mutt’ on RedHat/CentOS).

#!/bin/bash

free=`free -mt | grep Total | awk '{print $4}'`

if [ $free -lt 256 ]; then
        ps -eo %mem,pid,user,args >/tmp/processes.txt
        echo 'Warning, free memory is '$free'mb' | mutt -a /tmp/processes.txt -s "Server alert" email@me.com
fi

Then of course make it executable and symlink to cron.hourly:

chmod +x /etc/scripts/memalert.sh
ln -s -t /etc/cron.hourly/memalert.sh /etc/scripts/memalert.sh