nwithan8 / tauticord

A Discord bot that displays live data from Tautulli
GNU General Public License v3.0
111 stars 22 forks source link

[BUG] - Tauticord crashing after enabling plexapi option #232

Closed milindpatel63 closed 1 week ago

milindpatel63 commented 1 week ago

This bug has not been reported already

You have tried to fix the bug yourself

Current Behavior

I didn't notice for a long time, but new update changed the way cpu and memory stats were showing. So i tried enabling the new way by enabling sql queries in my tautulli instance. But after doing that, my tauticord crashes now. Here's the logs

ERROR:Task exception was never retrieved
future: <Task finished name='Task-28' coro=<VoiceCategoryStatsMonitor.run_service() done, defined at /app/modules/tasks/voice_category_stats.py:26> exception=SystemExit(1)>
Traceback (most recent call last):
  File "/app/modules/tasks/voice_category_stats.py", line 33, in run_service
    await self.service_entrypoint()
  File "/app/modules/tasks/performance_stats.py", line 95, in update_performance_stats
    cpu_percent = self.calculate_cpu_percent()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/modules/tasks/performance_stats.py", line 39, in calculate_cpu_percent
    resources: List[plexapi.server.StatisticsResources] = self.tautulli.plex_api.resources()
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/plexapi/server.py", line 1029, in resources
    return self.fetchItems(key, StatisticsResources)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/plexapi/base.py", line 281, in fetchItems
    data = self._server.query(ekey, headers=headers, params=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/plexapi/server.py", line 768, in query
    raise NotFound(message)
plexapi.exceptions.NotFound: (404) not_found; http://172.26.31.72:32400/statistics/resources?timespan=6 <html><head><title>Not Found</title></head><body><h1>404 Not Found</h1></body></html>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/run.py", line 57, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/run.py", line 188, in start
    discord_bot.connect()
  File "/app/modules/discord/bot.py", line 35, in connect
    self.client.run(self._token, reconnect=True)  # Can't have any asyncio tasks running before the bot is ready
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/discord/client.py", line 860, in run
    asyncio.run(runner())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 641, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.11/asyncio/base_events.py", line 608, in run_forever
    self._run_once()
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1936, in _run_once
    handle._run()
  File "/usr/lib/python3.11/asyncio/events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "/app/modules/tasks/voice_category_stats.py", line 36, in run_service
    exit(1)  # Die on any unhandled exception for this subprocess (i.e. internet connection loss)
    ^^^^^^^
  File "<frozen _sitebuiltins>", line 26, in __call__
SystemExit: 1
2024-10-13T07:48:36: PM2 log: App [tauticord:1] exited with code [1] via signal [SIGINT]

Expected Behavior

It should run fine

Steps to Reproduce

  1. Enable sql queries in tautulli
  2. Tauticord crashes

Supporting Information

I even tried fetching new plex token in tautulli settings. Still same issue.

nwithan8 commented 1 week ago

Do you know what version of Tautulli you are running?

milindpatel63 commented 1 week ago

Do you know what version of Tautulli you are running?

Tautulli: 2.14.5

nwithan8 commented 1 week ago

plexapi.exceptions.NotFound: (404) not_found; http://172.26.31.72:32400/statistics/resources?timespan=6 <html><head><title>Not Found</title></head><body><h1>404 Not Found</h1></body></html>

Your Plex server was unreachable. If you visit http://172.26.31.72:32400/statistics/resources in a browser, what comes back?

milindpatel63 commented 1 week ago

plexapi.exceptions.NotFound: (404) not_found; http://172.26.31.72:32400/statistics/resources?timespan=6 <html><head><title>Not Found</title></head><body><h1>404 Not Found</h1></body></html>

Your Plex server was unreachable. If you visit http://172.26.31.72:32400/statistics/resources in a browser, what comes back?

plex server is running fine. But this is weird, If i go to 'http://172.26.31.72:32400/statistics/resources' it says 404 Not Found in browser. But if i go to my local domain url 'https://plex.example.com/statistics/resources' it says 401 Unauthorized My local domain is just routed via traefik. I'm not aware of an option in plex server settings that disables local network access when directly accessed via ip:port

milindpatel63 commented 1 week ago

Does this by any chance need plex pass? Cause i don't have plex pass.

nwithan8 commented 1 week ago

Does this by any chance need plex pass? Cause i don't have plex pass.

I don't believe so.

If i go to 'http://172.26.31.72:32400/statistics/resources' it says 404 Not Found in browser. But if i go to my local domain url 'plex.example.com/statistics/resources' it says 401 Unauthorized My local domain is just routed via traefik. I'm not aware of an option in plex server settings that disables local network access when directly accessed via ip:port

In Tautulli, what URL is configured to communicate with Plex? I would assume the IP address, since that's what Tautulli had stored in its database.

milindpatel63 commented 1 week ago

Does this by any chance need plex pass? Cause i don't have plex pass.

I don't believe so.

If i go to 'http://172.26.31.72:32400/statistics/resources' it says 404 Not Found in browser. But if i go to my local domain url 'plex.example.com/statistics/resources' it says 401 Unauthorized My local domain is just routed via traefik. I'm not aware of an option in plex server settings that disables local network access when directly accessed via ip:port

In Tautulli, what URL is configured to communicate with Plex? I would assume the IP address, since that's what Tautulli had stored in its database.

But according to this, CPU and Ram usage require Plex Pass https://support.plex.tv/articles/200871837-status-and-dashboard.

Yes, in tautulli, local IP:Port is configured. The same shown in the error logs.

nwithan8 commented 1 week ago

Does this by any chance need plex pass? Cause i don't have plex pass.

I don't believe so.

If i go to 'http://172.26.31.72:32400/statistics/resources' it says 404 Not Found in browser. But if i go to my local domain url 'plex.example.com/statistics/resources' it says 401 Unauthorized My local domain is just routed via traefik. I'm not aware of an option in plex server settings that disables local network access when directly accessed via ip:port

In Tautulli, what URL is configured to communicate with Plex? I would assume the IP address, since that's what Tautulli had stored in its database.

But according to this, CPU and Ram usage require Plex Pass https://support.plex.tv/articles/200871837-status-and-dashboard.

Yes, in tautulli, local IP:Port is configured. The same shown in the error logs.

I was unaware of the Plex Pass requirement. In that case, do you have Plex Pass?

milindpatel63 commented 1 week ago

Does this by any chance need plex pass? Cause i don't have plex pass.

I don't believe so.

If i go to 'http://172.26.31.72:32400/statistics/resources' it says 404 Not Found in browser. But if i go to my local domain url 'plex.example.com/statistics/resources' it says 401 Unauthorized My local domain is just routed via traefik. I'm not aware of an option in plex server settings that disables local network access when directly accessed via ip:port

In Tautulli, what URL is configured to communicate with Plex? I would assume the IP address, since that's what Tautulli had stored in its database.

But according to this, CPU and Ram usage require Plex Pass support.plex.tv/articles/200871837-status-and-dashboard. Yes, in tautulli, local IP:Port is configured. The same shown in the error logs.

I was unaware of the Plex Pass requirement. In that case, do you have Plex Pass?

no i don't. Maybe for non-plex pass users, previous implementation of showing the cpu and memory usage of the host where tauticord is running was fine. An option to switch either would be fine by me.

nwithan8 commented 1 week ago

Thanks. This should now be handled properly in v5.7.3

milindpatel63 commented 1 week ago

Thanks. This should now be handled properly in v5.7.3

so for those people without plex pass, there's no way to get cpu and memory usage right now? I was fine with the old method of getting the performance metrics of the host where the tauticord container was running.

nwithan8 commented 1 week ago

Thanks. This should now be handled properly in v5.7.3

so for those people without plex pass, there's no way to get cpu and memory usage right now? I was fine with the old method of getting the performance metrics of the host where the tauticord container was running.

Correct, just to immediately remove the active bug.

I will look into re-introducing the alternative method for those without Plex Pass.