Hello community,

here is the log from the commit of package prometheus-webhook-snmp for 
openSUSE:Factory checked in at 2020-05-12 22:33:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/prometheus-webhook-snmp (Old)
 and      /work/SRC/openSUSE:Factory/.prometheus-webhook-snmp.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "prometheus-webhook-snmp"

Tue May 12 22:33:33 2020 rev:2 rq:802864 version:1.3

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/prometheus-webhook-snmp/prometheus-webhook-snmp.changes
  2019-12-04 14:20:08.186425813 +0100
+++ 
/work/SRC/openSUSE:Factory/.prometheus-webhook-snmp.new.2738/prometheus-webhook-snmp.changes
        2020-05-12 22:33:42.116040897 +0200
@@ -1,0 +2,11 @@
+Wed Mar 25 08:15:50 UTC 2020 - Volker Theile <[email protected]>
+
+- Update to version 1.3
+  * Add 'trap-default-severity' configuration option.
+  * Harden the notification parser. (bsc#1171471)
+  version 1.2
+  * Show used configuration settings in debug mode.
+  * Load configuration file from the directory in which the 
prometheus-webhook-snmp command is located.
+  * Automatically convert hyphens to underscores in configuration file 
parameters.
+
+-------------------------------------------------------------------

Old:
----
  prometheus-webhook-snmp-1.1+1557846568.ga2ef545.tar.gz

New:
----
  prometheus-webhook-snmp-1.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ prometheus-webhook-snmp.spec ++++++
--- /var/tmp/diff_new_pack.mAb1VR/_old  2020-05-12 22:33:43.896044612 +0200
+++ /var/tmp/diff_new_pack.mAb1VR/_new  2020-05-12 22:33:43.900044620 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package prometheus-webhook-snmp
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019-2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,12 +15,12 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 
 Name:           prometheus-webhook-snmp
-Version:        1.1+1557846568.ga2ef545
+Version:        1.3
 Release:        0
 Summary:        Prometheus Alertmanager receiver for SNMP traps
 License:        GPL-3.0
 Group:          System/Management
-Url:            https://github.com/SUSE/prometheus-webhook-snmp
+URL:            https://github.com/SUSE/prometheus-webhook-snmp
 Source0:        %{name}-%{version}.tar.gz
 BuildArch:      noarch
 

++++++ _service ++++++
--- /var/tmp/diff_new_pack.mAb1VR/_old  2020-05-12 22:33:43.932044687 +0200
+++ /var/tmp/diff_new_pack.mAb1VR/_new  2020-05-12 22:33:43.932044687 +0200
@@ -5,7 +5,7 @@
     <param name="exclude">.git</param>
     <param name="changesgenerate">disable</param>
     <param name="extract">prometheus-webhook-snmp.spec</param>
-    <param name="revision">v1.1</param>
+    <param name="revision">v1.3</param>
     <param name="versionformat">@PARENT_TAG@.%ct.%h</param>
     <param name="versionrewrite-pattern">v(.*)</param>
   </service>

++++++ prometheus-webhook-snmp-1.1+1557846568.ga2ef545.tar.gz -> 
prometheus-webhook-snmp-1.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/CHANGELOG.md 
new/prometheus-webhook-snmp-1.3/CHANGELOG.md
--- old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/CHANGELOG.md    
1970-01-01 01:00:00.000000000 +0100
+++ new/prometheus-webhook-snmp-1.3/CHANGELOG.md        2020-03-25 
09:48:10.000000000 +0100
@@ -0,0 +1,22 @@
+v1.3
+
+  * Add 'trap-default-severity' configuration option.
+  * Harden the notification parser.
+
+v1.2
+
+  * Show used configuration settings in debug mode.
+  * Load configuration file from the directory in which the 
prometheus-webhook-snmp
+    command is located.
+  * Automatically convert hyphens to underscores in configuration file 
parameters.
+
+v1.1
+
+  * Add support for global configuration file /etc/prometheus-webhook-snmp.conf
+  * Add ability to configure systemd service via 
/etc/default/prometheus-webhook-snmp
+  * Added python3-PyYAML as new dependency
+  * python3-pysnmp needs to be at least 4.4.1
+
+v1.0
+
+  * Initial Debian packaging.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/README.md 
new/prometheus-webhook-snmp-1.3/README.md
--- old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/README.md       
2019-05-14 17:09:27.643504043 +0200
+++ new/prometheus-webhook-snmp-1.3/README.md   2020-03-25 09:48:10.000000000 
+0100
@@ -1,4 +1,4 @@
-prometheus-webhook-snmp is a Prometheus Alertmanager receiver that translates 
incoming notifications into SNMP traps.
+prometheus-webhook-snmp is a Prometheus Alertmanager receiver that translates 
incoming notifications into SNMP v2c traps.
 
 # Features
 
@@ -26,7 +26,7 @@
 ## Global
 
 ### --snmp-host
-The host (IP or FQDN) of the SNMP trap receiver. Defaults to ``localhost``.
+The host (IPv4, IPv6 or FQDN) of the SNMP trap receiver. Defaults to 
``localhost``.
 
 ### --snmp-port
 The port of the SNMP trap receiver. Defaults to ``162``.
@@ -65,6 +65,9 @@
 ### --trap-default-oid
 The trap OID if none is found in the Prometheus alert labels. Defaults to 
``1.3.6.1.4.1.50495.15.1.2.1``.
 
+### --trap-default-severity
+The trap severity if none is found in the Prometheus alert labels. Defaults to 
an empty string.
+
 ## Command ``run``
 
 ### --host
@@ -96,7 +99,13 @@
 ```
 
 # Global configuration file
-The Prometheus Alertmanager receiver can be configured via configuration file, 
too. The file ``/etc/prometheus-webhook-snmp.conf`` is written in YAML format. 
Parameters in this file have precedence over default configuration settings. 
Please replace hyphens in parameter names with underscores.
+The Prometheus Alertmanager receiver can be configured via configuration file, 
too.
+Command line arguments have precedence over the settings in the configuration 
file.
+The configuration file is written in YAML format. The file will be loaded in 
the
+following order and precedence from ``/etc/prometheus-webhook-snmp.conf`` and 
the 
+directory in which the prometheus-webhook-snmp command is located.
+Parameters in these files have precedence over default configuration settings.
+Please replace hyphens in parameter names with underscores.
 
 Example configuration:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/debian/changelog 
new/prometheus-webhook-snmp-1.3/debian/changelog
--- old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/debian/changelog        
2019-05-14 17:09:27.643504043 +0200
+++ new/prometheus-webhook-snmp-1.3/debian/changelog    2020-03-25 
09:48:10.000000000 +0100
@@ -1,6 +1,15 @@
+prometheus-webhook-snmp (1.2-1) stable; urgency=low
+
+  * Show used configuration settings in debug mode.
+
+ -- Volker Theile <[email protected]>  Thu, 16 May 2019 14:04:41 +0200
+
 prometheus-webhook-snmp (1.1-1) stable; urgency=low
 
-  * Add support for global configuration file.
+  * Add support for global configuration file /etc/prometheus-webhook-snmp.conf
+  * Add ability to configure systemd service via 
/etc/default/prometheus-webhook-snmp
+  * Added python3-PyYAML as new dependency
+  * python3-pysnmp needs to be at least 4.4.1
 
  -- Volker Theile <[email protected]>  Mon, 13 May 2019 16:01:19 +0200
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus-webhook-snmp 
new/prometheus-webhook-snmp-1.3/prometheus-webhook-snmp
--- old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus-webhook-snmp 
2019-05-14 17:09:27.643504043 +0200
+++ new/prometheus-webhook-snmp-1.3/prometheus-webhook-snmp     2020-03-25 
09:48:10.000000000 +0100
@@ -8,19 +8,19 @@
 from prometheus_webhook_snmp import utils
 
 
-__version__ = "1.1"
+__version__ = "1.3"
 
 
 pass_context = click.make_pass_decorator(utils.Context, ensure=True)
 
 
 @click.group(help='Prometheus Alertmanager receiver that translates '
-                  'notifications into SNMP traps.')
+                  'notifications into SNMP v2c traps.')
 @click.option('--debug',
               is_flag=True,
               help='Enable debug output.')
 @click.option('--snmp-host',
-              help='The host (IP or FQDN) of the SNMP trap receiver.')
+              help='The host (IPv4, IPv6 or FQDN) of the SNMP trap receiver.')
 @click.option('--snmp-port',
               help='The port of the SNMP trap receiver.')
 @click.option('--snmp-community',
@@ -35,10 +35,13 @@
               help='The OID prefix for trap variable bindings.')
 @click.option('--trap-default-oid',
               help='The trap OID if none is found in the Prometheus alert 
labels.')
[email protected]('--trap-default-severity',
+              help='The trap severity if none is found in the Prometheus alert 
labels.')
 @click.version_option(__version__, message="%(version)s")
 @pass_context
 def cli(ctx, debug, snmp_host, snmp_port, snmp_community, snmp_retries,
-        snmp_timeout, alert_oid_label, trap_oid_prefix, trap_default_oid):
+        snmp_timeout, alert_oid_label, trap_oid_prefix, trap_default_oid,
+        trap_default_severity):
     ctx.config.load(click.get_current_context().info_name)
     ctx.config['debug'] = True if debug else None
     ctx.config['snmp_host'] = snmp_host
@@ -48,6 +51,7 @@
     ctx.config['snmp_timeout'] = snmp_timeout
     ctx.config['alert_oid_label'] = alert_oid_label
     ctx.config['trap_default_oid'] = trap_default_oid
+    ctx.config['trap_default_severity'] = trap_default_severity
     ctx.config['trap_oid_prefix'] = trap_oid_prefix
 
     if ctx.config['debug']:
@@ -69,6 +73,7 @@
     ctx.config['host'] = host
     ctx.config['port'] = port
     ctx.config['metrics'] = True if metrics else None
+    ctx.config.dump()
     utils.run_http_server(ctx)
     sys.exit(0)
 
@@ -76,6 +81,7 @@
 @cli.command(name='test', help='Trigger a SNMP trap.')
 @pass_context
 def test(ctx):
+    ctx.config.dump()
     trap_data = utils.parse_notification(ctx.config, {
         'receiver': 'bar',
         'status': 'firing',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus-webhook-snmp.spec
 new/prometheus-webhook-snmp-1.3/prometheus-webhook-snmp.spec
--- 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus-webhook-snmp.spec
    2019-05-14 17:09:28.023504043 +0200
+++ new/prometheus-webhook-snmp-1.3/prometheus-webhook-snmp.spec        
2020-03-25 09:48:10.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package prometheus-webhook-snmp
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019-2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,17 +15,13 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 
 Name:           prometheus-webhook-snmp
-Version:        1.1+1557846568.ga2ef545
+Version:        1.3
 Release:        0
 Summary:        Prometheus Alertmanager receiver for SNMP traps
 License:        GPL-3.0
 Group:          System/Management
 Url:            https://github.com/SUSE/prometheus-webhook-snmp
 Source0:        %{name}-%{version}.tar.gz
-%if 0%{?suse_version}
-Source98:       checkin.sh
-Source99:       README-checkin.txt
-%endif
 BuildArch:      noarch
 
 BuildRequires:  python3-setuptools
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus_webhook_snmp/utils.py
 new/prometheus-webhook-snmp-1.3/prometheus_webhook_snmp/utils.py
--- 
old/prometheus-webhook-snmp-1.1+1557846568.ga2ef545/prometheus_webhook_snmp/utils.py
        2019-05-14 17:09:27.643504043 +0200
+++ new/prometheus-webhook-snmp-1.3/prometheus_webhook_snmp/utils.py    
2020-03-25 09:48:10.000000000 +0100
@@ -2,6 +2,8 @@
 import ipaddress
 import json
 import logging
+import os
+import sys
 
 import cherrypy
 import dateutil.parser
@@ -15,6 +17,35 @@
 
 def parse_notification(config, notification):
     """
+    Parse the Alertmanager notification.
+
+    Example:
+    {
+      "receiver": "storage",
+      "status": "firing",
+      "alerts": [
+        {
+          "status": "firing",
+          "labels": {
+            "alertname": "OSD down",
+            "monitor": "ses",
+            "oid": "1.3.6.1.4.1.50495.15.1.2.4.2",
+            "severity": "warning",
+            "type": "ceph_default"
+          },
+          "annotations": {
+            "description": "One or more OSDs down for more than 15 minutes."
+          },
+          "startsAt": "2020-03-24T10:25:29.689078708-04:00",
+          "endsAt": "0001-01-01T00:00:00Z",
+          "generatorURL": "http://xxxx:9090/graph?g0.expr=...";
+        }
+      ],
+      ...
+    }
+
+    See https://prometheus.io/docs/alerting/configuration/#webhook_config
+
     :param config: The configuration data.
     :type config: dict
     :param notification:
@@ -52,9 +83,10 @@
                                   config['trap_default_oid']),
                 'alertname': alertname,
                 'status': alert['status'],
-                'severity': labels.pop('severity'),
+                'severity': labels.pop('severity',
+                                       config['trap_default_severity']),
                 'instance': labels.pop('instance', None),
-                'job': labels.pop('job'),
+                'job': labels.pop('job', None),
                 'description': summary or description,
                 'labels': labels,
                 'timestamp': timestamp,
@@ -71,7 +103,7 @@
 
 def send_snmp_trap(config, trap_data):
     """
-    Send a SNMP trap.
+    Send a SNMP v2c trap.
     :param config: The configuration data.
     :type config: dict
     :param trap_data:
@@ -182,11 +214,15 @@
             'alert_oid_label': 'oid',
             'trap_oid_prefix': '1.3.6.1.4.1.50495.15',
             'trap_default_oid': '1.3.6.1.4.1.50495.15.1.2.1',
+            'trap_default_severity': '',
             'host': '0.0.0.0',
             'port': 9099,
             'metrics': False
         }
 
+    def dump(self):
+        logger.debug('Configuration settings: %s', json.dumps(self))
+
     def reset(self, name=None):
         """
         Reset to default values. If a name is specified, only the named
@@ -206,13 +242,21 @@
         :param prog_name: The name of the program.
         :type prog_name: str
         """
-        file_name = '/etc/{}.conf'.format(prog_name)
-        try:
-            with open(file_name, 'r') as stream:
-                config = yaml.safe_load(stream)
-                self.update(config)
-        except (IOError, FileNotFoundError):
-            pass
+        file_name = '{}.conf'.format(prog_name)
+        path_names = [
+            os.path.join('/etc', file_name),
+            os.path.join(sys.path[0], file_name)
+        ]
+        for path_name in path_names:
+            try:
+                with open(path_name, 'r') as stream:
+                    config = yaml.safe_load(stream)
+                    # Automatically convert hyphens to underscores.
+                    for key in list(config.keys()):
+                        config[key.replace('-', '_')] = config.pop(key)
+                    self.update(config)
+            except (IOError, FileNotFoundError):
+                pass
 
     def __setitem__(self, key, value):
         """


Reply via email to