Here's an easy way to keep track of whether a computer is up and running, and how it's doing: have it send you email every day.
I was recently explaining to our system administrator at work how it was that I knew, before I came in this morning, that the mail spool on our gateway had filled up sometime on Sunday. It's easy, really: I just read my email before setting out for work, and saw that my system's automatic daily email had gotten bounced with a "disk full" error.
Having a machine send you daily email can give you a lot of information:
df(how much disk space is available) and either
uptime(how long your system has been running) or
w(uptime, plus who's logged in).
So, here's the script I run every day: it lives in a file called
~/bin/daily (because no matter where I am, I'm going to have
~/bin/ directory for my personal scripts).
#!/bin/bash # $Id: daily,v 1.2 1999/06/28 02:31:33 steve Exp $ (date; w; df) | mail -s "STATUS:`hostname` `date`" \ email@example.com firstname.lastname@example.org
There are a couple of subtle points here:
STATUS:'' in the subject and put anything that matches into a folder called ``
pings''. Mail to or from
postmastergoes into a folder called ``
problems'' where it can easily be spotted.
wcommand gives the same information as
uptimeon the first line of its output; I substitute
uptimeon systems where I'm either the only user, or one of too many to list.
Here's the master crontab file, which I keep in
# NOTE: master is ~/bin/crontab 8 3 * * * $HOME/bin/daily
The note is so that when I look at my crontab with
crontab -l I know where it came from -- I change this so
rarely that I really need the reminder.
The next time I feel the need to work on this stuff, I'll make it
self-installing, checking for a command-line argument like, e.g.,
--install and running
crontab to install