偵測DNS是否還活著.. 用Ruby
有鑒於某台主機的DNS常常掛掉.. 所以就寫了這個小程式..
while true
`ps aux | grep named`.split("\n").each{|line|
user, pid, cpu, mem, vsz, rss, tty, stat, start, time, *command = line.split("\s")
flag = true if command[0] == "/usr/sbin/named"
`/etc/init.d/named start` unless flag
}
sleep 300
end