-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdns_monitor.sh
48 lines (43 loc) · 974 Bytes
/
dns_monitor.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
#!/bin/bash
version="0.0.13"
# open several panes in byobu to monitor DNS and DHCP
function warn() {
boxchar='-' # ÷
boxchar2='|'
msg=${@}
mlength=${#msg}
mlength=$((mlength + 4))
marker=$(printf "${boxchar}%.0s" {1..$mlength})
printf " %s\n ${boxchar2} %s ${boxchar2}\n %s\n" "${marker}" "${msg}" "${marker}"
}
function checks(){
# check if we're running as a user
if [[ $(id -u) -eq 0 ]]
then
printf "Run as a normal user"
fi
if [[ -z ${TMUX} ]]
then
printf "Tmux not running yet"
byobu
fi
SESSION=${TMUX%%,*}
}
function check_current_pane() {
if [[ ! -z ${SESSION} ]]
then
active_line=$(byobu -S ${SESSION} list-panes | grep active)
current_pane=${active_line#:*}
else
warn No Active Session
fi
}
function open_pane() {
name=$1
shift
size=$1
shift
cmd=${@}
byobu -S ${TMUX} split-window -d -l ${size}
}
checks