#!/bin/bash # Christopher Jones # test_sites.sh # 04/24/2012 # This script will test all sites in the in the SITES_FILE field SITES_FILE=/home/site_info.txt SITE_IP=$( cat $SITES_FILE | grep -v "#COOP" | awk '{ print $7 }' | cut -c4- ) SITE_NAME=$( cat $SITES_FILE | cut -d "#" -f2 | grep -v "/usr/bin/" ) i=($(echo "$SITE_IP" )) n=($(echo "$SITE_NAME" )) echo "SITE NAME " > /tmp/sites.txt echo "SITE IP " > /tmp/ips.txt echo "PING STATUS " > /tmp/ping.txt echo "TELNET STATUS " > /tmp/telnet.txt echo "RAW PORT STATUS " > /tmp/raw.txt #echo "Testing the following sites:" #echo "$SITE_NAME" | column #echo "$SITE_IP" | column echo "$SITE_NAME" >> /tmp/sites.txt echo "$SITE_IP" >> /tmp/ips.txt for i in "${i[@]}"; do ping -c 1 $i > /dev/null if [ $? -ne 0 ]; then echo "ping failed" >> /tmp/ping.txt # echo "ping failed" else echo "ping passed" >> /tmp/ping.txt # echo "ping passed" fi done | column for i in "${i[@]}"; do netcat -z $i 23 > /dev/null if [ $? -ne 0 ]; then echo "telnet failed" >> /tmp/telnet.txt # echo "telnet failed" else echo "telnet passed" >> /tmp/telnet.txt # echo "telnet passed" fi done | column for i in "${i[@]}"; do netcat -z $i 10001 > /dev/null if [ $? -ne 0 ]; then echo "raw port failed" >> /tmp/raw.txt # echo "raw port failed" else echo "raw port passed" >> /tmp/raw.txt # echo "raw port passed" fi done | column echo echo echo echo echo "The following is the test results from the sites in $SITES_FILE:" paste <(cut -d, -f1 /tmp/sites.txt) <(cut -d, -f1 /tmp/ips.txt) <(cut -d, -f1 /tmp/ping.txt) <(cut -d, -f1 /tmp/telnet.txt) <(cut -d, -f1 /tmp/raw.txt) > /tmp/sites_status cat /tmp/sites_status