SPmorning_check.sh
/opt/scripts (#1011) pwd
/opt/scripts
/opt/scripts (#1012) cat SPmorning_check.sh
        #!/bin/bash
#
#Morning checkout script - Check all processes are running
#
CONFIG="/opt/scripts/config/SPproc.conf"
DISK_CHECK="/opt/scripts/sub/disk_check.sh"
#############################################################################################
###############################  FUNCTIONS ##################################################
#############################################################################################
#for i in `cat proc.conf | awk -F\| '{print $2}'`; do echo -n "$i "; ping -c2 "$i" &>/dev/null && echo success || echo fail; done
foo ()
{
yes '' | head -n2               #Echo several blank line
echo "Ping Test Results"
 for i in `cat $CONFIG | egrep -v "^#|^;"`;
do
        network=`echo $i|awk -F\| '{print $3}'`
        if [ "$network" = "$1" ]
        then
                ip=`echo $i|awk -F\| '{print $2}'`
                ping -c1 "$ip" &>/dev/null && echo -n "[ OK ]  " || echo -n "[ CRITICAL ]  "
                echo $i | awk -F\| '{print "\t \t" $2 "\t" $1}'
        fi
done
yes '' | head -n3               #Echo several blank line
}
#############################################################################################
###############################  FUNCTIONS ##################################################
#############################################################################################
echo "      ###################################################"
echo "         WIRELESS NETWORK in GTP Availability"
echo "      ###################################################"
foo 'AP'
echo "      ###################################################"
echo "            Internet Service Provider Availability"
echo "      ###################################################"
foo 'ISP'
echo "      ###################################################"
echo "            Check Browsing"
echo "      ###################################################"
foo 'WEB'
echo "      ###################################################"
echo "              GTP Managed Servers Availability"
echo "      ###################################################"
foo 'MS'
echo "      ###################################################"
echo "               Cloud Servers Availability"
echo "      ###################################################"
echo "                   DIGITAL OCEAN"
foo 'DIGITALOCEAN'
echo "                   RACKSPACE"
foo 'RACKSPACE'
echo "      ###################################################"
echo "                       Disk Space Check"
echo "      ###################################################"
$DISK_CHECK ops.stratpoint.com
$DISK_CHECK gw1
/opt/scripts/sub (#1025) pwd; cat disk_check.sh
/opt/scripts/sub
#!/bin/bash
HOSTS=$1
LOCAL_HOST=`hostname -s`
disk_thresh="80"
# Function which displays threshold check results
#
function threshold
{
   percentage="$1"
   stringlen="$2"
   outputval=""
   while [ $stringlen -lt 20 ]
   do
      outputval=$outputval" "
      let stringlen++
      if [ $stringlen -gt 19 ]
      then
         if [ $percentage -gt $disk_thresh ]
         then
            outputval=$outputval"CRITICAL"
         else
            outputval=$outputval"OK"
         fi
      fi
   done
   echo "$outputval"
}
for host in $HOSTS;
do
   hostname=$host
   if [ "$hostname" == "$LOCAL_HOST" ]
   then
      sshreq=`hostname | cut -f1,2,3 -d.; df -h`
   else
      sshreq=`ssh -24aqx -o 'BatchMode yes' $hostname "hostname | cut -f1,2,3 -d.; df -h " 2>/dev/null`
   fi
   hostline=`echo "$sshreq" | head -1`
   headers=`echo "$sshreq" | head -2 | tail -1 | awk '{ print $5"\t"$4"\t"$2"\t"$6}'`
   diskstatus=`echo "$sshreq" | tail -n+3 | awk '{ print $5"\t"$4"\t"$2"\t"$6}'`
   echo -e "Hostname: $hostline"
   echo -e "-------------------------------------------------\n"
   echo -e "$headers\n"
   echo "$diskstatus" | while read x; do
                           percentageval=`echo "$x" | awk -F '%' '{print $1}'`
                           echo -n "$x"
                           padlength=`echo $x | awk '{print $4}'`
                           threshold "$percentageval" "${#padlength}"
                        done
   echo -en "\n\n"
done
/opt/scripts/config (#1029) pwd; cat SPproc.conf
/opt/scripts/config
SPwf1|192.168.1.10|AP