Monitoring Plex with Plexpy on Ubuntu 16.04

Background:

Plex, for a multi-user multi-media system, lacks detailed logging and monitoring. A colleague recently pointed out to me that another system, PlexPY exists to fill that gap. This blog post will walk through the steps I took to integrate the system into my reverse proxy and setup init scripts.
Plexpy itself, has quite good documentation here (for initial setup) and here (for creating system init scripts).

Creating a new service:

This is straightforward, and can be done by following the documentation above. No changes were necessary to have it running on Ubuntu 16.04.

  1. Create the user to run the service:
    sudo adduser --system --no-create-home plexpy
  2. Change the ownership of the file structure to allow the new user to modify the files:
    sudo chown plexpy:nogroup -R /opt/plexpy
  3. Create the init script:
    sudo vi /lib/systemd/system/plexpy.service
  4. Put the following in the file:
    [Unit]
    Description=PlexPy - Stats for Plex Media Server usage
    
    [Service]
    ExecStart=/opt/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /opt/plexpy/config.ini --datadir /opt/plexpy
    GuessMainPID=no
    Type=forking
    User=plexpy
    Group=nogroup
    
    [Install]
    WantedBy=multi-user.target
  5. Reload the services, enable plexpy and start it:
    sudo systemctl daemon-reload; sudo systemctl enable plexpy.service; sudo service plexpy start

Configuring Apache reverse proxy to allow access:

  1. Shutdown Apache and PlexPY:
    sudo service plexpy stop
    sudo service apache2 stop
  2. Change the settings in PlexPY to make it work behind a reverse proxy. Edit the config file and change the lines to:
    http_root = /plexpy
    http_proxy = 1
  3. Edit your Apache reverse config file for the domain hosting plexpy:
    ProxyPass /plexpy http://Local_IP_of_plexpy:8181/plexpy/
    ProxyPassReverse /plexpy http://Local_IP_of_plexpy:8181/plexpy/
  4. Start the services again:
    sudo service plexpy start
    sudo service apache2 start
  5. Test:

2 thoughts on “Monitoring Plex with Plexpy on Ubuntu 16.04

  1. I am trying to set up PlexPy for remote access in a reverse proxy. the part I can’t find how to do is step 3. how do I create a reverse proxy file that will work properly and not break my web server. Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *