CPU Monitoring Script

June 27th, 2009

Have you ever had a rogue process chew up all the CPU on your Linux server for a days and nobody notice?

This happens to me quite a lot so I decided to write a bash script that looks for these processes and send an alert email.


#!/bin/bash

#
# cpumon - monitors CPU usage and sends an alert email if limit is exceeded
#
# 2009 - martin@teamburns.com
#

host=`hostname`
file="/tmp/cpumon.txt"

rm $file > /dev/null 2>&1

function sendEmail() {
   subject="High CPU on $host"
   /usr/bin/mail -s "$subject" user@domain.com < $file
}

while read a b c
do
   pid="$a"
   cmd="$b"
   cpu_percentage="$c"

   if [[ -z "$cpu_percentage" ]]
   then
      echo "process $pid $cmd is using less than zero percent of the cpu!"
      continue
   else
      cpu_percentage_integer=$(echo "$cpu_percentage"|sed 's/^\([^\.]*\)\..*$/\1/')
   fi

   if [[ $cpu_percentage_integer -gt 10 ]]
   then
      echo "$pid $cmd is using $cpu_percentage_integer percent of our CPU" >> $file
   fi
done <<< "`ps --no-heading -eo pid,comm,pcpu`"

if [[ -f $file ]]
then
   sendEmail
fi

This script can be scheduled to run periodically by placing an entry in the crontab file. Make sure use replace username with a valid name:


*/30 *  * * *   username    /home/username/cpumon >/dev/null 2>&1

Martin Linux , ,

Is QuickPwn Dead?

June 23rd, 2009

I just noticed that the iPhone DEV TEAM are no longer affiliated with  QuickPwn:

http://www.quickpwn.com/2009/06/quickpwn-30-status.html

Is the is end of QuickPwn?

Martin iPhone

Optus Tethering - Without breaking MMS

June 19th, 2009

Here is a mobile config you can download from your IPhone that will enable Optus Internet Tethering WITHOUT affecting your MMS functionality.

optustethering.mobileconfig

Martin iPhone

Navcore 8.410.1218 Rev 1.2 for GO910

April 5th, 2009

For those of you interested in installing the latest x40 firmware on your TomTom 910 visit:

http://www.anonym.to/?http://www.ipmart-forum.com/showpost.php?p=2599747&postcount=101

dump961098959

Martin TomTom