From 6e8d128b80795005d4cdc7e1db18c635d3ce0b2b Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Thu, 15 Dec 2022 17:01:08 +0100 Subject: [PATCH 01/13] remove leftover line --- pymod/publish.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pymod/publish.py b/pymod/publish.py index d6d5be7..f0b7729 100644 --- a/pymod/publish.py +++ b/pymod/publish.py @@ -49,7 +49,6 @@ def write(self, num=0): fp.writelines(['{0}\n'.format(str(self.inmemq[e][1])) for e in range(self.shared.topic['bulk'])]) published.update([self.inmemq[e][0] for e in range(self.shared.topic['bulk'])]) - self.shared.stats['published'] += self.shared.topic['bulk'] self.inmemq.rotate(-self.shared.topic['bulk']) From 9f1e521352755d34c03ad7593218ebf27ca1bafb Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Fri, 16 Dec 2022 09:35:29 +0100 Subject: [PATCH 02/13] fix walk through of in memory queue in case rate > bulk --- pymod/publish.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pymod/publish.py b/pymod/publish.py index f0b7729..781224e 100644 --- a/pymod/publish.py +++ b/pymod/publish.py @@ -49,7 +49,6 @@ def write(self, num=0): fp.writelines(['{0}\n'.format(str(self.inmemq[e][1])) for e in range(self.shared.topic['bulk'])]) published.update([self.inmemq[e][0] for e in range(self.shared.topic['bulk'])]) - self.inmemq.rotate(-self.shared.topic['bulk']) return True, published @@ -149,7 +148,7 @@ def tag2dict(self, body): return self._extract_body(body, tag_fields, body_to_tagname) - def _write(self, msgs): + def write(self): t = 1 lck = self.events['lck-' + self.name] published = set() @@ -158,6 +157,15 @@ def _write(self, msgs): while t <= self.shared.topic['retry']: try: lck.acquire(False) + msgs = [self.construct_msg(self.inmemq[e][1]) for e in range(self.shared.topic['bulk'])] + msgs = list(map( + lambda m: + AmsMessage(attributes={ + 'partition_date': m[0], + 'type': self.shared.topic['msgtype'] + }, data=m[1]), + msgs) + ) self.ams.publish(self.shared.topic['topic'], msgs, timeout=self.shared.topic['timeout']) published.update([self.inmemq[e][0] for e in range(self.shared.topic['bulk'])]) self._increm_intervalcounters(self.shared.topic['bulk']) @@ -205,10 +213,3 @@ def _write(self, msgs): return False, published return True, published - - def write(self): - msgs = [self.construct_msg(self.inmemq[e][1]) for e in range(self.shared.topic['bulk'])] - msgs = list(map(lambda m: AmsMessage(attributes={'partition_date': m[0], - 'type': self.shared.topic['msgtype']}, - data=m[1]), msgs)) - return self._write(msgs) From ce2331d803929e5d9e32d26d2a801b4e753dcf0e Mon Sep 17 00:00:00 2001 From: Dean Hudek Date: Thu, 14 Dec 2023 13:03:05 +0100 Subject: [PATCH 03/13] removed alarmtoque and its configuration --- .gitignore | 4 ++ bin/ams-alarm-to-queue | 5 -- config/ams-publisher-nagios.conf | 21 ------- config/ams-publisher-sensu.conf | 21 ------- pymod/alarmtoqueue.py | 98 -------------------------------- 5 files changed, 4 insertions(+), 145 deletions(-) create mode 100644 .gitignore delete mode 100755 bin/ams-alarm-to-queue delete mode 100644 pymod/alarmtoqueue.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2123d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Dockerfile +message_generator/ +conf-files/ +ams_test/ \ No newline at end of file diff --git a/bin/ams-alarm-to-queue b/bin/ams-alarm-to-queue deleted file mode 100755 index 9c2a1fb..0000000 --- a/bin/ams-alarm-to-queue +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3 - -from ams_publisher import alarmtoqueue - -alarmtoqueue.main() diff --git a/config/ams-publisher-nagios.conf b/config/ams-publisher-nagios.conf index 9dd2499..7c12314 100644 --- a/config/ams-publisher-nagios.conf +++ b/config/ams-publisher-nagios.conf @@ -28,24 +28,3 @@ AvroSchema = /etc/ams-publisher/metric_data.avsc Retry = 5 Timeout = 60 SleepRetry = 300 - -[Queue_Alarms] -Directory = /var/spool/ams-publisher/alarms/ -Rate = 10 -Purge = True -PurgeEverySec = 300 -MaxTemp = 300 -MaxLock = 0 -Granularity = 60 - -[Topic_Alarms] -Host = messaging-devel.argo.grnet.gr -Key = EGIKEY -Project = EGI -Bulksize = 100 -Topic = alarms -MsgType = alarm -Avro = False -Retry = 5 -Timeout = 60 -SleepRetry = 300 diff --git a/config/ams-publisher-sensu.conf b/config/ams-publisher-sensu.conf index f6398e1..d6209ed 100644 --- a/config/ams-publisher-sensu.conf +++ b/config/ams-publisher-sensu.conf @@ -28,24 +28,3 @@ AvroSchema = /etc/ams-publisher/metric_data.avsc Retry = 5 Timeout = 60 SleepRetry = 300 - -[Queue_Alarms] -Directory = /var/spool/ams-publisher/alarms/ -Rate = 10 -Purge = True -PurgeEverySec = 300 -MaxTemp = 300 -MaxLock = 0 -Granularity = 60 - -[Topic_Alarms] -Host = messaging-devel.argo.grnet.gr -Key = EGIKEY -Project = EGI -Bulksize = 100 -Topic = alarms -MsgType = alarm -Avro = False -Retry = 5 -Timeout = 60 -SleepRetry = 300 diff --git a/pymod/alarmtoqueue.py b/pymod/alarmtoqueue.py deleted file mode 100644 index 82cdd9e..0000000 --- a/pymod/alarmtoqueue.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python - -from messaging.message import Message -from messaging.error import MessageError -from messaging.queue.dqs import DQS - -from ams_publisher import config -from ams_publisher import log - -import argparse -import datetime -import os -import pwd -import pytz -import sys - - -CONF = '/etc/ams-publisher/ams-publisher.conf' - - -def seteuser(user): - os.setegid(user.pw_gid) - os.seteuid(user.pw_uid) - - -def build_msg(args, *headers): - msg = Message() - msg.header = dict() - msg.body = str() - - timestamp, service, hostname, testname, status, nagioshost = headers - - msg.header.update({'execution_time': timestamp}) - msg.header.update({'service_flavour': service}) - msg.header.update({'node_name': hostname}) - msg.header.update({'test_name': testname}) - msg.header.update({'status': status}) - - for bs in ['details', 'vo', 'site', 'roc', 'urlhistory', 'urlhelp']: - code = "msg.body += '%s: ' + args.%s + '\\n' if args.%s else ''" % (bs, bs, bs) - exec(code) - - msg.text = True - return msg - - -def main(): - parser = argparse.ArgumentParser() - lobj = log.Logger(sys.argv[0]) - logger = lobj.get() - confopts = config.parse_config(logger) - nagioshost = confopts['general']['host'] - tz = pytz.timezone(confopts['general']['timezone']) - timestamp = datetime.datetime.now(tz).strftime('%Y-%m-%dT%H:%M:%SZ') - - parser.add_argument('--queue', required=True, nargs='+') - - # msg headers - parser.add_argument('--service', required=True, type=str) - parser.add_argument('--hostname', required=True, type=str) - parser.add_argument('--testname', required=True, type=str) - parser.add_argument('--status', required=True, type=str) - - # msg body - parser.add_argument('--details', required=False, type=str) - parser.add_argument('--vo', required=False, type=str) - parser.add_argument('--site', required=False, type=str) - parser.add_argument('--roc', required=False, type=str) - parser.add_argument('--urlhistory', required=False, type=str) - parser.add_argument('--urlhelp', required=False, type=str) - - args = parser.parse_args() - - seteuser(pwd.getpwnam(confopts['general']['runasuser'])) - - try: - for q in args.queue: - granularity = config.get_queue_granul(q) - mq = DQS(path=q, granularity=granularity) - - msg = build_msg(args, timestamp, args.service, args.hostname, \ - args.testname, args.status, nagioshost) - mq.add_message(msg) - - except MessageError as e: - logger.error('Error constructing alarm - %s', repr(e)) - - except KeyError: - logger.error('No configured Queue for directory %s' % q) - queue_paths = list() - for (k, v) in confopts['queues'].items(): - queue_paths.append('{0} - {1}'.format(k, v['directory'])) - logger.error('Queues and directories found in config: %s' % ', '.join(queue_paths)) - raise SystemExit(1) - - except (OSError, IOError) as e: - logger.error(e) - raise SystemExit(1) From 3fd5dd638090d9940be365f980b70f8c6db01e6b Mon Sep 17 00:00:00 2001 From: Dean Hudek Date: Thu, 14 Dec 2023 13:14:36 +0100 Subject: [PATCH 04/13] removed ams-alarm-to-queue from .spec --- ams-publisher.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/ams-publisher.spec b/ams-publisher.spec index eb5ed51..da2e15c 100644 --- a/ams-publisher.spec +++ b/ams-publisher.spec @@ -54,7 +54,6 @@ Bridge from Nagios to the ARGO Messaging system %files -n argo-nagios-ams-publisher %defattr(-,root,root,-) -%{_bindir}/ams-alarm-to-queue %{_bindir}/ams-metric-to-queue %{_bindir}/ams-publisherd %config(noreplace) %{_sysconfdir}/ams-publisher/ams-publisher-nagios.conf @@ -95,7 +94,6 @@ Bridge from Sensu to the ARGO Messaging system %files -n argo-sensu-ams-publisher %defattr(-,root,root,-) -%{_bindir}/ams-alarm-to-queue %{_bindir}/ams-metric-to-queue %{_bindir}/ams-publisherd %config(noreplace) %{_sysconfdir}/ams-publisher/ams-publisher-sensu.conf From 9f20833cd02010a1c2dc36ec60ec52efe0512e23 Mon Sep 17 00:00:00 2001 From: Dean Hudek Date: Thu, 14 Dec 2023 13:21:17 +0100 Subject: [PATCH 05/13] removed ams-alarm-to-queue from setup n readme --- README.md | 2 +- setup.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9b5ea4..3f73e99 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Component relies on: |-------------------|----------------------------------------------------| | Configuration | `/etc/ams-publisher/ams-publisher.conf`| | Daemon component | `/usr/bin/ams-publisherd` | -| Cache delivery | `/usr/bin/ams-alarm-to-queue, ams-metric-to-queue` | +| Cache delivery | `ams-metric-to-queue` | | Init script (C6) | `/etc/init.d/ams-publisher` | | SystemD Unit (C7) | `/usr/lib/systemd/system/ams-publisher.service` | | Local caches | `/var/spool/ams-publisher/` | diff --git a/setup.py b/setup.py index 5b1931a..0a0330e 100644 --- a/setup.py +++ b/setup.py @@ -31,5 +31,4 @@ def get_ver(): 'config/metric_data.avsc']), ('/usr/lib/systemd/system/', ['init/ams-publisher-nagios.service', 'init/ams-publisher-sensu.service'])], - scripts=['bin/ams-alarm-to-queue', 'bin/ams-metric-to-queue', - 'bin/ams-publisherd']) + scripts=['bin/ams-metric-to-queue', 'bin/ams-publisherd']) From bfa30913396554d30be99190145562bf36da0086 Mon Sep 17 00:00:00 2001 From: Dean Hudek Date: Thu, 14 Dec 2023 13:26:41 +0100 Subject: [PATCH 06/13] maxcmdlength increased to 1kb --- pymod/stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymod/stats.py b/pymod/stats.py index ff30d6e..e9b30ff 100644 --- a/pymod/stats.py +++ b/pymod/stats.py @@ -11,7 +11,7 @@ from multiprocessing import Process from ams_publisher.shared import Shared -MAXCMDLENGTH = 128 +MAXCMDLENGTH = 1024 STATSOCK = '/run/ams-publisher/sock' From 3496d9c6e1fd1fa6656e925141d1c3258ff7b400 Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Mon, 18 Mar 2024 16:15:53 +0100 Subject: [PATCH 07/13] vary pytz dependency based on which distro we're building RPM package --- ams-publisher.spec | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ams-publisher.spec b/ams-publisher.spec index eb5ed51..e2c854f 100644 --- a/ams-publisher.spec +++ b/ams-publisher.spec @@ -44,7 +44,12 @@ Requires: python3-argo-ams-library Requires: python3-avro Requires: python3-dirq Requires: python3-messaging +%if 0%{?el7} Requires: python36-pytz +%endif +%if 0%{?el9} +Requires: python3-pytz +%endif Requires(post): systemd Requires(preun): systemd Requires(postun): systemd @@ -85,7 +90,12 @@ Requires: python3-argo-ams-library Requires: python3-avro Requires: python3-dirq Requires: python3-messaging +%if 0%{?el7} Requires: python36-pytz +%endif +%if 0%{?el9} +Requires: python3-pytz +%endif Requires(post): systemd Requires(preun): systemd Requires(postun): systemd From 511e303ff68977329e3894b7ccd99c607137461c Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Mon, 18 Mar 2024 16:22:05 +0100 Subject: [PATCH 08/13] update spec changelog and version bump --- ams-publisher.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ams-publisher.spec b/ams-publisher.spec index e2c854f..88cdd12 100644 --- a/ams-publisher.spec +++ b/ams-publisher.spec @@ -6,7 +6,7 @@ Name: ams-publisher Summary: Bridge from Sensu/Nagios to the ARGO Messaging system -Version: 0.4.0 +Version: 0.4.1 Release: 1%{mydist} Group: Network/Monitoring @@ -130,6 +130,8 @@ Bridge from Sensu to the ARGO Messaging system rm -rf $RPM_BUILD_ROOT %changelog +* Mon Mar 18 2024 Daniel Vrcic - 0.4.1-1%{?dist} +- refine spec by varying pytz dependency based on whether we're building on Centos7 or Rocky9 * Thu Sep 1 2022 Daniel Vrcic - 0.4.0-1%{?dist} - ARGO-3754 Build two RPMS, Nagios and Sensu with appropriate runtime permission settings - ARGO-3825 List requires explicitly for each ams-publisher package From 53f71e5bf8d580f255c26ca931daeb007fe25fad Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Mon, 18 Mar 2024 22:09:53 +0100 Subject: [PATCH 09/13] add Jenkins stage for Rocky 9 RPM build --- Jenkinsfile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 854a30b..84ec9db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { } } steps { - echo 'Building Rpm...' + echo 'Building Centos 7 RPM...' withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'jenkins-rpm-repo', usernameVariable: 'REPOUSER', \ keyFileVariable: 'REPOKEY')]) { sh "/home/jenkins/build-rpm.sh -w ${WORKSPACE} -b ${BRANCH_NAME} -d centos7 -p ${PROJECT_DIR} -s ${REPOKEY}" @@ -34,6 +34,27 @@ pipeline { } } } + stage ('Build Rocky 9') { + agent { + docker { + image 'argo.registry:5000/epel-9-ams' + args '-u jenkins:jenkins' + } + } + steps { + echo 'Building Rocky 9 RPM...' + withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'jenkins-rpm-repo', usernameVariable: 'REPOUSER', \ + keyFileVariable: 'REPOKEY')]) { + sh "/home/jenkins/build-rpm.sh -w ${WORKSPACE} -b ${BRANCH_NAME} -d rocky9 -p ${PROJECT_DIR} -s ${REPOKEY}" + } + archiveArtifacts artifacts: '**/*.rpm', fingerprint: true + } + post{ + always { + cleanWs() + } + } + } } } } From ab3ba9aede2a82d7e0f3e04bb3797f22123f257a Mon Sep 17 00:00:00 2001 From: Katarina Zailac <40790290+kzailac@users.noreply.github.com> Date: Tue, 28 May 2024 09:21:08 +0200 Subject: [PATCH 10/13] Revert "ARGO-4445 Increase cmd querry size for publisher probe inspection" --- .gitignore | 4 -- README.md | 2 +- ams-publisher.spec | 2 + bin/ams-alarm-to-queue | 5 ++ config/ams-publisher-nagios.conf | 21 +++++++ config/ams-publisher-sensu.conf | 21 +++++++ pymod/alarmtoqueue.py | 98 ++++++++++++++++++++++++++++++++ pymod/stats.py | 2 +- setup.py | 3 +- 9 files changed, 151 insertions(+), 7 deletions(-) delete mode 100644 .gitignore create mode 100755 bin/ams-alarm-to-queue create mode 100644 pymod/alarmtoqueue.py diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f2123d7..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Dockerfile -message_generator/ -conf-files/ -ams_test/ \ No newline at end of file diff --git a/README.md b/README.md index 3f73e99..e9b5ea4 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Component relies on: |-------------------|----------------------------------------------------| | Configuration | `/etc/ams-publisher/ams-publisher.conf`| | Daemon component | `/usr/bin/ams-publisherd` | -| Cache delivery | `ams-metric-to-queue` | +| Cache delivery | `/usr/bin/ams-alarm-to-queue, ams-metric-to-queue` | | Init script (C6) | `/etc/init.d/ams-publisher` | | SystemD Unit (C7) | `/usr/lib/systemd/system/ams-publisher.service` | | Local caches | `/var/spool/ams-publisher/` | diff --git a/ams-publisher.spec b/ams-publisher.spec index 9a6ea91..88cdd12 100644 --- a/ams-publisher.spec +++ b/ams-publisher.spec @@ -59,6 +59,7 @@ Bridge from Nagios to the ARGO Messaging system %files -n argo-nagios-ams-publisher %defattr(-,root,root,-) +%{_bindir}/ams-alarm-to-queue %{_bindir}/ams-metric-to-queue %{_bindir}/ams-publisherd %config(noreplace) %{_sysconfdir}/ams-publisher/ams-publisher-nagios.conf @@ -104,6 +105,7 @@ Bridge from Sensu to the ARGO Messaging system %files -n argo-sensu-ams-publisher %defattr(-,root,root,-) +%{_bindir}/ams-alarm-to-queue %{_bindir}/ams-metric-to-queue %{_bindir}/ams-publisherd %config(noreplace) %{_sysconfdir}/ams-publisher/ams-publisher-sensu.conf diff --git a/bin/ams-alarm-to-queue b/bin/ams-alarm-to-queue new file mode 100755 index 0000000..9c2a1fb --- /dev/null +++ b/bin/ams-alarm-to-queue @@ -0,0 +1,5 @@ +#!/usr/bin/python3 + +from ams_publisher import alarmtoqueue + +alarmtoqueue.main() diff --git a/config/ams-publisher-nagios.conf b/config/ams-publisher-nagios.conf index 7c12314..9dd2499 100644 --- a/config/ams-publisher-nagios.conf +++ b/config/ams-publisher-nagios.conf @@ -28,3 +28,24 @@ AvroSchema = /etc/ams-publisher/metric_data.avsc Retry = 5 Timeout = 60 SleepRetry = 300 + +[Queue_Alarms] +Directory = /var/spool/ams-publisher/alarms/ +Rate = 10 +Purge = True +PurgeEverySec = 300 +MaxTemp = 300 +MaxLock = 0 +Granularity = 60 + +[Topic_Alarms] +Host = messaging-devel.argo.grnet.gr +Key = EGIKEY +Project = EGI +Bulksize = 100 +Topic = alarms +MsgType = alarm +Avro = False +Retry = 5 +Timeout = 60 +SleepRetry = 300 diff --git a/config/ams-publisher-sensu.conf b/config/ams-publisher-sensu.conf index d6209ed..f6398e1 100644 --- a/config/ams-publisher-sensu.conf +++ b/config/ams-publisher-sensu.conf @@ -28,3 +28,24 @@ AvroSchema = /etc/ams-publisher/metric_data.avsc Retry = 5 Timeout = 60 SleepRetry = 300 + +[Queue_Alarms] +Directory = /var/spool/ams-publisher/alarms/ +Rate = 10 +Purge = True +PurgeEverySec = 300 +MaxTemp = 300 +MaxLock = 0 +Granularity = 60 + +[Topic_Alarms] +Host = messaging-devel.argo.grnet.gr +Key = EGIKEY +Project = EGI +Bulksize = 100 +Topic = alarms +MsgType = alarm +Avro = False +Retry = 5 +Timeout = 60 +SleepRetry = 300 diff --git a/pymod/alarmtoqueue.py b/pymod/alarmtoqueue.py new file mode 100644 index 0000000..82cdd9e --- /dev/null +++ b/pymod/alarmtoqueue.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python + +from messaging.message import Message +from messaging.error import MessageError +from messaging.queue.dqs import DQS + +from ams_publisher import config +from ams_publisher import log + +import argparse +import datetime +import os +import pwd +import pytz +import sys + + +CONF = '/etc/ams-publisher/ams-publisher.conf' + + +def seteuser(user): + os.setegid(user.pw_gid) + os.seteuid(user.pw_uid) + + +def build_msg(args, *headers): + msg = Message() + msg.header = dict() + msg.body = str() + + timestamp, service, hostname, testname, status, nagioshost = headers + + msg.header.update({'execution_time': timestamp}) + msg.header.update({'service_flavour': service}) + msg.header.update({'node_name': hostname}) + msg.header.update({'test_name': testname}) + msg.header.update({'status': status}) + + for bs in ['details', 'vo', 'site', 'roc', 'urlhistory', 'urlhelp']: + code = "msg.body += '%s: ' + args.%s + '\\n' if args.%s else ''" % (bs, bs, bs) + exec(code) + + msg.text = True + return msg + + +def main(): + parser = argparse.ArgumentParser() + lobj = log.Logger(sys.argv[0]) + logger = lobj.get() + confopts = config.parse_config(logger) + nagioshost = confopts['general']['host'] + tz = pytz.timezone(confopts['general']['timezone']) + timestamp = datetime.datetime.now(tz).strftime('%Y-%m-%dT%H:%M:%SZ') + + parser.add_argument('--queue', required=True, nargs='+') + + # msg headers + parser.add_argument('--service', required=True, type=str) + parser.add_argument('--hostname', required=True, type=str) + parser.add_argument('--testname', required=True, type=str) + parser.add_argument('--status', required=True, type=str) + + # msg body + parser.add_argument('--details', required=False, type=str) + parser.add_argument('--vo', required=False, type=str) + parser.add_argument('--site', required=False, type=str) + parser.add_argument('--roc', required=False, type=str) + parser.add_argument('--urlhistory', required=False, type=str) + parser.add_argument('--urlhelp', required=False, type=str) + + args = parser.parse_args() + + seteuser(pwd.getpwnam(confopts['general']['runasuser'])) + + try: + for q in args.queue: + granularity = config.get_queue_granul(q) + mq = DQS(path=q, granularity=granularity) + + msg = build_msg(args, timestamp, args.service, args.hostname, \ + args.testname, args.status, nagioshost) + mq.add_message(msg) + + except MessageError as e: + logger.error('Error constructing alarm - %s', repr(e)) + + except KeyError: + logger.error('No configured Queue for directory %s' % q) + queue_paths = list() + for (k, v) in confopts['queues'].items(): + queue_paths.append('{0} - {1}'.format(k, v['directory'])) + logger.error('Queues and directories found in config: %s' % ', '.join(queue_paths)) + raise SystemExit(1) + + except (OSError, IOError) as e: + logger.error(e) + raise SystemExit(1) diff --git a/pymod/stats.py b/pymod/stats.py index e9b30ff..ff30d6e 100644 --- a/pymod/stats.py +++ b/pymod/stats.py @@ -11,7 +11,7 @@ from multiprocessing import Process from ams_publisher.shared import Shared -MAXCMDLENGTH = 1024 +MAXCMDLENGTH = 128 STATSOCK = '/run/ams-publisher/sock' diff --git a/setup.py b/setup.py index 0a0330e..5b1931a 100644 --- a/setup.py +++ b/setup.py @@ -31,4 +31,5 @@ def get_ver(): 'config/metric_data.avsc']), ('/usr/lib/systemd/system/', ['init/ams-publisher-nagios.service', 'init/ams-publisher-sensu.service'])], - scripts=['bin/ams-metric-to-queue', 'bin/ams-publisherd']) + scripts=['bin/ams-alarm-to-queue', 'bin/ams-metric-to-queue', + 'bin/ams-publisherd']) From d3097d5dfa3d4064693a971a5cece70d1006b18e Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Thu, 6 Jun 2024 12:20:25 +0200 Subject: [PATCH 11/13] list all changes in CHANGELOG for the release --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 423baab..119459b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [0.4.1] - 2024-06-06 + +### Changed + +* ARGO-4445 Increase cmd query size for publisher probe inspection + +### Added + +* ARGO-4524 ams-publisher Rocky 9 RPM + ## [0.4.0] - 2022-09-1 ### Changed From d8686ee603e3eb52f469e147eca7b17d0256dfa9 Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Thu, 6 Jun 2024 12:24:50 +0200 Subject: [PATCH 12/13] increase maxcmdlength --- pymod/stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymod/stats.py b/pymod/stats.py index ff30d6e..a4d7aa5 100644 --- a/pymod/stats.py +++ b/pymod/stats.py @@ -11,7 +11,7 @@ from multiprocessing import Process from ams_publisher.shared import Shared -MAXCMDLENGTH = 128 +MAXCMDLENGTH = 1024 STATSOCK = '/run/ams-publisher/sock' @@ -30,7 +30,7 @@ def parse_result(query): shared = Shared() - maxcmdlength = 128 + maxcmdlength = 1024 query_consumed, query_published = '', '' for w in shared.workers: From 31a623773762095336ea9de9e537387b2008b946 Mon Sep 17 00:00:00 2001 From: Daniel Vrcic Date: Thu, 6 Jun 2024 12:29:40 +0200 Subject: [PATCH 13/13] refine README with basic Rocky 9 info --- README.md | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e9b5ea4..53357ad 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ Complete list of features are: ## Installation -Component is supported on CentOS 7. RPM packages and all needed dependencies are available in ARGO repositories so installation of component simply narrows down to installing a package: +Component is supported on CentOS 7 and Rocky 9 Linux. RPM packages and all needed dependencies are available in ARGO repositories so installation of component simply narrows down to installing a package: - yum install -y ams-publisher + dnf install -y ams-publisher Component relies on: - `argo-ams-library` - interaction with ARGO Messaging @@ -42,14 +42,13 @@ Component relies on: | File Types | Destination | |-------------------|----------------------------------------------------| -| Configuration | `/etc/ams-publisher/ams-publisher.conf`| +| Configuration | `/etc/ams-publisher/ams-publisher.conf` | | Daemon component | `/usr/bin/ams-publisherd` | | Cache delivery | `/usr/bin/ams-alarm-to-queue, ams-metric-to-queue` | -| Init script (C6) | `/etc/init.d/ams-publisher` | -| SystemD Unit (C7) | `/usr/lib/systemd/system/ams-publisher.service` | -| Local caches | `/var/spool/ams-publisher/` | -| Inspection socket | `/var/run/ams-publisher/sock` | -| Log files | `/var/log/ams-publisher/` | +| SystemD Unit (R9) | `/usr/lib/systemd/system/ams-publisher.service` | +| Local caches | `/var/spool/ams-publisher/` | +| Inspection socket | `/run/ams-publisher/sock` | +| Log files | `/var/log/ams-publisher/` | ## Configuration @@ -120,12 +119,7 @@ SleepRetry = 300 Components needs to be properly configured before starting it. At least one worker must be spawned so at least one directory queue needs to exist, Nagios should deliver results to it and publisher part of the worker needs to be associated to it. Afterward, it's just a matter of starting the service. -CentOS 6: -``` -/etc/init.d/ams-publisher start -``` - -CentOS 7: +CentOS 7 and Rocky 9: ``` systemctl start ams-publisher.service ```