| Anunta-ma cand moare un server |
|
| Scris de Cypress | ||||||
| Saturday, 15 December 2007 | ||||||
#!/bin/bash
# Shell script to monitor running services such as web/http, ssh, mail etc.
# If service fails it will send an Email to ADMIN user
# ---------------------------------------------------
# service port
ports="22 80 25"
# service names as per above ports
service="SSH WEB MAIL"
# No of services to monitor as per (above ports+1)
SCOUNTER=4
#Email id to send alert
ADMINEMAIL="
Aceasta adresa e-mail este protejata impotriva spamului, JavaScript trebuie activat pentru a putea vizualiza pagina.
"
# counter
c=1
echo "Running services status:"
# use sudo if you want i.e. sudo /bin/netstat
/bin/netstat -tulpn | grep -vE '^Active|Proto' | while read LINE
do
sendMail=0
# get active port name and use : as delimiter
t=$(echo $LINE | awk '{ print $4}' | cut -d: -f2)
[ "$t" == "" ] && t=-1 || :
# get service name from $services and : as delimiter
sname=$(echo $service | cut -d' ' -f$c)
sstatus="$sname: No"
# now compare port
for i in $ports
do
if [ $i -eq $t ]; then
sstatus="$sname: Ok"
sendMail=1
fi
done
# display service status as OK or NO
echo "$sstatus"
#next service please
c=$( expr $c + 1 )
[ "$sendMail" == "0" ] && echo $sstatus | mail -s "service down $sstatus" $ADMINEMAIL || :
# break afer 3 services
[ $c -ge $SCOUNTER ] && break || :
done
Only registered users can write comments! Powered by !JoomlaComment 3.12 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.Stiri similare: |
||||||



Debunking the Linux virus myth
Sa speram. Si daca ajunge acolo, sa sper...
Debunking the Linux virus myth
do I smell a frontpage
Debunking the Linux virus myth
Pagina e acolo, atat doar ca e un spatiu...
Un nou articol pe MYLRo.org
dar ce fel de vizite? conteaza sa ai tra...
Debunking the Linux virus myth
page not found
Un nou articol pe MYLRo.org
Articolul il scrisesem mai demult si l-a...
Debunking the Linux virus myth
Wohooo... 5661 de read-uri de ieri si 91...