tomclegg.net


Diary
Examples
    256-router
    adzap
    apache-double-reverse
    cacti-adodb-php4
    debian-quota
    diskonmodule
    dollarsperbyte
    dynip
    ezmlm-linux
    fbsdhabits
    freebsdclone
    macbook-quantal-sound
    maildirpop3d-awfulhak
    mandy
    md
    mrtg
    net-snmp
    nodefaultroute
    oracle9i
    oracle9i-bsd5
    oracle9i-client
    oracle9i-nat
    php-cgi
    php-commandline
    php-image
    php-kics
    php-mini_httpd
    pinouts
    pizzaperdollar
    plesk-symlink-php
    pxe
    qmail-linux
    qmail-qfilter
    racoon-sonicwall
    redundant-vpn
    rewriterule
    seahorse-workaround
    setting-locale-failed
  >smalldog<
    snmpv3-cacti
    spamassassin
    squid-tproxy
    supfile
    suse73
    svc-nmbd
    svc-smbd
    svc-smtpd
    switch-virtualbox-virsh
    toyotastereo
    vm
    vn-file
    wmp-invalid
    xcode-remote-install
    xen-eth0-renamed
    xen-monowall
    xen3-ubuntu-dapper
    zz-update-grub-fail
Hire Tom
Mostly Mozart
Patches
School
Scrapbook
Software
Telephones




colocation
comments
davidireland
edsgranola
faq
funsites
goodlooking
goodmovies
google-earth-saucy-amd64
houserules
liberating
resume
resume2
scratch
shopping
snacks
todo
university
warisbogus

A simple watchdog script
Posted August 1, 2003

Send email messages (eg. to a cell phone) when a machine on the LAN is unreachable.

In /var/service/watchdog/run ...

#!/bin/sh

while sleep 60
do
  for ip in 10.0.0.1 10.0.0.3 172.16.88.132
  do
    if ping -c 1 -t 2 $ip >/dev/null
    then
      echo "$ip ok"
    else
      echo "$ip dropped one"
      sleep 10
      if ! ping -c 1 -t 2 $ip >/dev/null
      then
        echo "$ip dropped two, sending email"
        echo could not ping $ip at "`date`" | \
         MAILUSER="example-$ip" MAILHOST=example.com \
         /var/qmail/bin/datemail cellphone@example.com
      fi
    fi
  done
done 2>&1