Thursday 6 October 2016

Solaris servers Check Availability script


1)in this script we have server-client technology
2)server(central server which can login in to other servers with out passwords) can collect information from clients & push to users
3)client script will be placed on all clients & generate information(Nodename,kernel release,uptime,last reboot,status)
4)keep maintain all servers need to collect information in solaris_list file


client script

# cat client.sh
#!/bin/bash
############################################################
###########################################################
###SOLARIS SERVERS AVAILABILITY CHECK##################################
###version 1.0##########################################
####designed: CHITTI BABU MIRIYALA################
###############################################
#!/bin/bash
NODE_NAME=`uname -n`
KERNEL_REL=`uname -v`
UP_TM=`uptime|awk -F"," '{print $1}'`
LST_BOT=`who -b|awk '{print $4, $5 ,$6}'`
echo "<td>$NODE_NAME</td><td>$KERNEL_REL</td><td>$UP_TM</td><td>$LST_BOT</td><td>Available</td></tr>"



server script

# cat server_live.sh
#!/bin/bash
############################################################
###########################################################
###SOLARIS SERVERS AVAILABILITY CHECK##################################
###version 1.0##########################################
####designed: CHITTI BABU MIRIYALA################
###############################################
>/tmp/server_health_output1
echo "From:chitti.babu@gmail.com" >"/tmp/server_health_output1"
echo "To:chitti.babu@yahoo.com">>"/tmp/server_health_output1"
>>"/tmp/server_health_output1"
echo "Subject:SOLARIS SERVERS AVAILABILITY CHECK">>"/tmp/server_health_output1"
echo "Content-type: text/html">>"/tmp/server_health_output1"
echo "<html>">>"/tmp/server_health_output1"
echo "<body>">>"/tmp/server_health_output1"
echo "<table width=100%>">>"/tmp/server_health_output1"
echo "<tr BGCOLOR="#33ffec"><td colspan=6><h4><center> SOLARIS SERVERS AVAILABILITY STATUS </h4></td></tr>">>"/tmp/server_health_output1"
echo "<tr BGCOLOR="#FFFF00"><td> <h5>NODE IP ADDRESS </h5> </td><td> <h5>NODE NAME</h5> </td><td> <h5>KERNEL VERSION</h5></td><td> <h5>UP TIME</h5> </td><td> <h5>LAST REBOOTED</h5></td><td><h5>SERVER STATUS</h5> </td></tr>">>"/tmp/server_health_output1"
for i in `cat /opt/scripts/solaris_list`
do
#ping -q -c 1 $i > /tmp/null
ping -p 22 $i > /tmp/null
if [ $? -eq 0 ]
then

echo "<tr BGCOLOR="#00FF00"><td> $i</td>">>"/tmp/server_health_output1"
        ssh -q $i  '/bin/bash /opt/scripts/client.sh' >>"/tmp/server_health_output1"
else

echo "<tr BGCOLOR="#FF0000"><td colspan=6> $i SERVER NOT REACHBLE NEED ADMIN HELP</td></tr>">>"/tmp/server_health_output1"
fi
done
echo "</table>" >>"/tmp/server_health_output1"
echo "</body>">>"/tmp/server_health_output1"
echo "</html>">>"/tmp/server_health_output1"
cat "/tmp/server_health_output1"|/usr/sbin/sendmail -t
#cat "/tmp/server_health_output1"|mail "chitti.babu@gmail.com"
>"/tmp/server_health_output1"

No comments:

Post a Comment