# plexSentry (20160511 Update)

**URL:** <https://forums.plex.tv/t/plexsentry-20160511-update/98816>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [April 3, 2015, 1:20am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816 "2015-04-03T01:20:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 1:20am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/1 "2015-04-03T01:20:32Z")

</div>

[20160511 Update - Incremental]

-Added a key to the config file to account for secure only connections (a work around till i figure out a bug in auto detection)

-Various little fixes I've built in over the past couple of months as I work on the big overhaul.

&nbsp; &nbsp;

[20151216 Update - Incremental]

-SQL Server Update -&nbsp;Added the ability to monitor shared channels, and added logic to make sure it doesn't kill optimizing jobs (this fixed a issue with sync jobs as well) Only need to update the executable and the common js file.

[20151216 Update - Incremental]

-SQL Server Update&nbsp;Log - file added and some small tweaks

[20150907 Update - Incremental]

-SQL Server Update (only PlexSentry.exe was changed) - Because of changes to the PMS or the new app, iOS users (maybe other clients, but haven't seen it yet) could get around limitations by changing their bitrate after start. The status api point /status/sessions would then not update with the new transcode key, preventing a kill. Add a new function that queries the&nbsp;/transcode/sessions api point for orphan transcodes by eliminating known keys from the sync and status api points, and then kills any "orphaned" key that is transcoding video. The side effect is if there is a user that has transcoding privileges that makes a switch, they'll have to restart the video with the desired bitrate to avoid orphaned transcode keys. I have two a##hole users to thank for the requirement of this new code.

**plexSentry (Formerly PlexMonitor) monitors and logs all user activity (playing, syncing) on your Plex server. What separates it from other programs is the ability to set limits on your users activity. Whether it's preventing users from transcoding on your server, stopping your idiot relations from syncing your entire library, or spotting which users are sharing their logon with the entire ####ing neighborhood.**

&nbsp;Features

-keeps log of sessions (1 per session key, not play state) and syncs.

-If user doesn't have transcode permissions, it kills the transcode session and sends a email to user and admin

-If user stream count is above user stream max sends a email to user and admin

-If user sync count is above user sync max sends a email to user and admin after deleting sync

-When above conditions are met, attempts to kill connected clients through HTTP API (only useful on local clients)

-Creates it's own token from plex.tv

-Connects to SQL Server back end or SQLite db file

-Monitors shared channels

-Updates user list from plex.tv as it runs

-Per user settings for transcode (h264 and others), stream count, sync limits for video\audio counts and minimum quality

-Pulls current data from specified server

-Notifies through dummy gmail account (easily changed)

-A friendly user front end (jquery/javascript with a c# middleman for sql requests)

-Notifications on start and stop

-Does not have to be run on target server

-Continues to operate when plex.tv is down

-Can kill transcodes and syncs directly from the web interface without conditions being met

&nbsp;

To Do

-add email option to front end

-total sum line in summary, charts

-Add limits for amount of time they can use the server in 24 hours before notice is sent (will work on if requested)

-more notification methods?

&nbsp;

Required

-Windows x64

-IIS Server (UI Only) - Someone could write a php or other middleman to handle db requests, eliminating this requirement

-SQL Server or SQLite

-VS 2012 x64 redistribution file (required for sqlite db)

[http://www.microsoft.com/en-us/download/details.aspx?id=30679&nbsp;](http://www.microsoft.com/en-us/download/details.aspx?id=30679%C2%A0)

&nbsp;

&nbsp;

Install Steps

Back end

-Fill in the variables in \*.config file

-Use the command list in 'SQL Server - Build Commands.txt' to build your database

-Run from any computer with network access

&nbsp;

Front end

-fill in the external server variable in script.Plex-common.js&nbsp;

-modify db connection strings

&nbsp;

Email Examples -:

Subject -: Multiple Streams Detected

2 simultaneous streams (Ally McBeal-One Hundred Tears(2002)\CSI: Crime Scene Investigation-Girls Gone Wilder(2014)) were detected (Your current limit is 1). Termination of this stream has been attempted. If this is an issue with your app and the problem persists, please contact #### for possible solutions. -Media Server (this email address is for outgoing automated messages only)&nbsp;

&nbsp;

Subject -: [Ally McBeal-One Hundred Tears(2002)] Transcoding was Terminated

One Hundred Tears was terminated due to transcoding, please raise your bitrate to the maximum or you will be banned. If the bitrate is at maximum, please contact #%@ for secondary codec permissions. -Media Server (this email address is for outgoing automated messages only)&nbsp;

![PlexMonitorFilteredUserpng](https://home.randomevents.net/share/plexsentry/PlexMonitorFilteredUser.png "Image: https://home.randomevents.net/share/plexsentry/PlexMonitorFilteredUser.png")

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 1:23am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/2 "2015-04-03T01:23:56Z")

</div>

For anyone that goes with the SQL Server version and also uses Calibre, I have a website for that you might be interested in.

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 6:07am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/3 "2015-04-03T06:07:28Z")

</div>

I assume the filename is wrong and should be 2015 not 2014?

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 6:23am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/4 "2015-04-03T06:23:57Z")

</div>

BTW you have user/password information in the .config files

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 6:35am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/5 "2015-04-03T06:35:14Z")

</div>

Thanks for the heads up. Oh, and yes the date was mean to be 2015

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 7:40am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/6 "2015-04-03T07:40:44Z")

</div>

Ok i have a few questions because i am not able to get this to work.

in the script-plex-sqlite.js, what do you mean by the external server address? when i am outside my home network, i access my plex servers through plex.tv

Now when i loaded the webpage, i see one of my friends has an episode on pause but there isn't much i can do... Clicking on LoginAccount does nothing, and clicking the Settings icon also does nothing. I first tried in Chrome and then in IE...

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 2:14pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/7 "2015-04-03T14:14:38Z")

</div>

"LoginAccount" is not useful to you without forms authentication.

In the js files there's a line of code -:

var server\_address = "[http://media.randomevents.net"](http://media.randomevents.net)//external address of server

The address is how I can access my plex server from the internet (behind a reverse proxy). Most people would use something like "[http://externalipaddress:32400"](http://externalipaddress:32400)or to test on the same machine&nbsp;"http://localhost:32400", I'm guessing since you were able to see your friend, you had the IIS portion set up correctly, so just click on "Media" in the top left corner to pull up the menu and options

---

<div class="post-metadata">

**Author:** ![hthighway](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hthighway/32/82003_2.png) [@hthighway](https://forums.plex.tv/u/hthighway)\
**Post date:** [April 3, 2015, 2:45pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/8 "2015-04-03T14:45:44Z")

</div>

> Try to kill some clients through of the HTTP API playback controls

If you ever get this part working I'm in. &nbsp;

I don't care if they transcode.

All I want it to do is drop clients if the user goes above 1 simultaneous stream.

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 3:41pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/9 "2015-04-03T15:41:05Z")

</div>

Working on that right now. Except I'm wondering if it should be manual, as I've seen issues with IOS devices that don't always drop a previous play state

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 4:08pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/10 "2015-04-03T16:08:32Z")

</div>

Ok i updated my JAVA and added the port number to the server address and now it seems to work...

Can i delete users from the database or should i just delete the .db file entirely because i have a bunch of your users in my database...

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 4:33pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/11 "2015-04-03T16:33:52Z")

</div>

Few more things:

- The Web Frontend's title still says PlexMonitor
- Shouldn't the Stream count for everyone by default be 1 for users and 99 for owner? When i first ran it, it kicked all my friends off before i could even configure their rights.
- It keeps trying to kill a paused Plex Web transcode and it doesn't work. Says it's killing it every 5 seconds. Dunno if it's because it thinks it is a Sync or because by default, nobody is allowed to stream by default
- i have 50 users ... it would be nice to be able to mass update instead of one by one&nbsp;

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 3, 2015, 7:00pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/12 "2015-04-03T19:00:13Z")

</div>

Looks like i am the only one using this so far&nbsp; ;)

I deleted the db file because i could not remove your users and now when i run the program, it creates a new db but cannot update it and can't retrieve my users:

```
Program has started, loading configuration
Retrieving authorization token from plex.tv
Retrieving server info from local server
Updating database with local server info
Database update failed
Updating shared users list from plex.tv to database
Plex update failed
Updating shared users list from plex.tv to database
Plex update failed
2015-04-03 14:57:58- Starting timer to check status at a interval of 5 seconds
Error when updating users
Checking for currently playing sessions
Current sessions-: 1
Error when checking user sessions

2015-04-03 14:58:04- Checking current syncs  
Error when checking sync sessions  
2015-04-03 14:58:04- Starting timer to check status at a interval of 5 seconds  
Error when updating users  
Checking for currently playing sessions  
Current sessions-: 1  
Error when checking user sessions

2015-04-03 14:58:25- Checking current syncs  
Error when checking sync sessions  
2015-04-03 14:58:25- Starting timer to check status at a interval of 5 seconds  
Error when updating users  
Checking for currently playing sessions  
Current sessions-: 1  
Error when checking user sessions

2015-04-03 14:58:30- Checking current syncs  
Error when checking sync sessions  
2015-04-03 14:58:30- Starting timer to check status at a interval of 5 seconds
```

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 3, 2015, 7:25pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/13 "2015-04-03T19:25:22Z")

</div>

jpp1972, try again with the new upload, that should solve most of your problems. Can you send me a screenshot of the paused instance? It's probably a problem with plex giving the wrong transcode id, the new version will also try stopping the client in addition to the transcode.

Mass update makes sense, I'll switch the interface over to that.

---

<div class="post-metadata">

**Author:** ![MAJ-5](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/maj-5/32/6663_2.png) [@MAJ-5](https://forums.plex.tv/u/MAJ-5)\
**Post date:** [April 4, 2015, 8:21am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/14 "2015-04-04T08:21:38Z")

</div>

I am drooling right now!!

This holds great potential, but I need a PHP UI to make it work :P

---

<div class="post-metadata">

**Author:** ![A\_User\_of\_Plex](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@A\_User\_of\_Plex](https://forums.plex.tv/u/A_User_of_Plex)\
**Post date:** [April 4, 2015, 9:27am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/15 "2015-04-04T09:27:44Z")

</div>

Having only 1 Mbps Upload this is a must have/killer app for my media server. With a PHP UI this would be perfect. For now I won't be able to use it..

---

<div class="post-metadata">

**Author:** ![karloscar](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@karloscar](https://forums.plex.tv/u/karloscar)\
**Post date:** [April 4, 2015, 5:36pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/16 "2015-04-04T17:36:27Z")

</div>

better documentation please..&nbsp;

The&nbsp;VS 2012 x64 redistribution file link doesn't work.

IIS Server (UI Only) (what is UI only?)

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 4, 2015, 7:21pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/17 "2015-04-04T19:21:16Z")

</div>

> The&nbsp;VS 2012 x64 redistribution file link doesn't work.

Copy the link to the clipboard, paste it in the address bar and remove the trailing space

> IIS Server (UI Only) (what is UI only?)

User Interface. Where you do the configuration of who has what rights and limits

---

<div class="post-metadata">

**Author:** ![karloscar](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@karloscar](https://forums.plex.tv/u/karloscar)\
**Post date:** [April 4, 2015, 9:22pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/18 "2015-04-04T21:22:28Z")

</div>

I get this: Processing has failed when i go to the webpage [https://192.168.0.141/plexmonitor](https://192.168.0.141/plexmonitor)

I've edited database.plex-sqlite.aspx with following:

sqlConnection.ConnectionString = "Data Source=C:\PlexMonitor\Plex Monitor (SQLite)\PlexMonitor-sqllite.db;Version=3;Timeout=100;journal\_mode=WAL;"; &nbsp;

You write to "-modify db connection strings"

is that the database.plex-sqlite.aspx you mean or?

I also get "Error when checking sync sessions" when running the&nbsp;

C:\PlexMonitor\Plex Monitor (SQLite)\Plex Monitor (SQLite).exe

Please let me know if you need more information.

---

<div class="post-metadata">

**Author:** ![random.server](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/random.server/32/12841_2.png) [@random.server](https://forums.plex.tv/u/random.server)\
**Post date:** [April 4, 2015, 10:06pm UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/19 "2015-04-04T22:06:00Z")

</div>

karloscar, Use the new version, everything will be plexSentry. you skipped a step, and need to modify the plexSentry (sqlite).exe.config to use the back end correctly. You changed the aspx file correctly for the front end.

---

<div class="post-metadata">

**Author:** ![jpp1972](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jpp1972/32/78108_2.png) [@jpp1972](https://forums.plex.tv/u/jpp1972)\
**Post date:** [April 6, 2015, 5:59am UTC](https://forums.plex.tv/t/plexsentry-20160511-update/98816/20 "2015-04-06T05:59:54Z")

</div>

I was hoping for a mass update version before i tried it again but i had a few users with multiple logins so i decided to try your latest version... Unfortunately, it doesn't work at all. It can't update the database or plex server.&nbsp;

If i run the previous version, it is able to update the database and plex

[Next page](https://forums.plex.tv/t/plexsentry-20160511-update/98816.md?page=2)
