[pkg-nagios-changes] [Git][nagios-team/pkg-nagios-plugins-contrib][master] 9 commits: Add check_chrony

Bernd Zeimetz gitlab at salsa.debian.org
Thu May 7 11:31:12 BST 2020



Bernd Zeimetz pushed to branch master at Debian Nagios Maintainer Group / pkg-nagios-plugins-contrib


Commits:
360f98c3 by Bernd Zeimetz at 2020-05-06T09:49:04+02:00
Add check_chrony

- - - - -
2191f5e2 by Bernd Zeimetz at 2020-05-06T09:49:04+02:00
Package check_chrony

- - - - -
d2a2f4b4 by Bernd Zeimetz at 2020-05-07T10:36:41+02:00
Migrating check_graphite to python3

- - - - -
43c2d9ae by Bernd Zeimetz at 2020-05-07T10:39:39+02:00
Migrating check_mongodb to python3

- - - - -
76b2a873 by Bernd Zeimetz at 2020-05-07T10:50:47+02:00
Migrating percona-nagios-plugins to python3

- - - - -
c4f0215f by Bernd Zeimetz at 2020-05-07T10:52:02+02:00
Ignore the redhat folder

- - - - -
b832621f by Bernd Zeimetz at 2020-05-07T10:52:04+02:00
Auto update of debian/control

- - - - -
1d1a6689 by Bernd Zeimetz at 2020-05-07T12:21:43+02:00
Depend on python3

- - - - -
b84f5ad6 by Bernd Zeimetz at 2020-05-07T12:30:46+02:00
Auto update of debian/control

- - - - -


14 changed files:

- + check_chrony/Makefile
- + check_chrony/check_chrony
- + check_chrony/control
- check_graphite/control
- check_mongodb/control
- debian/control
- debian/control.in
- debian/packaging-helper.py
- + debian/patches/check_graphite/python2to3
- + debian/patches/check_mongodb/python2to3
- + debian/patches/percona-nagios-plugins/python2to3
- debian/patches/series
- debian/rules
- percona-nagios-plugins/control


Changes:

=====================================
check_chrony/Makefile
=====================================
@@ -0,0 +1 @@
+include ../common.mk


=====================================
check_chrony/check_chrony
=====================================
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+
+# Monitor chronyd
+#
+# Copyright 2019 Bernd Zeimetz <bernd at bzed.de>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+from subprocess import Popen, PIPE
+import optparse
+import sys
+
+broken_example = """Reference ID    : 00000000 ()
+Stratum         : 0
+Ref time (UTC)  : Thu Jan 01 00:00:00 1970
+System time     : 0.000000000 seconds fast of NTP time
+Last offset     : +0.000000000 seconds
+RMS offset      : 0.000000000 seconds
+Frequency       : 8.769 ppm fast
+Residual freq   : +0.000 ppm
+Skew            : 0.000 ppm
+Root delay      : 1.000000000 seconds
+Root dispersion : 1.000000000 seconds
+Update interval : 0.0 seconds
+Leap status     : Not synchronised
+"""
+
+NAGIOS_STATUS = {
+    "OK": 0,
+    "WARNING": 1,
+    "CRITICAL": 2,
+    "UNKNOWN": 3
+}
+
+parser = optparse.OptionParser()
+parser.set_usage("%prog [options]")
+parser.add_option(
+    "-w", "--warning", dest="warning", metavar="WARNING",
+    type="int", default="1000",
+    help="time differences in ms (warning)"
+)
+parser.add_option(
+    "-c", "--critical", dest="critical", metavar="CRITICAL",
+    type="int", default="3000",
+    help="time differences in ms (critical)"
+)
+parser.add_option(
+    "-W", "--stratum-warning", dest="stratum_warning",
+    metavar="STRATUM_WARNING",
+    type="int", default="3",
+    help="maximum stratum level (warning)"
+)
+parser.add_option(
+    "-C", "--stratum-critical", dest="stratum_critical",
+    metavar="STRATUM_CRITICAL",
+    type="int", default="5",
+    help="maximum stratum level (critical)"
+)
+(options, args) = parser.parse_args()
+
+chronyc = Popen(
+    ['chronyc', 'tracking'],
+    stdin=PIPE, stdout=PIPE, stderr=PIPE,
+    bufsize=-1
+)
+output, error = chronyc.communicate()
+
+if chronyc.returncode > 0:
+    print("chronyc failed: {}".format(output))
+    sys.exit(NAGIOS_STATUS['CRITICAL'])
+
+output = output.split('\n')
+parsed_output = {}
+
+for line in output:
+    if ':' not in line:
+        continue
+    line = line.split(':')
+    key = line[0]
+    value = ':'.join(line[1:])
+    key = key.strip()
+    value = value.strip()
+    key = key.replace('(', '')
+    key = key.replace(')', '')
+    key = key.replace(' ', '_')
+    key = key.lower()
+
+    parsed_output[key] = value
+
+if '00000000' in parsed_output['reference_id']:
+    print("chrony failed to connect to NTP server.")
+    sys.exit(NAGIOS_STATUS['CRITICAL'])
+
+if int(parsed_output['stratum']) > options.stratum_critical:
+    print(
+        "chrony stratum too high: {} > {}".format(
+            parsed_output['stratum'],
+            options.stratum_critical
+        )
+    )
+    sys.exit(NAGIOS_STATUS['CRITICAL'])
+
+if int(parsed_output['stratum']) > options.stratum_warning:
+    print(
+        "chrony stratum too high: {} > {}".format(
+            parsed_output['stratum'],
+            options.stratum_warning
+        )
+    )
+    sys.exit(NAGIOS_STATUS['WARNING'])
+
+system_time = parsed_output['system_time'].split(' ')
+system_time_diff_ms = float(system_time[0]) * 1000
+system_time_desc = ' '.join(system_time[1:])
+
+if (system_time_diff_ms > options.critical):
+    print(
+        "chrony system time {}ms {}. ({}ms > {}ms)".format(
+            system_time_diff_ms,
+            system_time_desc,
+            system_time_diff_ms,
+            options.critical
+        )
+    )
+    sys.exit(NAGIOS_STATUS['CRITICAL'])
+
+if (system_time_diff_ms > options.warning):
+    print(
+        "chrony system time {}ms {}. ({}ms > {}ms)".format(
+            system_time_diff_ms,
+            system_time_desc,
+            system_time_diff_ms,
+            options.warning
+        )
+    )
+    sys.exit(NAGIOS_STATUS['WARNING'])
+
+
+print(
+    "chrony OK: System Time {}, Stratum {}".format(
+        parsed_output['system_time'],
+        parsed_output['stratum'],
+    )
+)
+sys.exit(NAGIOS_STATUS['OK'])
+


=====================================
check_chrony/control
=====================================
@@ -0,0 +1,5 @@
+Uploaders: Bernd Zeimetz <bzed at debian.org>
+Description: chrony NTP server check
+ This plugin is able to check the stratum time difference of a local
+ chronyd instance.
+Version: 0.1


=====================================
check_graphite/control
=====================================
@@ -1,4 +1,4 @@
 Uploaders: Bernd Zeimetz <bzed at debian.org>
 Description: Plugin to monitor graphite metrics
 Homepage: https://github.com/disqus/nagios-plugins
-Recommends: python
+Recommends: python3


=====================================
check_mongodb/control
=====================================
@@ -1,5 +1,5 @@
 Uploaders: Jan Wagner <waja at cyconet.org>
-Recommends: python-pymongo
+Recommends: python3, python3-pymongo
 Version: b33e763
 Homepage: https://github.com/mzupan/nagios-plugin-mongodb
 Watch: https://github.com/mzupan/nagios-plugin-mongodb <a class="commit-tease-sha"[^>]*>\s+([0-9a-f]+)\s+</a>


=====================================
debian/control
=====================================
@@ -5,7 +5,6 @@ Maintainer: Debian Nagios Maintainer Group <pkg-nagios-devel at lists.alioth.debian
 Uploaders: Bernd Zeimetz <bzed at debian.org>, Jan Wagner <waja at cyconet.org>, Stefan Schoerghofer <amd1212 at 4md.gr>, Petter Reinholdtsen <pere at hungry.com>, Leo Antunes <leo at costela.net>
 Build-Depends: debhelper (>= 8.0.0),
                dh-autoreconf,
-               python,
                python3, python3-debian,
                quilt (>= 0.46-7),
                autotools-dev, flex, libmemcached-dev [!hurd-i386], pkg-config
@@ -16,11 +15,11 @@ Vcs-Browser: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib
 Package: nagios-plugins-contrib
 Architecture: any
 Depends: ${misc:Depends}
-Recommends: libsocket-perl, libmonitoring-plugin-perl | libnagios-plugin-perl, libnet-snmp-perl, whois, nagios-plugins-basic, libnet-dns-perl, libdate-manip-perl, libmonitoring-plugin-perl | libnagios-plugin-perl (>= 0.31), libnet-cups-perl, debsecan, libio-socket-ssl-perl, libmail-imapclient-perl, libnet-smtp-tls-perl, libnet-smtp-ssl-perl, libnet-ssleay-perl, libnet-smtpauth-perl, bind9-host | knot-host, python, liblocale-gettext-perl, liblwp-useragent-determined-perl, snmp, freeipmi-tools, libipc-run-perl, lsof, libyaml-syck-perl, libxml-simple-perl, python-pymongo, libdbd-mysql-perl, libreadonly-perl, libdata-validate-domain-perl, libdata-validate-ip-perl, libredis-perl, libnet-snmp-perl (>= 5), libtimedate-perl, curl, file, openssl, libwebinject-perl, libnet-dns-sec-perl, ruby | ruby-interpreter, binutils,
+Recommends: libsocket-perl, libmonitoring-plugin-perl | libnagios-plugin-perl, libnet-snmp-perl, whois, nagios-plugins-basic, libnet-dns-perl, libdate-manip-perl, libmonitoring-plugin-perl | libnagios-plugin-perl (>= 0.31), libnet-cups-perl, debsecan, libio-socket-ssl-perl, libmail-imapclient-perl, libnet-smtp-tls-perl, libnet-smtp-ssl-perl, libnet-ssleay-perl, libnet-smtpauth-perl, bind9-host | knot-host, python3, liblocale-gettext-perl, liblwp-useragent-determined-perl, snmp, freeipmi-tools, libipc-run-perl, lsof, libyaml-syck-perl, libxml-simple-perl, python3-pymongo, libdbd-mysql-perl, libreadonly-perl, libdata-validate-domain-perl, libdata-validate-ip-perl, libredis-perl, libnet-snmp-perl (>= 5), libtimedate-perl, curl, file, openssl, libwebinject-perl, libnet-dns-sec-perl, ruby | ruby-interpreter, binutils,
             ${perl:Depends},
             ${python:Depends},
             ${shlibs:Depends}
-Suggests: backuppc, perl-doc, libsys-virt-perl, cciss-vol-status (>= 1.10), mpt-status, smstools (>= 3~), expect, nagios-plugin-check-multi, moreutils, percona-toolkit, python2.7, python-pymongo
+Suggests: backuppc, perl-doc, libsys-virt-perl, cciss-vol-status (>= 1.10), mpt-status, smstools (>= 3~), expect, nagios-plugin-check-multi, moreutils, percona-toolkit, python3, python3-pymongo, python3-boto
 Enhances: nagios-plugins, nagios-plugins-basic, nagios-plugins-standard
 Description: Plugins for nagios compatible monitoring systems
  This package provides various plugins for Nagios compatible monitoring
@@ -36,6 +35,9 @@ Description: Plugins for nagios compatible monitoring systems
    * check_checksums (20130611): plugin to verify file checksums
      against (local, not 100% secure) lists.
      Supports md5 sha1 sha224 sha256 sha384 sha512 checksums.
+   * check_chrony (0.1): chrony NTP server check
+     This plugin is able to check the stratum time difference of a local
+     chronyd instance.
    * check_clamav (1.2): plugin to check for clamav signature freshness
      This script is used to compare the version and signature
      level of the currently running clamd daemon with the latest


=====================================
debian/control.in
=====================================
@@ -5,7 +5,6 @@ Maintainer: Debian Nagios Maintainer Group <pkg-nagios-devel at lists.alioth.debian
 Uploaders: #AUTO_UPDATE_Uploaders#
 Build-Depends: debhelper (>= 8.0.0),
                dh-autoreconf,
-               python,
                python3, python3-debian,
                quilt (>= 0.46-7),
                #AUTO_UPDATE_Build-Depends#


=====================================
debian/packaging-helper.py
=====================================
@@ -24,7 +24,7 @@ ALLOWED_TESTS_FIELDS = ('Depends',
 # find all plugins
 __basedir__ = os.path.realpath(os.path.dirname(sys.argv[0]) + os.path.sep + '..')
 __plugins__ = [p for p in os.listdir(__basedir__) 
-                   if (os.path.isdir(__basedir__ + os.path.sep + p) and p!='debian' and p!='.git' and p!='.pc')]
+                   if (os.path.isdir(__basedir__ + os.path.sep + p) and p!='debian' and p!='.git' and p!='.pc' and p!='redhat')]
 __plugins__.sort()
 
 


=====================================
debian/patches/check_graphite/python2to3
=====================================
@@ -0,0 +1,113 @@
+Index: pkg-nagios-plugins-contrib/check_graphite/check_graphite.py
+===================================================================
+--- pkg-nagios-plugins-contrib.orig/check_graphite/check_graphite.py
++++ pkg-nagios-plugins-contrib/check_graphite/check_graphite.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ """
+ check_graphite.py
+ ~~~~~~~
+@@ -9,8 +9,8 @@ check_graphite.py
+ 
+ import json
+ import optparse
+-import urllib
+-import urllib2
++import urllib.request, urllib.parse, urllib.error
++import urllib.request, urllib.error, urllib.parse
+ import sys
+ 
+ from numbers import Real
+@@ -34,7 +34,7 @@ class Graphite(object):
+             [('until', self._until)] +\
+             [('format', 'json')]
+         self.full_url = self.url + '/render?' +\
+-            urllib.urlencode(params)
++            urllib.parse.urlencode(params)
+ 
+     def check_datapoints(self, datapoints, check_func, **kwargs):
+         """Find alerting datapoints
+@@ -56,19 +56,19 @@ class Graphite(object):
+             return [x for x in datapoints if isinstance(x, Real) and check_func(x, kwargs['threshold'])]
+         elif 'bounds' in kwargs:
+             if 'compare' in kwargs:
+-              return [datapoints[x] for x in xrange(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x], kwargs['compare'][x]]) and check_func(datapoints[x] / kwargs['bounds'][x], kwargs['beyond']) and check_func(datapoints[x], kwargs['compare'][x])]
++              return [datapoints[x] for x in range(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x], kwargs['compare'][x]]) and check_func(datapoints[x] / kwargs['bounds'][x], kwargs['beyond']) and check_func(datapoints[x], kwargs['compare'][x])]
+             else:
+-                return [datapoints[x] for x in xrange(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x]]) and check_func(datapoints[x], kwargs['bounds'][x])]
++                return [datapoints[x] for x in range(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x]]) and check_func(datapoints[x], kwargs['bounds'][x])]
+ 
+     def fetch_metrics(self):
+         try:
+-            response = urllib2.urlopen(self.full_url)
++            response = urllib.request.urlopen(self.full_url)
+ 
+             if response.code != 200:
+                 return None
+             else:
+                 return json.loads(response.read())
+-        except urllib2.URLError, TypeError:
++        except urllib.error.URLError as TypeError:
+             return None
+ 
+     def generate_output(self, datapoints, *args, **kwargs):
+@@ -210,7 +210,7 @@ if __name__ == '__main__':
+             warn = float(options.warning)
+             crit = float(options.critical)
+         except ValueError:
+-            print 'ERROR: WARNING or CRITICAL threshold is not a number\n'
++            print('ERROR: WARNING or CRITICAL threshold is not a number\n')
+             parser.print_help()
+             sys.exit(NAGIOS_STATUSES['UNKNOWN'])
+ 
+@@ -234,7 +234,7 @@ if __name__ == '__main__':
+                 kwargs['compare'] = [x[0] for x in metric_data[3].get('datapoints', [])][from_slice:]
+ 
+                 if not graphite.has_numbers(kwargs['compare']):
+-                    print 'CRITICAL: No compare target output from Graphite!'
++                    print('CRITICAL: No compare target output from Graphite!')
+                     sys.exit(NAGIOS_STATUSES['CRITICAL'])
+ 
+             if graphite.has_numbers(actual) and graphite.has_numbers(kwargs['bounds']):
+@@ -245,13 +245,13 @@ if __name__ == '__main__':
+                                                                      target=target_name)
+ 
+             else:
+-                print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
++                print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
+                 sys.exit(NAGIOS_STATUSES['CRITICAL'])
+         else:
+             for target in metric_data:
+                 datapoints = [x[0] for x in target.get('datapoints', []) if isinstance(x[0], Real)]
+                 if not graphite.has_numbers(datapoints) and not options.empty_ok:
+-                    print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
++                    print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
+                     sys.exit(NAGIOS_STATUSES['CRITICAL'])
+ 
+                 crit_oob = graphite.check_datapoints(datapoints, check_func, threshold=crit)
+@@ -265,13 +265,13 @@ if __name__ == '__main__':
+                                                                           critical=crit)
+     else:
+         if options.empty_ok and isinstance(metric_data, list):
+-            print 'OK: No output from Graphite for target(s): %s' % ', '.join(targets)
++            print('OK: No output from Graphite for target(s): %s' % ', '.join(targets))
+             sys.exit(NAGIOS_STATUSES['OK'])
+ 
+-        print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
++        print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
+         sys.exit(NAGIOS_STATUSES['CRITICAL'])
+ 
+-    for target, messages in check_output.iteritems():
++    for target, messages in check_output.items():
+         if messages['CRITICAL']:
+             exit_code = NAGIOS_STATUSES['CRITICAL']
+         elif messages['WARNING']:
+@@ -281,6 +281,6 @@ if __name__ == '__main__':
+ 
+         for status_code in ['CRITICAL', 'WARNING', 'OK']:
+             if messages[status_code]:
+-                print '\n'.join(['%s: %s' % (status_code, status) for status in messages[status_code]])
++                print('\n'.join(['%s: %s' % (status_code, status) for status in messages[status_code]]))
+ 
+     sys.exit(exit_code)


=====================================
debian/patches/check_mongodb/python2to3
=====================================
@@ -0,0 +1,45 @@
+Index: pkg-nagios-plugins-contrib/check_mongodb/check_mongodb.py
+===================================================================
+--- pkg-nagios-plugins-contrib.orig/check_mongodb/check_mongodb.py
++++ pkg-nagios-plugins-contrib/check_mongodb/check_mongodb.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ 
+ #
+ # A MongoDB Nagios check script
+@@ -26,8 +26,8 @@
+ # See the README.md
+ #
+ 
+-from __future__ import print_function
+-from __future__ import division
++
++
+ import sys
+ import time
+ import optparse
+@@ -1137,9 +1137,9 @@ def check_queries_per_second(con, query_
+ 
+             # update the count now
+             if mongo_version == 2:
+-                db.nagios_check.update({u'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
++                db.nagios_check.update({'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
+             else:
+-                db.nagios_check.update_one({u'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
++                db.nagios_check.update_one({'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
+ 
+             message = "Queries / Sec: %f" % query_per_sec
+             message += performance_data(perf_data, [(query_per_sec, "%s_per_sec" % query_type, warning, critical, message)])
+@@ -1149,9 +1149,9 @@ def check_queries_per_second(con, query_
+             query_per_sec = 0
+             message = "First run of check.. no data"
+             if mongo_version == 2:
+-                db.nagios_check.update({u'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
++                db.nagios_check.update({'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
+             else:
+-                db.nagios_check.update_one({u'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
++                db.nagios_check.update_one({'_id': last_count['_id']}, {'$set': {"data.%s" % query_type: {'count': num, 'ts': int(time.time())}}})
+ 
+         except TypeError:
+             #


=====================================
debian/patches/percona-nagios-plugins/python2to3
=====================================
@@ -0,0 +1,206 @@
+Index: pkg-nagios-plugins-contrib/percona-nagios-plugins/nagios/bin/pmp-check-aws-rds.py
+===================================================================
+--- pkg-nagios-plugins-contrib.orig/percona-nagios-plugins/nagios/bin/pmp-check-aws-rds.py
++++ pkg-nagios-plugins-contrib/percona-nagios-plugins/nagios/bin/pmp-check-aws-rds.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ """Nagios plugin for Amazon RDS monitoring.
+ 
+ This program is part of $PROJECT_NAME$
+@@ -98,7 +98,7 @@ def debug(val):
+     """Debugging output"""
+     global options
+     if options.debug:
+-        print 'DEBUG: %s' % val
++        print('DEBUG: %s' % val)
+ 
+ 
+ def main():
+@@ -166,7 +166,7 @@ def main():
+     parser.add_option('-i', '--ident', help='DB instance identifier')
+     parser.add_option('-p', '--print', help='print status and other details for a given DB instance',
+                       action='store_true', default=False, dest='printinfo')
+-    parser.add_option('-m', '--metric', help='metric to check: [%s]' % ', '.join(metrics.keys()))
++    parser.add_option('-m', '--metric', help='metric to check: [%s]' % ', '.join(list(metrics.keys())))
+     parser.add_option('-w', '--warn', help='warning threshold')
+     parser.add_option('-c', '--crit', help='critical threshold')
+     parser.add_option('-u', '--unit', help='unit of thresholds for "storage" and "memory" metrics: [%s].'
+@@ -193,7 +193,7 @@ def main():
+         sys.exit()
+     elif options.db_list:
+         info = rds.get_list()
+-        print 'List of all DB instances in %s region(s):' % (options.region,)
++        print('List of all DB instances in %s region(s):' % (options.region,))
+         pprint.pprint(info)
+         sys.exit()
+     elif not options.ident:
+@@ -204,10 +204,10 @@ def main():
+         if info:
+             pprint.pprint(vars(info))
+         else:
+-            print 'No DB instance "%s" found on your AWS account and %s region(s).' % (options.ident, options.region)
++            print('No DB instance "%s" found on your AWS account and %s region(s).' % (options.ident, options.region))
+ 
+         sys.exit()
+-    elif not options.metric or options.metric not in metrics.keys():
++    elif not options.metric or options.metric not in list(metrics.keys()):
+         parser.print_help()
+         parser.error('Metric is not set or not valid.')
+     elif not options.warn and options.metric != 'status':
+@@ -327,7 +327,7 @@ def main():
+                 try:
+                     storage = db_classes[info.instance_class]
+                 except:
+-                    print 'Unknown DB instance class "%s"' % info.instance_class
++                    print('Unknown DB instance class "%s"' % info.instance_class)
+                     sys.exit(CRITICAL)
+ 
+             free = '%.2f' % (free / 1024 ** 3)
+@@ -353,12 +353,12 @@ def main():
+ 
+     # Final output
+     if status != UNKNOWN and perf_data:
+-        print '%s %s | %s' % (short_status[status], note, perf_data)
++        print('%s %s | %s' % (short_status[status], note, perf_data))
+     elif status == UNKNOWN and not options.forceunknown:
+-        print '%s %s | null' % ('OK', note)
++        print('%s %s | null' % ('OK', note))
+         sys.exit(0)
+     else:
+-        print '%s %s' % (short_status[status], note)
++        print('%s %s' % (short_status[status], note))
+ 
+     sys.exit(status)
+ 
+Index: pkg-nagios-plugins-contrib/percona-nagios-plugins/nagios/bin/pmp-check-mongo.py
+===================================================================
+--- pkg-nagios-plugins-contrib.orig/percona-nagios-plugins/nagios/bin/pmp-check-mongo.py
++++ pkg-nagios-plugins-contrib/percona-nagios-plugins/nagios/bin/pmp-check-mongo.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python2.7
++#!/usr/bin/env python3
+ """MongoDB Nagios check script
+ 
+ This program is part of $PROJECT_NAME$
+@@ -23,8 +23,8 @@ from types import FunctionType
+ 
+ try:
+     import pymongo
+-except ImportError, e:
+-    print e
++except ImportError as e:
++    print(e)
+     sys.exit(2)
+ 
+ # As of pymongo v 1.9 the SON API is part of the BSON package, therefore attempt
+@@ -51,7 +51,7 @@ def unicode_truncate(s, length, encoding
+ 
+ def parse_options(args):
+     funcList = []
+-    for item_name, item_type in NagiosMongoChecks.__dict__.items():
++    for item_name, item_type in list(NagiosMongoChecks.__dict__.items()):
+         if type(item_type) is FunctionType and item_name.startswith("check_") and item_name is not 'check_levels':
+             funcList.append(item_name)
+     p = ModifiedOptionParser()
+@@ -76,7 +76,7 @@ def parse_options(args):
+     # Add options for output stat file
+     try:
+         result = p.parse_args()
+-    except OptionParsingError, e:
++    except OptionParsingError as e:
+         if 'no such option' in e.msg:
+             sys.exit("UNKNOWN - No such options of %s" % e.msg.split(":")[1])
+         if 'invalid choice' in e.msg:
+@@ -87,16 +87,16 @@ def parse_options(args):
+ 
+ def return_result(result_type, message):
+     if result_type == "ok":
+-        print "OK - " + message
++        print("OK - " + message)
+         sys.exit(0)
+     elif result_type == "critical":
+-        print "CRITICAL - " + message
++        print("CRITICAL - " + message)
+         sys.exit(2)
+     elif result_type == "warning":
+-        print "WARNING - " + message
++        print("WARNING - " + message)
+         sys.exit(1)
+     else:
+-        print "UNKNOWN - " + message
++        print("UNKNOWN - " + message)
+         sys.exit(2)
+ 
+ 
+@@ -110,9 +110,9 @@ def check(args, check_name):
+         checksObj = globals()['NagiosMongoChecks'](args)
+         run_check = getattr(checksObj, check_name)
+         result_type, message = run_check(args, args.warning, args.critical)
+-    except Exception, e:
++    except Exception as e:
+         raise
+-        print(traceback.extract_tb(sys.exc_info()[-1], 1))
++        print((traceback.extract_tb(sys.exc_info()[-1], 1)))
+         return_result("critical", str(e))
+     return_result(result_type, message)
+ 
+@@ -193,7 +193,7 @@ class NagiosMongoChecks:
+         except:
+             try:
+ 		data = self.connection['admin'].command(son.SON([('serverStatus', 1)]))
+-	    except Exception, e:
++	    except Exception as e:
+ 		if type(e).__name__ == "OperationFailure":
+ 		    sys.exit("UNKNOWN - Not authorized!")
+ 		else:
+@@ -222,7 +222,7 @@ class NagiosMongoChecks:
+     def save_file(self, filename, contents):
+             try:
+                 pickle.dump(contents, open(filename, "wb"))
+-            except Exception, e:
++            except Exception as e:
+                 sys.exit("UNKNOWN - Error saving stat file %s: %s" % (filename, e.message))
+ 
+     # TODO - Fill in all check defaults
+@@ -280,19 +280,19 @@ class NagiosMongoChecks:
+                 con = pymongo.MongoClient(self.host, self.port, ssl=self.ssl, replicaSet=self.replicaset, serverSelectionTimeoutMS=2500)
+             if (self.user and self.passwd) and not con['admin'].authenticate(self.user, self.passwd):
+                 sys.exit("CRITICAL - Username and password incorrect")
+-        except Exception, e:
++        except Exception as e:
+             raise
+             if isinstance(e, pymongo.errors.AutoReconnect) and str(e).find(" is an arbiter") != -1:
+                 # We got a pymongo AutoReconnect exception that tells us we connected to an Arbiter Server
+                 # This means: Arbiter is reachable and can answer requests/votes - this is all we need to know from an arbiter
+-                print "OK - State: 7 (Arbiter)"
++                print("OK - State: 7 (Arbiter)")
+                 sys.exit(0)
+             con = None
+             self.pyMongoError = str(e)
+         if con is not None:
+ 	    try:
+                 con['admin'].command(pymongo.son_manipulator.SON([('ping', 1)]))
+-            except Exception, e:
++            except Exception as e:
+                 sys.exit("UNKNOWN - Unable to run commands, possible auth issue: %s" % e.message)
+             self.connection_time = round(time.time() - start_time, 2)
+             version = con.server_info()['version'].split('.')
+@@ -478,7 +478,7 @@ class NagiosMongoChecks:
+             time_range = (time.time() - start).total_seconds
+             message = "Collection %s.%s  query took: %d s" % (self.database, self.collection, time_range)
+             return self.check_levels(time_range, warning_level, critical_level, message)
+-        except Exception, e:
++        except Exception as e:
+             message = "Collection %s.%s  query FAILED: %s" % (self.database, self.collection, e)
+             return "critical", message
+ 
+@@ -491,7 +491,7 @@ class NagiosMongoChecks:
+         # get a  fresh status for the replset
+         try:
+             replset_status = self.connection['admin'].command("replSetGetStatus")
+-        except Exception, e:
++        except Exception as e:
+             return "critical", "Are your running with --replset? -  %s" % (e)
+ 
+         for member in replset_status['members']:


=====================================
debian/patches/series
=====================================
@@ -52,3 +52,6 @@ check_nfsmounts/nfs4_support
 check_httpd_status/htdigest_auth
 check_raid/no_epn
 percona-nagios-plugins/fix_bashism
+check_graphite/python2to3
+check_mongodb/python2to3
+percona-nagios-plugins/python2to3


=====================================
debian/rules
=====================================
@@ -5,10 +5,7 @@
 export DH_VERBOSE=1
 
 PKGNAME = nagios-plugins-contrib
-PLUGINS := $(shell find $(CURDIR) -mindepth 1 -maxdepth 1 -name .git -prune -o -name .pc -prune -o -name debian -prune -o -type d -printf '%f\n' | sort)
-
-%:
-	dh $@ --with quilt,python2
+PLUGINS := $(shell find $(CURDIR) -mindepth 1 -maxdepth 1 -name .git -prune -o -name redhat -prune -o -name .pc -prune -o -name debian -prune -o -type d -printf '%f\n' | sort)
 
 override_dh_auto_build:
 	dh_auto_build
@@ -37,6 +34,10 @@ debian/tests/control: debian/packaging-helper.py $(TESTS_FILES)
 	-if [ -d .git ]; then git add $@; git commit -m 'Auto update of $@' $@; fi
 
 
+%:
+	dh $@ --with quilt,python2
+
+
 watch:
 	@$(PACKAGING_HELPER) --watch
 


=====================================
percona-nagios-plugins/control
=====================================
@@ -4,4 +4,4 @@ Homepage: http://www.percona.com/doc/percona-monitoring-plugins/
 Uploaders: Bernd Zeimetz <bzed at debian.org>
 Description: Percona Monitoring Plugins (nagios)
  Nagios MySQL Monitoring plugins writting/provided by Percona.
-Suggests: percona-toolkit, python2.7, python-pymongo
+Suggests: percona-toolkit, python3, python3-pymongo, python3-boto



View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/-/compare/52e6b0745643794271b86c6ba101925e71431329...b84f5ad6aeaf211dcc4fa72bcc91ce83ca5a44a1

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/-/compare/52e6b0745643794271b86c6ba101925e71431329...b84f5ad6aeaf211dcc4fa72bcc91ce83ca5a44a1
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20200507/64143aa0/attachment-0001.html>


More information about the pkg-nagios-changes mailing list