Bug 56350 - Traceback in check_univention_ad_connector (univention-monitoring-client)
Traceback in check_univention_ad_connector (univention-monitoring-client)
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Monitoring (Prometheus or Nagios)
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-4-errata
Assigned To: Florian Best
Christian Castens
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-07-25 14:29 CEST by Christina Scheinig
Modified: 2023-07-26 14:55 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.069
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2023072421000235, 2023072621000081
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christina Scheinig univentionstaff 2023-07-25 14:29:09 CEST
On the DC and DC-Backup the command
 
run-parts /usr/share/univention-monitoring-client/scripts/

is executed and throws the following traceback:
 
Traceback (most recent call last):

  File "/usr/share/univention-monitoring-client/scripts//check_univention_ad_connector", line 89, in <module>
    ADConnector.main()
  File "/usr/lib/python3/dist-packages/univention/monitoring/__init__.py", line 73, in main
    self.write_metrics()
  File "/usr/share/univention-monitoring-client/scripts//check_univention_ad_connector", line 51, in write_metrics
    self.write_connector_metrics(len(connectors), connector)
  File "/usr/share/univention-monitoring-client/scripts//check_univention_ad_connector", line 57, in write_connector_metrics
    self.write_metric('univention_ad_connector_ad_reachable', 1 if rc == 0 else 0)
  File "/usr/lib/python3/dist-packages/univention/monitoring/__init__.py", line 81, in write_metric
    g = Gauge(metric_name, doc or self.__doc__ or '', labelnames=list(labels), registry=self._registry)
  File "/usr/lib/python3/dist-packages/prometheus_client/metrics.py", line 320, in __init__
    labelvalues=labelvalues,
  File "/usr/lib/python3/dist-packages/prometheus_client/metrics.py", line 103, in __init__
    registry.register(self)
  File "/usr/lib/python3/dist-packages/prometheus_client/registry.py", line 29, in register
    duplicates))
ValueError: Duplicated timeseries in CollectorRegistry: {'univention_ad_connector_ad_reachable'}
run-parts: /usr/share/univention-monitoring-client/scripts//check_univention_ad_connector exited with return code 1
Comment 1 Florian Best univentionstaff 2023-07-25 14:54:59 CEST
diff --git monitoring/univention-monitoring-client/alerts-ad-connector/check_univention_ad_connector monitoring/univention-monitoring-client/alerts-ad-connector/check_univention_ad_connector
index ecbe90e92a..b8725f6634 100755
--- monitoring/univention-monitoring-client/alerts-ad-connector/check_univention_ad_connector
+++ monitoring/univention-monitoring-client/alerts-ad-connector/check_univention_ad_connector
@@ -48,13 +48,15 @@ class ADConnector(Alert):
     def write_metrics(self):
         connectors = ('connector %s' % ucr.get('connector/listener/additionalbasenames', '')).split(' ')
         for connector in connectors:
+            if not connector:
+                continue
             self.write_connector_metrics(len(connectors), connector)
 
     def write_connector_metrics(self, connectors, connector):
         # check whether we can connect to the AD
         # CRITICAL: in case we cannot connect to the AD
         rc = self.exec_command(['univention-adsearch', '-c', connector, 'cn=users'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)[0]
-        self.write_metric('univention_ad_connector_ad_reachable', 1 if rc == 0 else 0)
+        self.write_metric('univention_ad_connector_ad_reachable', 1 if rc == 0 else 0, connector=connector)
 
         # check whether the AD connector is running; for this, get the exact command
         # that was used to launch the process; remove multiple whitespaces and quotes
Comment 2 Florian Best univentionstaff 2023-07-26 11:36:12 CEST
Patch applied.

univention-monitoring-client.yaml
66b5c6112ba1 | fix(monitoring): fix writing of metrics and labels in check_univention_ad_connector

univention-monitoring-client (1.0.2-6)
66b5c6112ba1 | fix(monitoring): fix writing of metrics and labels in check_univention_ad_connector
Comment 3 Christian Castens univentionstaff 2023-07-26 14:36:49 CEST
QA:
  Tested with:
     apt install univention-monitoring-ad-connector
     echo '#!/bin/sh' > /usr/sbin/univention-adsearch
     chmod +x /usr/sbin/univention-adsearch
     cp /usr/sbin/univention-adsearch /usr/sbin/univention-adconnector-list-rejected
     /usr/share/univention-monitoring-client/scripts/check_univention_ad_connector

 - Traceback does not occur anymore with the new version: OK
 - No related errors/tracebacks in logfiles: OK
 - advisories: OK
Comment 4 Christian Castens univentionstaff 2023-07-26 14:55:46 CEST
<https://errata.software-univention.de/#/?erratum=5.0x752>