mvantassel / plexpy2influx

Pipe select PlexPy metrics to InfluxDB so it can be graphed in Grafana
MIT License
7 stars 5 forks source link

Cannot get any data from PlexPy #5

Closed benjmd closed 6 years ago

benjmd commented 6 years ago
I just get streams of the blow when attempting to run it: 2017-07-29 00:03:23 DEBUG PlexPy APIv2 :: API called with kwargs: {'cmd': u'get_users_table', 'apikey': u'****de'}

API key is correct, have deleted/regenerated.

Any tips would be appreciated :)

mvantassel commented 6 years ago

Hey @benjmd, any other logs you can send my way?

benjmd commented 6 years ago

Yep, where from/what do you need? (also love the super fast reply!)

benjmd commented 6 years ago

When plex isn't playing anything, I get this ever 30 seconds inline with the UPDATE_INTERVAL_MS=30000: No sessions to log: Fri Jul 28 2017 14:44:20 GMT+0000 (UTC)

When plex is playing something, I get nothing in the plex2influx log. I get the original logged output from plexpy logs (2017-07-29 00:03:23 | DEBUG | PlexPy APIv2 :: API called with kwargs: {'cmd': u'get_users_table', 'apikey': u'****de'} -- | -- | --)

mvantassel commented 6 years ago

ok that's a good log it means it did establish a connection to plexpy and logging there are no active play sessions.

If you look in your influxDB do you have data in library, users etc?

benjmd commented 6 years ago

Nope, nothing gets written to influxdb. I don't have user/pass set as it's all local/is a problem for later-benjmd. I currently run telegraf/home-assistant/speedtest and they're all writing to influxdb. I tried setting a user/pass as part of t/s, made no difference.

mvantassel commented 6 years ago

ok can you try running the container with --privileged ?

benjmd commented 6 years ago

I'll give it a go as soon as I wan work out how to do it on synology. Its super limited, I usually have to export the config, change things, clear the container, delete it, then import the modified config file. Edit: I'm a dickhead, found it.

mvantassel commented 6 years ago

Ah yes. I run all my containers in Unraid and have to do a similar workflow to update my packages. I'm going to guess privileged mode is the answer here. It's the only way they work in Unraid for me.

I'll update the README tonight!

benjmd commented 6 years ago

No dice, running privileged. Same deal. Nothing being written to influxdb. Still get "No sessions to log: Fri Jul 28 2017 15:01:16 GMT+0000 (UTC)" when something is playing in plex, still get "PlexPy APIv2 :: API called with kwargs: {'cmd': u'get_users_table', 'apikey': u'****de'} --" and "2017-07-29 00:33:25 | DEBUG | PlexPy APIv2 :: Cleaned kwargs: {}" in the plexpy logs.

mvantassel commented 6 years ago

ok so plexpy connection seems to be good. So let's debug Influx. Is the database created? INFLUX_HOST correctly defined?

The script doesn't create the database for you so that would be the first thing I check.

The good thing about this thread is it clearly indicates this script needs better logging & error handling!

benjmd commented 6 years ago

haha, yup.

PlexPy connection appears ok, but I don't even know if its returning usable data. I deleted and recreated the database in influxdb, no change.

I'm not keen on containers having privileged access either. Seems like it could go bad.

Assuming you mean INFLUXDB_HOST (unless that's changed recently)?

I have tried on network IPs (192.168.1.x and on the docker bridge network 172.17.0.x), I have tried linking the containers so that hostnames work (influxdb:port etc). I have things running bridged so I can monitor container network usage, something I haven't worked out how to do when sitting on the host network.

I tried 'plex' and plex as the "INFLUXDB_DB", no change.

Have you thought about making it a config file instead of a host of environment variables? Like this: https://github.com/barrycarey/Speedtest-for-InfluxDB-and-Grafana/blob/master/config.ini

mvantassel commented 6 years ago

Re: the config file I haven't thought about a config ini or yaml config simply because this started as a node script then became a container. I'd be open to a PR though!

Have a look at all the config options in the script and see if anything stands out that is mismatched with your setup e.g. https, port etc: https://github.com/mvantassel/plexpy2influx/blob/master/plexpy2influx.js#L12-L17

benjmd commented 6 years ago

Will do, thanks for your help :-) On Sat, 29 Jul 2017 at 00:59, Matthew VanTassel notifications@github.com wrote:

Re: the config file I haven't thought about a config ini or yaml config simply because this started as a node script then became a container. I'd be open to a PR though!

Have a look at all the config options in the script and see if anything stands out that is mismatched with your setup e.g. https, port etc: https://github.com/mvantassel/plexpy2influx/blob/master/plexpy2influx.js#L12-L17

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mvantassel/plexpy2influx/issues/5#issuecomment-318684472, or mute the thread https://github.com/notifications/unsubscribe-auth/ARvsBDgWOjGfirwJn5zdpWdAejAi6By3ks5sSf5LgaJpZM4Omrxl .

benjmd commented 6 years ago

New logs look the goods, showing a connection to PlexPy (which we saw yesterday): Sat Jul 29 2017 16:22:49 GMT+0930 (ACST): Initialize PlexPy2Influx Sat Jul 29 2017 16:22:49 GMT+0930 (ACST): Getting PlexPy Activity Data Sat Jul 29 2017 16:22:49 GMT+0930 (ACST): Getting PlexPy Library Data Sat Jul 29 2017 16:22:49 GMT+0930 (ACST): Getting PlexPy User Data Sat Jul 29 2017 16:22:50 GMT+0930 (ACST): Parsing PlexPy Activity Data Sat Jul 29 2017 16:22:50 GMT+0930 (ACST): Parsing PlexPy User Data Sat Jul 29 2017 16:22:51 GMT+0930 (ACST): Parsing PlexPy Library Data

Is something supposed to appear when it writes/doesn't write to influxdb?

Had a look at the linked config options, all appear OK.

I've attached a pic of the environment variables in use. I've added all the non-essential ones too to rule them out as making a difference. plexpy2influx env

Still nothing in influxdb - influxdb plex

Also I have no idea what I'm doing, so it could be that ;)

mvantassel commented 6 years ago

Glad you got the logs showing up for you but it looks like I missed adding a catch to the writeToInflux method. I just added that so you should see an error like the one I pasted below. If writes are successful you'll get a message for those already.

screenshot 2017-07-29 09 49 53

Hopefully this gives us some useful errors to get to the bottom of what's going on!

benjmd commented 6 years ago

You legend, found it.

Environment variable INFLUXDB_HOST doesn't do anything. Changed it to INFLUX_HOST, now getting things recorded: Sat Jul 29 2017 22:42:50 GMT+0930 (ACST): wrote session data to influx

mvantassel commented 6 years ago

Oh wow that's a huge blunder of my README. I just updated that and added working support for username/pass should you need that in the future.

Glad you got it sorted out! I'll close this issue but if you have any feature requests log and issue and I'll see what I can do!

benjmd commented 6 years ago

Thanks heaps, awesome work :)