├── 01-banner ├── 02-last-login ├── 03-uptime ├── 04-load-average ├── 05-memory ├── 06-logins ├── 07-processes ├── 08-plex-stats ├── 09-sabnzbd-stats ├── 09-transmission-stats ├── 10-process-check ├── 11-disk-stats ├── README.md ├── colors.txt ├── config.conf └── dependency-check.sh /01-banner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " 6 | █████████████ █████ █████████████ ${YEL}███████${NC} ███████ 7 | ███████████████ █████ █████████████ ${YEL}███████${NC} ███████ 8 | █████ ██████ █████ █████ ${YEL}███████${NC} ███████ 9 | █████ █████ █████ █████ ${YEL}██████${NC}██████ 10 | █████ ██████ █████ ████████████ ${YEL}███████${NC}███ 11 | ███████████████ █████ ████████████ ${YEL}███████${NC} 12 | █████████████ █████ █████ ${YEL}███████${NC}██ 13 | █████ █████ █████ ${YEL}███████${NC}████ 14 | █████ █████ █████ ${YEL}███████${NC}███████ 15 | █████ ██████████████ █████████████ ${YEL}███████${NC} ███████ 16 | █████ ██████████████ █████████████ ${YEL}███████${NC} ███████ 17 | " 18 | echo " " 19 | -------------------------------------------------------------------------------- /02-last-login: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}Last login..........:${NC} ${PUR}$(last | head -1 | cut -c 1-9 | xargs)${NC} at ${PUR}$(last | head -1 | cut -c 40-55 | xargs)${NC} from ${PUR}$(last | head -1 | cut -c 23-39 | xargs)${NC}" 6 | -------------------------------------------------------------------------------- /03-uptime: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}Uptime..............:${NC} ${PUR}$(uptime -p | sed 's/^up.//')${NC}" 6 | -------------------------------------------------------------------------------- /04-load-average: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}Load Averages.......:${NC} 1 min: ${PUR}$(cat /proc/loadavg | cut -f1 -d' ')${NC} 5 mins: ${PUR}$(cat /proc/loadavg | cut -f2 -d' ')${NC} 15 mins: ${PUR}$(cat /proc/loadavg | cut -f3 -d' ')${NC}" 6 | -------------------------------------------------------------------------------- /05-memory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}Memory..............:${NC} Used: ${PUR}$(free -m | grep Mem: | xargs | cut -f3 -d' ')${NC} MB | Free: ${PUR}$(free -m | grep Mem: | xargs | cut -f7 -d' ')${NC} MB | Total: ${PUR}$(free -m | grep Mem: | xargs | cut -f2 -d' ')${NC} MB" 6 | -------------------------------------------------------------------------------- /06-logins: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}SSH Logins..........:${NC} There are currently ${PUR}$(who | wc -l)${NC} users logged in" 6 | -------------------------------------------------------------------------------- /07-processes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | echo -e " ${YEL}Processes...........:${NC} There are currently ${PUR}$(ps -ef | wc -l)${NC} processes running" 6 | -------------------------------------------------------------------------------- /08-plex-stats: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/config.conf 4 | source /etc/update-motd.d/colors.txt 5 | /bin/bash /etc/update-motd.d/dependency-check.sh 6 | 7 | PLEXSTATS="$(curl -s "$TAUTIP:$TAUTPORT/api/v2?apikey=$TAUTAPI&cmd=get_activity")" 8 | 9 | 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" 10 | 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" 11 | 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)" 12 | -------------------------------------------------------------------------------- /09-sabnzbd-stats: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | source /etc/update-motd.d/config.conf 5 | /bin/bash /etc/update-motd.d/dependency-check.sh 6 | 7 | QUEUE="$(curl -s "$SABHOST:$SABPORT/sabnzbd/api?mode=qstatus&apikey=$SABAPI&output=json")" 8 | 9 | echo -e " ${YEL}SABNZBD Queue.......:${NC} There are currently ${PUR}$(echo "$QUEUE" | jq ".value.noofslots_total")${NC} slots in queue" 10 | echo -e " ${YEL}SABNZBD Speed.......:${NC} Currently downloading at ${PUR}$(echo "$QUEUE" | jq ".value.kbpersec" | tr -d '"')${NC} KB/s" 11 | echo -e " ${YEL}Remaining...........:${NC} ${PUR}$(echo "$QUEUE" | jq ".value.mb" | tr -d '"')${NC} MB" 12 | -------------------------------------------------------------------------------- /09-transmission-stats: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | source /etc/update-motd.d/config.conf 5 | /bin/bash /etc/update-motd.d/dependency-check.sh 6 | 7 | LIST="$(transmission-remote -n $TRANSUSER:$TRANSPASS -l)" 8 | STATS="$(transmission-remote -n $TRANSUSER:$TRANSPASS -st | tail -5)" 9 | 10 | echo -e " ${YEL}Torrents............:${NC} There are currently ${PUR}$(echo "$(echo "$LIST" | wc -l) - 2" | bc)${NC} torrents in Transmission" 11 | echo -e " ${YEL}Seeding Torrents....:${NC} There are currently ${PUR}$(echo "$LIST" | grep Seeding | wc -l)${NC} torrents actively seeding" 12 | echo -e " ${YEL}Downloaded..........:${NC} ${PUR}$(echo "$STATS" | grep Downloaded | cut -f2 -d':' | xargs)${NC}" 13 | echo -e " ${YEL}Uploaded............:${NC} ${PUR}$(echo "$STATS" | grep Uploaded | cut -f2 -d':' | xargs)${NC}" 14 | echo -e " ${YEL}Ratio...............:${NC} ${PUR}$(echo "$STATS" | grep Ratio | cut -f2 -d':' | xargs)${NC}" 15 | -------------------------------------------------------------------------------- /10-process-check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | 5 | service_check(){ 6 | 7 | STATE=$(service $1 status | grep "active (running)" | wc -l) 8 | if [ "$STATE" = "1" ]; then 9 | echo -e "${GRN}OK!${NC}" 10 | else 11 | echo -e "${RED}Not running...${NC}" 12 | fi 13 | } 14 | 15 | PLEXSTATE=$(service_check plexmediaserver) 16 | TRANSSTATE=$(service_check transmission-daemon) 17 | TAUTSTATE=$(service_check tautulli) 18 | OMBISTATE=$(service_check ombi) 19 | 20 | echo -e " ${YEL}Plex Status.........:${NC} $(echo $PLEXSTATE)" 21 | echo -e " ${YEL}Transmission Status.:${NC} $(echo $TRANSSTATE)" 22 | echo -e " ${YEL}Tautulli Satus......:${NC} $(echo $TAUTSTATE)" 23 | echo -e " ${YEL}Ombi Status.........:${NC} $(echo $OMBISTATE)" 24 | -------------------------------------------------------------------------------- /11-disk-stats: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source /etc/update-motd.d/colors.txt 4 | source /etc/update-motd.d/config.conf 5 | 6 | echo -e "${BLU} Used Avail. Total Percent${NC}" 7 | 8 | for i in $(echo $DISKS | sed "s/,/ /g"); do 9 | 10 | if mountpoint -q $i; then 11 | AVAIL="$(df --output=avail $i | tail -1)" 12 | USED="$(df --output=used $i | tail -1)" 13 | SIZE="$(df --output=size $i | tail -1)" 14 | PERCENT="$(df --output=pcent $i | tail -1 | sed 's/\%//')" 15 | CHAR=$(echo 20-${#i} | bc) 16 | 17 | if [ $PERCENT -gt 90 ]; then 18 | COLOR=${RED} 19 | elif [ $PERCENT -gt 75 ]; then 20 | COLOR=${YEL} 21 | else 22 | COLOR=${GRN} 23 | fi 24 | 25 | echo -e " ${YEL}$i$(printf '%*s' "$CHAR" | tr ' ' "."): ${NC}$COLOR$(echo "scale=2; $USED/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$(echo "scale=2; $AVAIL/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$(echo "scale=2; $SIZE/1073741824" | bc -l | awk '{printf "%.2f", $0}')${NC}T $COLOR$PERCENT${NC}%" 26 | 27 | fi 28 | done 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PlexMOTD 2 | 3 | ![PlexMOTD](https://cdn.discordapp.com/attachments/147268654055161856/442694454575628288/unknown.png) 4 | 5 | I created these MOTD scripts so that I could see my Plex & Transmission statistics at a glance when I login to my server. 6 | This is running on Ubuntu 16.04, and the scripts are split into manageable chunks. 7 | 8 | I get the torrent stats from Transmission, and I am using Tautulli (PlexPy) API to get the Plex stream stats. I have also removed my API keys and credentials. 9 | 10 | ## Usage 11 | 12 | Place these files in the `/etc/update-motd.d/` directory. 13 | Enter your credentials into `config.conf` 14 | 15 | ## Dependencies 16 | `sudo apt-get install bc jq` 17 | 18 | ## To-Do List: 19 | - Fix memory stats, I don't think it is accurate at the moment 20 | - Add disk space status 21 | - Maybe add local weather 22 | - Fix CPU usage as unix load =/= percentage 23 | - Add some more plex stats 24 | - Add more torrent clients such as Deluge/uTorrent/qBitTorrent 25 | - Re-arrange the stats into a cleaner format 26 | -------------------------------------------------------------------------------- /colors.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BLK='\033[0;30m' # Black 4 | RED='\033[0;31m' # Red 5 | GRN='\033[0;32m' # Green 6 | BLU='\033[0;34m' # Blue 7 | CYA='\033[0;36m' # Cyan 8 | WHI='\033[0;37m' # White 9 | YEL='\033[0;33m' # Yellow 10 | PUR='\033[0;35m' # Purple 11 | NC='\033[0m' # No Color 12 | -------------------------------------------------------------------------------- /config.conf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TRANSUSER="user" # Transmission Web Username 4 | TRANSPASS="pass" # Transmission Web Password 5 | 6 | TAUTIP="http://localhost" # Tautulli IP/Hostname 7 | TAUTPORT="8181" # Tautulli Port 8 | TAUTAPI="apikey" # Tautulli API Key 9 | 10 | SABHOST="http://localhost" # SABNZBD IP/Hostname 11 | SABPORT="8080" # SABNZBD Port 12 | SABAPI="apikey" # SABNZBD API Key 13 | 14 | DISKS=/mnt/Bay01/,/mnt/Bay02/,/mnt/Bay03/,/mnt/Bay04/,/mnt/Bay05/,/mnt/Bay06/,/mnt/Bay07/,/mnt/Bay08/ 15 | -------------------------------------------------------------------------------- /dependency-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [ -e /usr/bin/jq ]; then 4 | echo "Warning: /usr/bin/jq not found, please run 'sudo apt-get install jq'" 5 | exit 1 6 | fi 7 | 8 | if ! [ -e /usr/bin/bc ]; then 9 | echo "Warning: /usr/bin/bc not found, please run 'sudo apt-get install bc'" 10 | exit 1 11 | fi 12 | --------------------------------------------------------------------------------