Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Hide bandwidth if 0 current streams #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions 08-plex-stats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ source /etc/update-motd.d/colors.txt

PLEXSTATS="$(curl -s "$TAUTIP:$TAUTPORT/api/v2?apikey=$TAUTAPI&cmd=get_activity")"

echo -e " ${YEL}Plex Streams........:${NC} There are currently ${PUR}$(curl -s "$TAUTIP:$TAUTPORT/api/v2?apikey=$TAUTAPI&cmd=get_activity" | tac | tac | jq '.response.data.stream_count' | tr -d '"')${NC} users streaming on Plex"
echo -e " ${YEL}Plex Bandwidth......:${NC} Plex streams are using ${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.total_bandwidth') / 1024" | bc)${NC} mbps total"
echo -e " ${YEL} ${NC} (${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.wan_bandwidth') / 1024" | bc)${NC} mbps WAN, ${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.lan_bandwidth') / 1024" | bc)${NC} mbps LAN)"
echo -e " ${YEL}Plex Streams........:${NC} There are currently ${PUR}$(echo $PLEXSTATS | tac | tac | jq '.response.data.stream_count' | tr -d '"')${NC} users streaming on Plex"
if [ "$(echo $PLEXSTATS | tac | tac | jq '.response.data.stream_count' | tr -d '"')" != "0" ]; then
echo -e " ${YEL}Plex Bandwidth......:${NC} Plex streams are using ${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.total_bandwidth') / 1024" | bc)${NC} mbps total"
echo -e " ${YEL} ${NC} (${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.wan_bandwidth') / 1024" | bc)${NC} mbps WAN, ${PUR}$(echo "scale=2; $(echo $PLEXSTATS | jq '.response.data.lan_bandwidth') / 1024" | bc)${NC} mbps LAN)"
fi