Created
May 1, 2018 19:13
-
-
Save ThisIsAreku/787149a23ddf9d59c8c1522d2f405179 to your computer and use it in GitHub Desktop.
Plex monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd "$(dirname "$0")" | |
. ./plex_config | |
wget -qO- "${PLEXPY_URL}api/v2?apikey=${PLEXPY_TOKEN}&cmd=get_activity" | ./jq-linux64 -M 'def c(d): reduce .response.data.sessions[] as $n (0; if $n.transcode_decision==d then . + 1 else . + 0 end); [{transcode_type: "transcode", "activity_stream_count": .|c("transcode")}, {transcode_type: "direct_play", "activity_stream_count": .|c("direct play")}, {transcode_type: "direct_stream", "activity_stream_count": .|c("direct stream")}]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd "$(dirname "$0")" | |
. ./plex_config | |
wget -qO- "${PLEXPY_URL}api/v2?apikey=${PLEXPY_TOKEN}&cmd=get_libraries" | ./jq-linux64 -M '[ .response.data[] | {section_id: .section_id, section_name: .section_name, library_size: {count: (.count // 0)|tonumber, child_count: (.child_count // 0)|tonumber}}]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd "$(dirname "$0")" | |
. ./transmission_config | |
# No CURL ? No problems | |
tokenHeader=$(busybox echo -ne 'GET /transmission/rpc HTTP/1.0\r\n\r\n'|busybox nc ${HOST} ${PORT}|busybox grep 'X-Transmission-Session-Id: '|busybox head -n1|busybox sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | |
busybox echo -ne "POST /transmission/rpc HTTP/1.0\r\nContent-Type: application/json\r\nContent-Length: 26\r\n$tokenHeader\r\n\r\n{\"method\":\"session-stats\"}\r\n"|nc ${HOST} ${PORT}|busybox tail -n1 | ./jq-linux64 -M '{download_speed: .arguments.downloadSpeed, upload_speed: .arguments.uploadSpeed, active_torrent_count: .arguments.activeTorrentCount, paused_torrent_count: .arguments.pausedTorrentCount, torrent_count: .arguments.torrentCount}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment