Helper Script
#!/bin/bash
echo "----------------------------"
echo "Sourcing Functions:"
echo "----------------------------"
echo " - nodes_up: Checks what hosts are up or down using nmap"
echo " - slbs_status: Check if NGINX Process and Status in AZ1 & AZ2"
echo " - slbs: Check if NGINX nodes are up / down using nmap in AZ1 & AZ2"
echo " - service_db_netwk: Checks connectivity between the Service in AZ1 and MySQL in AZ2 and vice-versa"
echo " - tail_service_log: Tail 100 lines of the service.log in Service AZ1"
#"Make sure to source this file before using any of the functions here. Otherwise, add this helper file into the bashrc: e.g.: source /home/mypath/helper. Call function by name only Example: nodes_up"
function nodes_up()
{
for host in $(cat service);
do
echo "-----------------------------------------"
nmap -sn -v $host | grep -E -- 'Nmap scan|Host is';
for host in $(cat service);
do
echo "-----------------------------------------"
nmap -sn -v $host | grep -E -- 'Nmap scan|Host is';
done
done
echo ""
}
function slbs ()
{
for host in $(cat slbs);
do
echo "-----------------------------------------"
nmap -sn -v $host | grep -E -- 'Nmap scan|Host is';
done
echo -e "\e[30;43m*********** Date ***********\e[0m"
date
echo ""
}
function slbs_status ()
{
for host in $(cat slbs);
do
echo "-------------NGINX PROCESS----------------------------"
pssh -i -H $host "ps -ef | grep nginx"
echo "-------------NGINX STATUS----------------------------"
pssh -i -H $host "cd mypath/init.d/; ./nginx status"
done
echo -e "\e[30;43m*********** Date ***********\e[0m"
date
echo ""
}
function service_db_network()
{
pssh -i -h service_az1 "telnet 192.10.10.100 3306"
pssh -i -h service_az2 "telnet 192.10.10.101 3306"
}
function tail_service_log()
{
pssh -i -h service_az1 "tail -100 /mypath/service.log"
}
In : Linux