tdog.blog header

Handy checkup script

September 29th, 2005 by Tom Myer

Hi there! Welcome to our blog. Don't forget to sign up for our free RSS feed. We Triple Dog Dare Ya! And thanks for visiting!

When we’re launching and/or monitoring a customer web site, it’s important to have good information about server performance at our fingertips. We’ve developed a handy, short shell script that helps us monitor server load and the number of processes that are present for mysql and httpd.

Here is the script:

#!/bin/sh
date
uptime
echo -n "mysqld: "
ps aux | grep mysqld | wc -l
echo -n "apache: "
ps aux | grep httpd | wc -l

Save this script as checkup and make sure you run chmod +x on it. From the command line, you can invoke it as ./checkup and get the following output:

Wed Sep 21 18:31:04 CDT 2005
6:31pm up 173 days, 4:44, 1 user, load average: 0.72, 0.81, 0.73
mysqld: 16
apache: 33

As you can see, the script prints out the current date, the results of uptime (which includes server load averages for the last 1, 5, and 15 minutes), and the number of mysqld and apache processes. Many times, this simple script is enough for our admins to get an overall picture of the server’s health.

Something else we do? We can redirect the output of this script to a log file and then email that log file once a day to other interested parties.

Tags: No Comments

Leave A Comment

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.