Issue #12 October 2005

Contest

Last month's contest: Favorite performance tool

Last month's contest asked you to tell us about your favorite Linux performance tuning or monitoring tool.

Honorable mentions:

We have to give props to all the fans of top out there. It's one of our favorite tools too—sometimes after a particularly large lunch we just sit and watch it run all afternoon.

The winner:

But we had to hand ultimate honors to Matthew Nuzum, who shared with us his favorite script for monitoring servers:

"As you know, when managing servers, sometimes freaky unexpected things can happen. The worst thing in the world is to have a user or your boss call you and say, 'is the server having problems?' while you stand clueless. I created a quick little script that runs every five minutes via cron and monitors the cpu load and the number of database connections. If they exceed a certain threshold, the server logs important data and sends a message to my pager."

Here's Matthew's script:

#!/bin/sh
# who should be notified upon event:
# separate multiple email addresses with a space
CONTACTS="my_pager@email.address multiple@adresses.allowed"
                                                                                                                                                 
# Create some messages
HOSTNAME=`hostname`
WARNING_DB="Database connections on $HOSTNAME is rather high"
WARNING_CPU="CPU load on $HOSTNAME is rather high"
WARN=0
                                                                                                                                                 
#calculate the db load
DB_LOAD=`ps -ax | grep postgres | wc -l`
if (($DB_LOAD > 150))
then
  WARN=1
  echo "$WARNING_DB ($DB_LOAD) " | mail -s "db_load is high ($DB_LOAD)" $CONTACTS
fi
                                                                                                                                                 
#calculate the processor load
CPU_LOAD=`cat /proc/loadavg | cut --delimiter=" " -f 2 | cut --delimiter="." -f 1`
if (($CPU_LOAD > 8))
then
  WARN=1
  echo "$WARNING_CPU ($CPU_LOAD) " | mail -s "CPU_load is high ($CPU_LOAD)" $CONTACTS
fi
                                                                                                                                                 
if (($WARN > 0))
then
  echo -=-=-=-=-=-=-=-=- W A R N I N G -=-=-=-=-=-=-=-=- >> /tmp/warn.txt
  NOW=`date`
  echo -=-=-=-=-=-$NOW-=-=-=-=-=- >> /tmp/warn.txt
  echo CPU LOAD: $CPU_LOAD DB LOAD: $DB_LOAD >> /tmp/warn.txt
  echo >> /tmp/warn.txt
  top -bn 1 >> /tmp/warn.txt
  echo >> /tmp/warn.txt
fi

For his efforts, we are sending him a Cool Stuff Store gift certificate.

October contest: Write our Summit 2006 theme song

This month, we want to see what sort of song-writing talent we have out there in Red Hat Magazine reader-land. Below is a link to a musical score written by our good friend Brent Fox, a Red Hat Technical Account Manager with an obviously golden ear. It's two minutes of delicate country stylings, and just needs a few verses and a good chorus to become the hit song of next year's Summit. We've provided the tune in three formats:

ogg | wav | mp3

Give it a listen or two, then put your creative mind to work. Bonus points, of course, for sending us a link to an audio or video performance of your Grammy-worthy effort.

The work must be original and cannot borrow in part or wholesale from previously existing works. We will not accept any entries that are inappropriate or derogatory, and may alter the work for time or effect.

The winning lyrics will receive a Cool Stuff Store gift certificate.

The information provided in this article is for your information only. The origin of this information may be internal or external to Red Hat. While Red Hat attempts to verify the validity of this information before it is posted, Red Hat makes no express or implied claims to its validity.

This article is protected by the Open Publication License, V1.0 or later. Copyright © 2004 by Red Hat, Inc.