A little BASH of network monitoring

Nothing revolutionary here, but this is a super quick and simple way to monitor the availability of your network nodes via ICMP.

Prerequisites:

  • Ability to send mail from the server running the script
  • ICMP connectivity to each target node
  • DNS provider that does NOT rewrite domain errors (NXDOMAIN redirect)
  1. Create a file with a list of nodes (I used ‘nodes.list’) and make it relative to your script. Use IP addresses or FQDNs if you always trust DNS….

nodes.list:

2. Create the following BASH script, tweak $SOURCE and $TO.

3. Create a cron job. Here is an example that performs the checks every 5 minutes:

4. Test out the script by adding a few bogus IP addresses to the nodes.list source file. Then remove them.
5. Sit back and relax, then begin troubleshooting when you get your first alert 🙂