-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnslog.sh
50 lines (43 loc) · 1.73 KB
/
dnslog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# log file to get dnsmasq log info from
logfile="/var/log/dnsmasq.log"
#logfile="/var/log/messages"
# check for required command line option
case "${1}" in
query | "-q")
sudo tail -F ${logfile} | sed 's/.*]: //' | grep "query\["
;;
reply | "-r")
sudo tail -F ${logfile} | sed 's/.*]: //' | grep "reply "
;;
cached | "-c")
sudo tail -F ${logfile} | sed 's/.*]: //' | grep "cached "
;;
*)
# show usage
echo "dnslog.sh requires one of the following options to run:"
echo "** Your/root password is required to access dnsmask.log file only. **"
echo
echo "dnslog.sh -q - shows \"query\" lines"
echo "dnslog.sh -r - shows \"reply\" lines"
echo "dnslog.sh -c - shows \"cached\" lines"
echo
echo "Running each command line option in a terminal multiplexor like tmux"
echo "makes DNS server monitoring more useful."
echo
echo "tmux screen split example:"
echo "+-----------------------------------------------------+"
echo "| user@host ~: dnslog.sh -q |"
echo "| |"
echo "| |"
echo "+-----------------------------------------------------+"
echo "| user@host ~: dnslog.sh -r |"
echo "| |"
echo "| |"
echo "+-----------------------------------------------------+"
echo "| user@host ~: dnslog.sh -c |"
echo "| |"
echo "| |"
echo "+-----------------------------------------------------+"
echo
esac