#!/bin/bash
nslookup google.com localhost > /dev/null
if [ $? -eq 1 ]
then
/etc/init.d/pdns stop
echo $(date) >> /tmp/monitor.log
fi
ket :
- lookup google ke localhost
- $? artinya jika benar hasilnya 0 , jika gagal hasilnya 1
- -eq 1 artinya jika hasilnya 1 ( gagal )
- maka service DNS akan di restart
- echo $(date) artinya tanggal tiap restart service akan di kirim ke file /tmp/monitor.log
(Visited 96 times, 1 visits today)