From IT Mission Linux Tips, Hacks, Tutorials, Howtos - Itmission.org

Main: Server-monitoring-using-ping-and-bash

This script monitors that server host names or IP address in hostlist and send messages to the server admins.

  #!/bin/bash
  cat hostlist |  while read line
  do
  pingcount=$(ping -c 1 $line |grep received|awk -F',' '{print $2}'|awk '{print $1}')
  if [ $pingcount -eq 0 ]; then
  /usr/bin/wall "$line is unreachable, please check and reboot"
  fi
  done
Retrieved from http://www.itmission.org/Main/Server-monitoring-using-ping-and-bash
Page last modified on September 19, 2007, at 12:31 AM