Installing PlexPy

Share your awesome tips and tricks here.
Post Reply
MikeG.6.5
Posts: 917
youtube meble na wymiar Warszawa
Joined: Fri May 15, 2015 1:56 am

Installing PlexPy

Post by MikeG.6.5 »

PlexPy is an app I discussed in my HT thread, but I didn't really get into the details of what the app is, what it does and how it can work for you in running Plex Media Server on your NAS.

PlexPy is a Python based application used to monitor a PMS installation. It gives you historical tracking of who, what, when, how and even where someone streams any media from your NAS. It's really simple to install, and maintain.

The first step, install Python from App Central. After this is installed you are going to ne4ed to download the PlexPy app itself. You can find it from here: http://forums.plex.tv/discussion/169591 ... program/p1

This thread is a long one, and most of the questions that you might have are likely to be answered in it. It might be dry , but it's also very informative.

After you download PlexPy, the next step is to unrar the files into a location on your NAS. To do this, I use WinSCP. I'm not going to offer other alternate apps, so if you don't want to install the free WinSCP for whatever reason you are on your own...

Every script I write for my NAS goes into a specific folder. I tried using the folder described in other posts here, and had issues with that folder disappearing after a reboot, so I made one called misc. (Full path is /volume1/misc.) In this folder I have a PlexPy folder that I unrarred the files to.

Ok, this gets PlexPy installed, but so far it's not running. So to get it running the next step is to open a WinSCP terminal window and put this in the command line: /volume1/misc/PlexPy/PlexPy.py It should start up right away, and not give you any errors. DON'T CLOSE The terminal window yet. The way we started PlexPy is going to require this window open, at least for a little bit.... If you close this window PlexPy stops running, and we need it running at least a little longer. I'll show you how to get it running as a daemon in a bit.

Open a browser window up and point it to the http://your.nas.ip.here:8181 and this should walk you through the PlexPy wizard for setting it up. Just follow the prompts. For now you won't have any history on what people have been viewing from your PMS install. But, from this point on you will start getting historical tracking that you can keep for a couple of years or more if you want.

NOW close the terminal window. And try getting to the PlexPy web page (http://your.nas.ip.here:8181) And it fails, right? Yepper, this is what we want it to do....

So to make sure PlexPy is running we need to make a script that your cron calls to check for PlexPy. If it's running, the script stops, and everything goes on. If it's not running, the script calls the PlexPy scripts, starts it as a daemon.

This is the script I use for checking PlexPy: (I named this file ChkPlexPy.sh)

Code: Select all

#!/bin/sh
#######################################################################################
#  This script tests to make sure the PlexPy application is running on your Asustor   #
#  NAS.  if it is the script exits and does nothing.  If not it will restart PlexPy   #
#  as a daemon so the app is always running.  This app is usefull  #
#  because you can set it to monitor your HDD space, and view recently added shows    #
#  and movies within Plex.                                                            #
#  ---------------------------------------------------------------------------------  #
#  You can change this to test for remote access by changing the localhost to the     #
#  DNS name of your NAS.  Ex: If you use Asustor's DDNS service it would be something #
#  like http://yourddnsname.myasustor.com:  If you are using Maraschino on another    #
#  port than 7000 you will need to edit the script below to reflect the port number.  #
#  ---------------------------------------------------------------------------------  #
#  This can be used to test operation of any app that has a web page for accessing    #
#  the app itself.  If the app is a stand alone app and doesn't use a web page        #
#  this check will not work.  There are other ways to check their operations.         #
#  ---------------------------------------------------------------------------------  #
#  Visit http://forum.asustor.com/index.php and ask MikeG.6.5 for any support issues  #
#######################################################################################

curl -u (username if one used):(password if one used) -I -m 8 "http://your.nas.ip.here:8181/home";
if [ "$?" -ne "0" ]

then
                /usr/sbin/syslog --log 0 --level 0 --user admin --event "PlexPy isn't running:  Starting it"                
                /volume1/misc/PlexPy/PlexPy.py -d
fi

exit 0
This puts a line in the System Logs for the NAS, and if you are running AiMaster on your phone or tablet you will get a notification every time PlexPy isn't running. (Like at boot up. I can't seem to get anything starting on boot up...)

Next you need to edit the cron file to get this test script to run every few minutes. You can find the cron file here: /volume0/usr/builtin/etc/crontabs/root Just double click that file in WinSCP and it opens up in an editor. Include this line to test Plex:

*/15 * * * * /volume1/misc/ChkPlexPy.sh

This checks if PlexPy is running every 15 minutes on the quarter hour.

Pretty simple. And after you use this for a while you will start to seem some really great info in your database.

Let me know if you have problems.
Post Reply

Return to “Tips & Tricks”