Wednesday, March 12, 2014

Check multiple websites for the instance of a word

Just a quick and simple script that downloads a webpage, and checks it for a specific word (like ERROR). If the word is found, it displays it to the console, and logs it to a file (website_errors). As I've stated in the usage, you can for loop this on a list of servers. I've elected to keep the page's source, if you don't want to, just omit the "-O ${HOSTNAME}.source" from the wget command.

# Author: Daniel Eather
# Date: 20140311
# Description: This script will download the main index.cgi page and check for the keyword ERROR.
# Usage: for x in $(cat server_list); do ./ ${x}; done


echo "Checking ${HOSTNAME}..."
wget -q -O ${HOSTNAME}.source "http://${HOSTNAME}/cgi-bin/index.cgi?A=blah&B=blah"
if [ "$ERROR_STATE" ]
        echo "${HOSTNAME}: ERROR Detected with index.cgi file!" | tee -a website_errors