Skip to content

Commit

Permalink
Dispatcher bugfix queues not being disabled properly (#13364)
Browse files Browse the repository at this point in the history
* Dispatcher bugfix queues not being disabled properly
Introduced in #13355
Affected queues: Alerting, Discovery, Services, Ping

Adjust log level of several messages

* better formatting? looks like garbage python black
  • Loading branch information
murrant committed Oct 15, 2021
1 parent da57ea6 commit eb65361
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
8 changes: 4 additions & 4 deletions LibreNMS/__init__.py
Expand Up @@ -222,9 +222,9 @@ def connect(self):
import pymysql

pymysql.install_as_MySQLdb()
logger.info("Using pure python SQL client")
logger.debug("Using pure python SQL client")
except ImportError:
logger.info("Using other SQL client")
logger.debug("Using other SQL client")

try:
import MySQLdb
Expand Down Expand Up @@ -421,7 +421,7 @@ def __init__(self, namespace="lock", **redis_kwargs):
self._redis = redis.Redis(**kwargs)
self._redis.ping()
self._namespace = namespace
logger.info(
logger.debug(
"Created redis lock manager with socket_timeout of {}s".format(
redis_kwargs["socket_timeout"]
)
Expand Down Expand Up @@ -503,7 +503,7 @@ def __init__(self, name, namespace="queue", **redis_kwargs):
self._redis = redis.Redis(**kwargs)
self._redis.ping()
self.key = "{}:{}".format(namespace, name)
logger.info(
logger.debug(
"Created redis queue with socket_timeout of {}s".format(
redis_kwargs["socket_timeout"]
)
Expand Down
15 changes: 8 additions & 7 deletions LibreNMS/queuemanager.py
Expand Up @@ -41,8 +41,8 @@ def __init__(

self._stop_event = threading.Event()

logger.info("Groups: {}".format(self.config.group))
logger.info(
logger.debug("Groups: {}".format(self.config.group))
logger.debug(
"{} QueueManager created: {} workers, {}s frequency".format(
self.type.title(),
self.get_poller_config().workers,
Expand Down Expand Up @@ -126,6 +126,7 @@ def start(self):
if hasattr(self.config.group, "__iter__")
else [self.config.group]
)
logger.debug("Starting {} workers for {}".format(workers, self.type))
if self.uses_groups:
for group in groups:
group_workers = max(int(workers / len(groups)), 1)
Expand Down Expand Up @@ -198,7 +199,7 @@ def _create_queue(self, queue_type, group):
:param group:
:return:
"""
logger.info("Creating queue {}".format(self.queue_name(queue_type, group)))
logger.debug("Creating queue {}".format(self.queue_name(queue_type, group)))
try:
return LibreNMS.RedisUniqueQueue(
self.queue_name(queue_type, group),
Expand Down Expand Up @@ -373,7 +374,7 @@ def __init__(self, config, lock_manager):
:param lock_manager: the single instance of lock manager
"""
TimedQueueManager.__init__(
self, config, lock_manager, "ping", config.ping.enabled
self, config, lock_manager, "ping", False, config.ping.enabled
)
self._db = LibreNMS.DB(self.config)

Expand Down Expand Up @@ -409,7 +410,7 @@ def __init__(self, config, lock_manager):
:param lock_manager: the single instance of lock manager
"""
TimedQueueManager.__init__(
self, config, lock_manager, "services", config.services.enabled
self, config, lock_manager, "services", False, config.services.enabled
)
self._db = LibreNMS.DB(self.config)

Expand Down Expand Up @@ -459,7 +460,7 @@ def __init__(self, config, lock_manager):
:param lock_manager: the single instance of lock manager
"""
TimedQueueManager.__init__(
self, config, lock_manager, "alerting", config.alerting.enabled
self, config, lock_manager, "alerting", False, config.alerting.enabled
)
self._db = LibreNMS.DB(self.config)

Expand Down Expand Up @@ -526,7 +527,7 @@ def __init__(self, config, lock_manager):
:param lock_manager: the single instance of lock manager
"""
TimedQueueManager.__init__(
self, config, lock_manager, "discovery", config.discovery.enabled
self, config, lock_manager, "discovery", False, config.discovery.enabled
)
self._db = LibreNMS.DB(self.config)

Expand Down
19 changes: 18 additions & 1 deletion LibreNMS/service.py
Expand Up @@ -369,7 +369,7 @@ def service_age(self):
return time.time() - self.start_time

def attach_signals(self):
logger.info(
logger.debug(
"Attaching signal handlers on thread %s", threading.current_thread().name
)
signal(SIGTERM, self.terminate) # capture sigterm and exit gracefully
Expand Down Expand Up @@ -451,6 +451,23 @@ def start(self):
"redis" if isinstance(self._lm, LibreNMS.RedisLock) else "internal",
)
)
logger.info(
"Queue Workers: Discovery={} Poller={} Services={} Alerting={} Billing={} Ping={}".format(
self.config.discovery.workers
if self.config.discovery.enabled
else "disabled",
self.config.poller.workers
if self.config.poller.enabled
else "disabled",
self.config.services.workers
if self.config.services.enabled
else "disabled",
"enabled" if self.config.alerting.enabled else "disabled",
"enabled" if self.config.billing.enabled else "disabled",
"enabled" if self.config.ping.enabled else "disabled",
)
)

if self.config.update_enabled:
logger.info(
"Maintenance tasks will be run every {}".format(
Expand Down

0 comments on commit eb65361

Please sign in to comment.