Install PlexPy on Ubuntu for Plex Monitoring

plexpy-logoInstall PlexPy on Ubuntu for Plex Monitoring to add some extra sleekness and professionalism to your home media server. PlexPy is a python-based version of PlexWatch on github and uses code from Headphones for the web interface and daemon. You can use PlexPy to send notifications to Kodi and push services like Pushbullet and Pushover as well as email. This PlexPy installation tutorial was tested on Ubuntu 16.04 and should work on all previous versions of Ubuntu and even Debian-based systems.

PlexPy can show you tons of information about your Plex Media Server, here is a sample overview screen.

plexpy-overview-screenshot

Here is a screenshot of the statistics page showing an overview of media play counts.

plexpy-statistics-screenshot

Install PlexPy on Ubuntu

Update repos then install git and python on Ubuntu

sudo apt-get update
sudo apt-get install python git -y

Clone the latest PlexPy from the github repository

sudo git clone https://github.com/drzoidberg33/plexpy.git /opt/plexpy

Create a secure PlexPy user that has no shell and isn't allowed to log in which will be used to run the PlexPy daemon

sudo adduser --system --group --disabled-login plexpy --home /opt/plexpy --shell /bin/nologin --quiet

Change ownership of PlexPy to our secure plexpy user

sudo chown -R plexpy:plexpy /opt/plexpy

Create the default PlexPy file which the init.d script reads from to set certain options like the user it runs as, port it runs on and so on.

sudo nano /etc/default/plexpy

Paste the PlexPy default configuration file below.

If you are running Headphones then port 8181 is likely occupied so change HP_PORT to something other than 8181

HP_USER=plexpy      #$RUN_AS, username to run plexpy under, the default is plexpy
# HP_HOME=          #$APP_PATH, the location of PlexPy.py, the default is /opt/plexpy
# HP_DATA=          #$DATA_DIR, the location of plexpy.db, cache, logs, the default is /opt/plexpy
# HP_PIDFILE=       #$PID_FILE, the location of plexpy.pid, the default is /var/run/plexpy/plexpy.pid
# PYTHON_BIN=       #$DAEMON, the location of the python binary, the default is /usr/bin/python
# HP_OPTS=          #$EXTRA_DAEMON_OPTS, extra cli option for plexpy, i.e. " --config=/home/plexpy/config.ini"
# SSD_OPTS=         #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
HP_PORT=8181        #$PORT_OPTS, default is 8181 for the webserver, overrides value in config.ini

Ctrl+X, Y and Enter to Save

Copy the Ubuntu PlexPy init.d script over

sudo cp /opt/plexpy/init-scripts/init.ubuntu /etc/init.d/plexpy

Make the Ubuntu PlexPy init.d script executable

sudo chmod +x /etc/init.d/plexpy

Now enable the PlexPy init.d script on Ubuntu

sudo update-rc.d plexpy defaults

Finally start the PlexPy service on Ubuntu

sudo service plexpy start

PlexPy will be running on boot, if you find that it isn't you can change the priority for its init.d script

sudo update-rc.d plexpy defaults 98

PlexPy will be running on its default port 8181 unless you changed the HP_PORT value in /etc/default/plexpy