Hmm, are you manually specifying a date? It works fine with myPlex (thats why I originally wrote it).
The logfile format should (hopefully) be the same, but if it is slightly different that could explain why it isn’t finding any… Can you PM me the output of the following command please so I can take a look (only need a few lines of it, and you can change the IP’s for security reasons)
cat ‘/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log’ | grep ‘progress?key’
Nope, not manually specifying a date.
I just run perl plex-reporter.pl, it says using todays date
here's the output of that command:
root@MARTY-UBUNTU:~# cat '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log' | grep 'progress?key' <br />
root@MARTY-UBUNTU:~# <br />
Ok, thats not good.... Could you send me the logfile please via PM so I can see what is going on. You can remove any ip addresses using sed if needed.
Quick update for all…
Version 0.5 has been uploaded 
It fixes a number of issues (including tracking clients connecting remotely), and it also removes the dependency on the external grep/sed commands (all handled in-house now). Multiple logfiles are now supported (so it should handle plex rotating the log after a while).
It also now supports using a regular expression to specify a date range (detailed in the readme), so you can get it to report for the whole month/year rather than a single day.
Hey,
I’ve been testing this for a while, but I’ve noticed that if somebody watches something via myPlex (shared content, not using my account)
That it doesn’t show up. Is this on purpose?
It should show up... I have a few people watching off my server and I can see their connections and what they have watched just fine. Can you PM me your logfile please and I will take another look.
I’ll upload it in a few days once some stuff has been watched, the logs got wiped today when I restarted the server
DodgyGeeza
I’m running the script on a different machine than where PMS is installed (same LAN).
I have put the local IP (10.0.0.xx) in the script settings, that should work, right?
The log files path is the local path to the Plex Media Server log on the remote machine, so:
‘/Users/MyUserName/Library/Logs/Plex Media Server.old.log’
‘/Users/MyUserName/Library/Logs/Plex Media Server.log’
Is that correct? (I have verified that the log files are there on the PMS machine).
Not matter which date I choose, the script output says:
No clients connected to your plex server on ‘’
I’m using OS X 10.7 for both PMS and running the script.
Any ideas?
The IP setting in the script is so that it can retrieve the metadata for the media that has been played. At present the script needs to run on the server (rather than a remote client) as that is where the logfile is....
I will take a look at adding SSH support into it so that it can pull the logfile from a remote system, though tbh the script was designed to be run on the plex server itself (so SSH shouldn't be required).
I noticed this as well. Non LAN based connections were not being trapped by the script. I ended up changing line 145 from
$log_line !~ /$curdate.+progress\?X-Plex-Token=.+state=playing/i ) {
to
$log_line !~ /$curdate.+progress\?key.+X-Plex-Token=/i ) {
Its now running correctly with both LAN and WAN connected clients sessions being reported.
Hi, I will give this a test at my end and if all looks good I will update the code on GitHub :-)
I’ve just edited the code a bit and with the help of a friend managed to (hopefully) fix the remote client logging issue. If they are using DirectPlay the log entries differ and so weren’t being captured. I’ve also sorted the play lists so its a bit easier to read etc.
Let me know if you still have issues… I’ve tested with a couple of remote clients now and I can see what they are watching etc 
Thanks.
Remote connections were still not being reported for me until I added in my regex conditional check (see previous post) in addition to the existing conditions in v0.8. Remote connections are now being reported again.
However, media lookup is no longer working. I tried changing the 127.0.0.1 IP for $plex_server to the LAN IP (just in case it was a binding issue) but still no media lookup. Reports just list the media IDs.
**[EDIT]** Found the problem with media lookup not working. I commented out the following block at Line 150 and all is now well. The test of opening a socket was failing for some reason even though my PMS is running on the same server as the script is run from.
if ( $plex_medialookup ) {<br />
if ( $plex_server eq "127.0.0.1" || $plex_server eq "localhost" ) {<br />
# Easiest way to check is to try and open the plex port<br />
$plex_socket = new IO::Socket::INET(LocalHost => "$plex_server", <br />
LocalPort => "$plex_port",<br />
Proto => 'tcp',<br />
Listen => 1,<br />
Reuse => 1 ) && &plex_noserver;<br />
}<br />
}
**[EDIT]** Question: Some videos are being reported multiple times whereas in previous versions they were singularly reported. Is this intentional and correct? Or is this a bug?
**[EDIT]** Requests i) Could we also have timestamps for the individual videos listed under each day please. ii) Could we have an option to output the data as XML. This could then serve as a data source to support a web page or a GUI based front-end.
Hi,
The regex check you posted was added into 0.8, so you shouldn't have needed to change anything for the pattern matching... The port test might fail if your plex server is listening on a specific interface rather than all interfaces. I will put in an override option so that you can tell it to ignore the check easily.
Played media should not be displayed multiple times (per connecting client) as the entries first go into a hash where we don't duplicate entries. In theory you could see duplicates if the media file(s) have duplicate entries in the database. There is a debugging line you can uncomment (im going to formalise it in the next release) which shows you the plex entry id of the played file etc. Do you have a screenshot of the duplicates?
As for the timestamps, I can add that in if people are interested. Personally I was just concerned with what had been watched, not when, however I can work on that. The XML output has been on my todo list for a while, just haven't got around to it. Hopefully it will be in the 1.0 release :-)
Hmm. It didn't start reporting external clients until I added my REGEX again. Here's your REGEX capture conditional check statement (line 177):
if ( $log_line !~ /$curdate.+progress\?key.+state=playing/i &&<br />
$log_line !~ /$curdate.+progress\?X-Plex-Token=/i &&<br />
$log_line !~ /$curdate.+GET\ \/library\/metadata\/[0-9]+\?X-Plex-Token=.*\[[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\]/i ) {
Here's my revised version which correctly reports my externally connected clients:
if ( $log_line !~ /$curdate.+progress\?key.+state=playing/i &&<br />
$log_line !~ /$curdate.+progress\?key.+X-Plex-Token=/i &&<br />
$log_line !~ /$curdate.+progress\?X-Plex-Token=/i &&<br />
$log_line !~ /$curdate.+GET\ \/library\/metadata\/[0-9]+\?X-Plex-Token=.*\[[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\]/i ) {
Regarding the multiple entries, I believe it maybe caused by a bug with the REGEX parsing as it only occurs if I specify a range of dates. e.g. -d "Feb [0-9][0-9], 2012" or -d "Feb [0-9]+, 2012". If I specify a single date it correctly reports only single entries. I'll see if I can grab a screenshot to demonstrate.
I am definitely interested in timestamps so if this could be added it would be great. Good to hear the XML output is on the books.
Q: Is it possible to discern the client type from the connection logs and/or whether the videos were transcoded/direct played or streamed?
Keep up the excellent work and thanks for providing the tool.
I've added in your regex and will test it shortly locally. Providing all is well it will be in the 0.9 release :-)
I will double-check the multi-date output to see about the duplicate entries... If you could send me a screenshot via PM that would be great!
From looking at the logfiles, I can't see a way to tell the type of client that connected, however it should be possible to tell if its direct-play or transcoded (though it will take a bit more work to complete). The latter probably won't make it into the 1.0 release, but I will add it to the todo list.
Timestamps and XML should be in the 1.0 release :D
Just a quick note to request the latest status of this script? I have found it to be most useful however with the latest PMS 0.9.6 release, the script now fails with ERROR: Failed to retrieve required variables.
Hi, I haven't had much time as of late to work on the script (though I'm hoping to spend a few hours on it this weekend), so there hasn't been much development on it.
I haven't been able to test with the 0.9.6 release yet as it isn't available for Linux. If you could PM me a portion of your logfile, or the rest of the error message (there should be a line from the logfile with it) I will take a look and see if I can get it fixed.
No worries.
I actually hadn't realised you had already updated to v0.9. I was still running v0.8 PRS. :blink:
I just re-tested using the newer version of the script and this is what I get (note: I edited the script to report v0.9 as opposed to v0.8 which it was still set to):
Plex Reporter Script - Version 0.9<br />
- Using date: Apr 04, 2012<br />
- Reading logfile: /Users/zeph/Library/Logs/Plex Media Server.old.log<br />
Use of uninitialized value $tmp_key in scalar chomp at /Users/zeph/Bin/plex-reporter.pl line 197, <PLEX_LOG> line 306000.<br />
Use of uninitialized value $tmp_ip in scalar chomp at /Users/zeph/Bin/plex-reporter.pl line 197, <PLEX_LOG> line 306000.<br />
ERROR: Failed to retrieve required variables from line: Apr 04, 2012 00:14:14 [0xb0b2b000] DEBUG - Request: GET /:/progress?key=xxxx&identifier=com.plexapp.plugins.library&time=236435&X-Plex-Client-Capabilities=protocols%3Dhttp-live-streaming%2Chttp-mp4-streaming%2Chttp-streaming-video%2Chttp-streaming-video-720p%2Chttp-mp4-video%2Chttp-mp4-video-720p%3BvideoDecoders%3Dh264%7Bprofile%3Ahigh%26resolution%3A1080%26level%3A51%7D%3BaudioDecoders%3Dmp3%2Caac%7Bbitrate%3A160000%7D&X-Plex-Client-Platform=iOS&X-Plex-Version=2.2&X-Plex-Token=XXXXXXXXXXXXXXXXXXXXXX [EDITED FOR SECURTY] (3 live)
Oops, I missed that one…
Just uploaded a new version (0.9a) which should now work against your logfile. If you could give it a try and let me know that would be great.
Also looks as if more information is being passed in the url, which means I can capture that and get that displayed as well 