viernes, 15 de enero de 2010

Scripts

APACHE RUN
-----------

#!/bin/sh
run=`ps ax | grep /usr/sbin/apache2 | grep -v grep | cut -c1-5 | paste -s -`
if [ "$run" ];
then
echo “Apache is running ”
else
echo "No se encuentra corriendo el servicio de Apache, por favor ejecutar /etc/init.d/apache2 restart" | mail -s "Apache is Not Running" user@empresa.com
fi

CONEXION INTERNET
-----------------

for i in 1 2 3 4 ; do
conect=1
ping -c 3 -q google.com > /tmp/tmp
grep "3 packets received" /tmp/tmp > /tmp/tmp2
var=$(cat /tmp/tmp2 | awk -F, '{print $2 }')

if [ "$var" = "$test" ]; then
echo conectado
break
else
echo no conectado
conect=0
sleep 1
fi
done
if [ conect = 0 ]; then
reboot
else
echo "ok"
fi

No hay comentarios: