kopia lustrzana https://github.com/Yakifo/amqtt
Merge pull request #181 from ajmirsky/issue/180
fix: $SYS broker stats plugin, topicspull/184/head^2
commit
52faed680b
|
@ -1,3 +1,3 @@
|
||||||
"""INIT."""
|
"""INIT."""
|
||||||
|
|
||||||
__version__ = "0.11.0-beta4"
|
__version__ = "0.11.0-rc"
|
||||||
|
|
|
@ -196,7 +196,7 @@ class PluginManager:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _call_coro(plugin: Plugin, coro_name: str, *args: Any, **kwargs: Any) -> str | bool | None:
|
async def _call_coro(plugin: Plugin, coro_name: str, *args: Any, **kwargs: Any) -> str | bool | None:
|
||||||
if not hasattr(plugin.object, coro_name):
|
if not hasattr(plugin.object, coro_name):
|
||||||
_LOGGER.warning("Plugin doesn't implement coro_name")
|
_LOGGER.warning(f"Plugin doesn't implement coro_name '{coro_name}': {plugin.name}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
coro: Awaitable[str | bool | None] = getattr(plugin.object, coro_name)(*args, **kwargs)
|
coro: Awaitable[str | bool | None] = getattr(plugin.object, coro_name)(*args, **kwargs)
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BrokerSysPlugin:
|
||||||
async def on_broker_post_start(self, *args: None, **kwargs: None) -> None:
|
async def on_broker_post_start(self, *args: None, **kwargs: None) -> None:
|
||||||
"""Initialize statistics and start $SYS broadcasting."""
|
"""Initialize statistics and start $SYS broadcasting."""
|
||||||
self._stats[STAT_START_TIME] = int(datetime.now(tz=UTC).timestamp())
|
self._stats[STAT_START_TIME] = int(datetime.now(tz=UTC).timestamp())
|
||||||
version = f"HBMQTT version {amqtt.__version__}"
|
version = f"aMQTT version {amqtt.__version__}"
|
||||||
self.context.retain_message(DOLLAR_SYS_ROOT + "version", version.encode())
|
self.context.retain_message(DOLLAR_SYS_ROOT + "version", version.encode())
|
||||||
|
|
||||||
# Start $SYS topics management
|
# Start $SYS topics management
|
||||||
|
@ -131,8 +131,8 @@ class BrokerSysPlugin:
|
||||||
"messages/received": self._stats[STAT_MSG_RECEIVED],
|
"messages/received": self._stats[STAT_MSG_RECEIVED],
|
||||||
"messages/sent": self._stats[STAT_MSG_SENT],
|
"messages/sent": self._stats[STAT_MSG_SENT],
|
||||||
"time": int(datetime.now(tz=UTC).timestamp()),
|
"time": int(datetime.now(tz=UTC).timestamp()),
|
||||||
"uptime": str(datetime.fromtimestamp(uptime, UTC)),
|
"uptime": str(uptime),
|
||||||
"uptime/formatted": str(uptime),
|
"uptime/formatted": str(datetime.fromtimestamp(self._stats[STAT_START_TIME], UTC)),
|
||||||
"clients/connected": client_connected,
|
"clients/connected": client_connected,
|
||||||
"clients/disconnected": client_disconnected,
|
"clients/disconnected": client_disconnected,
|
||||||
"clients/maximum": self._stats[STAT_CLIENTS_MAXIMUM],
|
"clients/maximum": self._stats[STAT_CLIENTS_MAXIMUM],
|
||||||
|
|
Ładowanie…
Reference in New Issue