Skip to content

Instantly share code, notes, and snippets.

@jrh-spg
Last active June 4, 2021 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrh-spg/35dadc55e52f63ed2329117ac63c454f to your computer and use it in GitHub Desktop.
Save jrh-spg/35dadc55e52f63ed2329117ac63c454f to your computer and use it in GitHub Desktop.
Icecast connection watcher
#!/bin/bash
TERM=xterm-256color
bold=$(printf '\033[1m')
lred=$(printf '\033[91m')
lblue=$(printf '\033[94m')
white=$(printf '\033[97m')
green=$(printf '\033[92m')
lgreen=$(printf '\033[36m')
yellow=$(printf '\033[33m')
default=$(printf '\033[0m')
sourceHost=home.grey-box.net
MyExit() {
echo -e "\n\e[31mStopped by user\e[0m"
tput cnorm
exit
}
trap MyExit INT
source=$(dig +short ${sourceHost})
delay=5
tput civis
clear
str="${2:-}"
printf "\033[1;35m"
while true; do
cmd=$(netstat -pant|grep 8000|grep -v '10.0.2'|grep -v '0.0.0.0'|grep -v 127.0.0.1|grep -v ${source}|awk '{print $5}'|cut -d: -f1|uniq)
clear
printf "${lblue}${bold} Icecast Clients${default}\n ───────────────\n"
for ip in ${cmd}; do
ptr=$(dig -x ${ip} +short)
printf " ${white}${ip} - ${ptr}${default}%s\n" "${str}"
done
sleep ${delay}
done
clear
tput cnorm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment