From 2ae25caa69a9413002edbf88cb78a2329e109cbf Mon Sep 17 00:00:00 2001 From: voetberg Date: Wed, 18 Mar 2026 10:21:15 -0500 Subject: [PATCH 1/5] Common: Update to python3, remove future print Issue: probes#127 --- common/check_updated_dids | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/check_updated_dids b/common/check_updated_dids index 756aad8a..7ee5b6cc 100755 --- a/common/check_updated_dids +++ b/common/check_updated_dids @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright European Organization for Nuclear Research (CERN) 2013 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,7 +13,6 @@ """ Probe to check the backlog of updated dids. """ -from __future__ import print_function import sys import traceback From c32fea261854c49059b85254ecf56664945981d6 Mon Sep 17 00:00:00 2001 From: voetberg Date: Wed, 18 Mar 2026 10:22:02 -0500 Subject: [PATCH 2/5] Common: Correct copyright statement Issue: probes#127 --- common/check_updated_dids | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/check_updated_dids b/common/check_updated_dids index 7ee5b6cc..390cf6d5 100755 --- a/common/check_updated_dids +++ b/common/check_updated_dids @@ -1,14 +1,17 @@ #!/usr/bin/env python3 -# Copyright European Organization for Nuclear Research (CERN) 2013 +# Copyright European Organization for Nuclear Research (CERN) since 2012 # # Licensed under the Apache License, Version 2.0 (the "License"); -# You may not use this file except in compliance with the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# Authors: -# - Vincent Garonne, , 2013 -# - Thomas Beermann, , 2019 -# - Eric Vaandering , 2020-2021 +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Probe to check the backlog of updated dids. From f57f8bf2e0467c284c16caad8ec597531bfb6c13 Mon Sep 17 00:00:00 2001 From: voetberg Date: Wed, 18 Mar 2026 10:27:34 -0500 Subject: [PATCH 3/5] Common: Use select and func.count statements from sqla2.0 Issue: probes#127 --- common/check_updated_dids | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/check_updated_dids b/common/check_updated_dids index 390cf6d5..cc5de38b 100755 --- a/common/check_updated_dids +++ b/common/check_updated_dids @@ -21,10 +21,11 @@ import sys import traceback from prometheus_client import CollectorRegistry, Gauge, push_to_gateway +from sqlalchemy import func, select + from rucio.common.config import config_get from rucio.db.sqla import models from rucio.db.sqla.session import get_session -from rucio.db.sqla.util import get_count from utils.common import probe_metrics @@ -39,8 +40,12 @@ if __name__ == "__main__": try: registry = CollectorRegistry() session = get_session() - query = session.query(models.UpdatedDID) - result = get_count(query) + stmt = select( + func.count() + ).select_from( + models.UpdatedDID + ) + result = session.execute(stmt).scalar_one() probe_metrics.gauge(name='judge.updated_dids').set(result) Gauge('judge_updated_dids', '', registry=registry).set(result) From 1ebbbbb0e7e33b2949baf19073f5f4175677a7f0 Mon Sep 17 00:00:00 2001 From: voetberg Date: Wed, 18 Mar 2026 10:28:19 -0500 Subject: [PATCH 4/5] Common: Remove unused comment Issue: probes#127 --- common/check_updated_dids | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/common/check_updated_dids b/common/check_updated_dids index cc5de38b..cb76c17c 100755 --- a/common/check_updated_dids +++ b/common/check_updated_dids @@ -56,16 +56,6 @@ if __name__ == "__main__": except: continue - # created_at, count, max, min, avg, stdev = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 - # result = session.execute('select * from atlas_rucio.concurency_stats where created_at > sysdate - 1/1440') - # for row in result: - # created_at, count, max, min, avg, stdev = row - # monitor.record_gauge(stat='judge.updated_dids_per_min.count', value=count or 0) - # monitor.record_gauge(stat='judge.updated_dids_per_min.max', value=max or 0) - # monitor.record_gauge(stat='judge.updated_dids_per_min.min', value=min or 0) - # monitor.record_gauge(stat='judge.updated_dids_per_min.avg', value=avg or 0) - # monitor.record_gauge(stat='judge.updated_dids_per_min.stdev', value=stdev or 0) - # print created_at, count, max, min, avg, stdev except: print(traceback.format_exc()) sys.exit(UNKNOWN) From 029c879d485f3e19e98f2e1458c58d2753d66b4c Mon Sep 17 00:00:00 2001 From: voetberg Date: Wed, 18 Mar 2026 10:31:20 -0500 Subject: [PATCH 5/5] Common: Use updated prometheuspusher methods Issue: probes#127 --- common/check_updated_dids | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/common/check_updated_dids b/common/check_updated_dids index cb76c17c..06e13bee 100755 --- a/common/check_updated_dids +++ b/common/check_updated_dids @@ -20,41 +20,28 @@ Probe to check the backlog of updated dids. import sys import traceback -from prometheus_client import CollectorRegistry, Gauge, push_to_gateway from sqlalchemy import func, select -from rucio.common.config import config_get from rucio.db.sqla import models from rucio.db.sqla.session import get_session -from utils.common import probe_metrics +from utils.common import PrometheusPusher # Exit statuses OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3 -PROM_SERVERS = config_get('monitor', 'prometheus_servers', raise_exception=False, default='') -if PROM_SERVERS != '': - PROM_SERVERS = PROM_SERVERS.split(',') - if __name__ == "__main__": try: - registry = CollectorRegistry() session = get_session() - stmt = select( - func.count() - ).select_from( - models.UpdatedDID - ) - result = session.execute(stmt).scalar_one() - probe_metrics.gauge(name='judge.updated_dids').set(result) - Gauge('judge_updated_dids', '', registry=registry).set(result) - - if len(PROM_SERVERS): - for server in PROM_SERVERS: - try: - push_to_gateway(server.strip(), job='check_updated_dids', registry=registry) - except: - continue + + with PrometheusPusher(job_name='check_updated_dids') as manager: + stmt = select( + func.count() + ).select_from( + models.UpdatedDID + ) + result = session.execute(stmt).scalar_one() + manager.gauge(name='judge.updated_dids').set(result) except: print(traceback.format_exc())