Wednesday, November 14, 2018

Script check server down (Monitor server)

----------------------------------------------Begin--------------------------------------------

#!/bin/bash
SERVERIP=192.168.0.xx
NOTIFYEMAIL=admin@domain.com

ping -c 3 $SERVERIP > /dev/null 2>&1
if [ $? -ne 0 ]
then
   # Use your favorite mailer here:
   echo "Dear Admin team please check LAN interface on this server ip: $SERVERIP" | mail -s "Alert IP: $SERVERIP interface: XXX is down" -r Server-Info@domain.com $NOTIFYEMAIL


----------------------------------------------End----------------------------------------------

#vim checkiponline.sh
------------------------Script check ip online ----------------------------------------------

echo " -------------------------------------------  "
echo " -------------------------------------------  "
for i in $( ls /sys/class/net ); do echo -n $i; ethtool $i | grep Link\ d; done
echo " -------------------------------------------  "
echo " -------------------------------------------  "
ip a
echo " -------------------------------------------  "
echo " -------------------------------------------  "

--------------------------End Script----------------------------------------------------------

No comments: