veezer Posted February 28, 2020 Share Posted February 28, 2020 Hi all, Just thought I'd share a few scripts I wrote and packaged up as a docker for auto sleeping/waking up a Plex server. This docker, called WakerUp works in the following scenario: You have a stand-alone Plex server running on Linux (preferably Ubuntu). You have a firewall/router capable of logging firewall accesses to a file or syslog server. Your Plex server can be remotely woken up via a Wake-On-Lan magic packet. You can ssh into your Plex server. If so, then WakerUp will run on your Unraid system as a docker container, and it will remotely monitor your Plex server for activity via the Plex API. If it detects inactivity, it will sleep the Plex server via ssh after a suitable interval. Once the server is asleep, WakerUp will continue monitoring the log, looking for accesses in the firewall log for things like port 32400 (the Plex network port), although the exact search string is configurable, and will send the sleeping Plex a WOL packet to wake it up, and then repeat the whole sleep/wakeup process indefinitely. Since my Plex server also serves files over NFS, I needed a way to trigger scans on my library for new items every now and then (since the auto-detect of file system changes doesn't work over NFS), so WakerUp will also trigger library scans at regular, user-configurable intervals when the server is awake. Everything is open-source: You can find the documentation and source here: https://github.com/virantha/wakerup To install, you just add https://github.com/virantha/docker-containers into your Docker templates repository list: And then add a new Docker container called 'wakerup': The settings are explained in the README in the source repository, but should be fairly straightforward. You shouldn't have to do any configuration on your Plex server, as WakerUp will take care of setting up ssh keys, and installing pm-utils on the server. Once installed, check your docker log to make sure it looks something like the following: Let me know if anyone finds this useful or if you have any questions! 1 1 Quote Link to comment
lepathi Posted July 11, 2020 Share Posted July 11, 2020 This sounds great. Might give it a try when tuning my rig for energy efficiency. Quote Link to comment
Hairy Posted February 11, 2022 Share Posted February 11, 2022 Hello Tried to use your setup to automagical start and stop the powerhungry server, but I have some problems setting it up My environment: - Powerhungry PlexServer on Unraid with running Plex in a docker container - Power effeciency miniServer on Unraid with your docker container - Router: Synology RT Router with syslog forwarded to the miniServer (will be saved under /mnt/user/syslogs/syslog-IPADDRESS.log ) I have some confusion with the default xml, as there is the log path mentioned twice and even then only the folder and not the direct .log filepath? As you can see in the PLEX_LOG_FILENAME is asking for the router logs (in my case for /mnt/user/syslogs/syslog-IPADDRESS.log?), but is this the in-container path the script is checking for a log, or what does the variable do ? In addition, what is then the "Host path 2", as this one is not really described in the github. Is this then the in-container logs path which is checking for the router logs? If yes, why is the default then the system share? I tried a lot of possible combinations out, but nothing seems to work. The closest I got without auto stopping the container was to the following error message: PLAY [all] ********************************************************************* TASK [Gathering Facts] ********************************************************* fatal: [PLEX_HOST_IP]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "Shared connection to PLEX_HOST_IP closed.\r\n", "module_stdout": "ERROR:root:code for hash md5 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type md5\r\nERROR:root:code for hash sha1 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type sha1\r\nERROR:root:code for hash sha224 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type sha224\r\nERROR:root:code for hash sha256 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type sha256\r\nERROR:root:code for hash sha384 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type sha384\r\nERROR:root:code for hash sha512 was not found.\r\nTraceback (most recent call last):\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 147, in <module>\r\n globals()[__func_name] = __get_hash(__func_name)\r\n File \"/usr/lib64/python2.7/hashlib.py\", line 97, in __get_builtin_constructor\r\n raise ValueError('unsupported hash type ' + name)\r\nValueError: unsupported hash type sha512\r\nTraceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1644598320.2319295-72292159337465/AnsiballZ_setup.py\", line 102, in <module>\r\n _ansiballz_main()\r\n File \"/root/.ansible/tmp/ansible-tmp-1644598320.2319295-72292159337465/AnsiballZ_setup.py\", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/root/.ansible/tmp/ansible-tmp-1644598320.2319295-72292159337465/AnsiballZ_setup.py\", line 37, in invoke_module\r\n from ansible.module_utils import basic\r\n File \"/tmp/ansible_setup_payload_hpw4Eo/ansible_setup_payload.zip/ansible/module_utils/basic.py\", line 124, in <module>\r\n File \"/usr/lib64/python2.7/sha.py\", line 10, in <module>\r\n from hashlib import sha1 as sha\r\nImportError: cannot import name sha1\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "warnings": ["Platform linux on host PLEX_HOST_IP is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information."]}}, "msg": "The following modules failed to execute: setup\n"} PLAY RECAP ********************************************************************* Python 2.7 and 3.9 is installed with the nerdpack on the plexServer and I tried it with and without root user (and clearing the appdata folder everytime). Seems to be some kind of issue with the server? The X-Plex-Token is extracted directly from the local plexServer as described in your link., but I also tried the https://app.plex.tv/desktop/#!/ variant (as that was a different token) Anything else I am missing or mixing up? Will upload the santized logs on debug level also : wakerup_logs.log Thank you and wish you a great further day Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.