[pkg-nagios-changes] [Git][nagios-team/pkg-nagios-plugins-contrib][master] 2 commits: check_chrony: migrate to python3
Bernd Zeimetz
gitlab at salsa.debian.org
Fri May 8 22:35:42 BST 2020
Bernd Zeimetz pushed to branch master at Debian Nagios Maintainer Group / pkg-nagios-plugins-contrib
Commits:
6c9d9177 by Bernd Zeimetz at 2020-05-08T23:30:40+02:00
check_chrony: migrate to python3
- - - - -
6b10aa5c by Bernd Zeimetz at 2020-05-08T23:35:04+02:00
dsa/check_enctropy: convert to python3
- - - - -
4 changed files:
- check_chrony/check_chrony
- + debian/patches/dsa/python2to3
- debian/patches/series
- dsa/control
Changes:
=====================================
check_chrony/check_chrony
=====================================
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Monitor chronyd
#
@@ -83,10 +83,10 @@ chronyc = Popen(
output, error = chronyc.communicate()
if chronyc.returncode > 0:
- print("chronyc failed: {}".format(output))
+ print(("chronyc failed: {}".format(output)))
sys.exit(NAGIOS_STATUS['CRITICAL'])
-output = output.split('\n')
+output = output.decode().split('\n')
parsed_output = {}
for line in output:
@@ -109,21 +109,21 @@ if '00000000' in parsed_output['reference_id']:
sys.exit(NAGIOS_STATUS['CRITICAL'])
if int(parsed_output['stratum']) > options.stratum_critical:
- print(
+ 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(
+ print((
"chrony stratum too high: {} > {}".format(
parsed_output['stratum'],
options.stratum_warning
)
- )
+ ))
sys.exit(NAGIOS_STATUS['WARNING'])
system_time = parsed_output['system_time'].split(' ')
@@ -131,33 +131,33 @@ system_time_diff_ms = float(system_time[0]) * 1000
system_time_desc = ' '.join(system_time[1:])
if (system_time_diff_ms > options.critical):
- print(
+ 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(
+ 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(
+print((
"chrony OK: System Time {}, Stratum {}".format(
parsed_output['system_time'],
parsed_output['stratum'],
)
-)
+))
sys.exit(NAGIOS_STATUS['OK'])
=====================================
debian/patches/dsa/python2to3
=====================================
@@ -0,0 +1,51 @@
+Index: pkg-nagios-plugins-contrib/dsa/checks/dsa-check-entropy
+===================================================================
+--- pkg-nagios-plugins-contrib.orig/dsa/checks/dsa-check-entropy
++++ pkg-nagios-plugins-contrib/dsa/checks/dsa-check-entropy
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+
+ # Copyright 2011 Peter Palfrader
+ # Copyright 2014 Hendrik Koehler
+@@ -46,7 +46,7 @@ if len(args) != 0:
+ sys.exit(4)
+
+ if not os.path.exists(AVAIL):
+- print "File %s does not exist."%(AVAIL)
++ print("File %s does not exist."%(AVAIL))
+ sys.exit(4)
+
+ tries = 0
+@@ -55,26 +55,26 @@ while tries <= options.retries:
+ f = open('/proc/sys/kernel/random/entropy_avail')
+ avail = f.readline().rstrip()
+ if len(avail) == 0:
+- print "Could not read anything from %s"%(AVAIL)
++ print("Could not read anything from %s"%(AVAIL))
+ sys.exit(4)
+ try:
+ avail = int(avail)
+ except ValueError:
+- print "Did not read a number from %s, got '%s' instead"%(AVAIL, avail)
++ print("Did not read a number from %s, got '%s' instead"%(AVAIL, avail))
+ sys.exit(4)
+
+ if avail >= options.watermark:
+ if tries > 0:
+- print "OK: %d bytes in the pool after %d attempts.|entropy=%d bytes"%(avail, tries, avail)
++ print("OK: %d bytes in the pool after %d attempts.|entropy=%d bytes"%(avail, tries, avail))
+ else:
+- print "OK: %d bytes in the pool.|entropy=%d bytes"%(avail, avail)
++ print("OK: %d bytes in the pool.|entropy=%d bytes"%(avail, avail))
+ sys.exit(0)
+
+ values.append(avail)
+ time.sleep(1.0 * options.sleep / 1000)
+ tries += 1
+
+-print "WARNING: Too little entropy in the pool (min: %d, max: %d in %d reads)|entropy=%d bytes"%(min(values), max(values), tries-1, avail)
++print("WARNING: Too little entropy in the pool (min: %d, max: %d in %d reads)|entropy=%d bytes"%(min(values), max(values), tries-1, avail))
+ sys.exit(1)
+
+ # vim:set et:
=====================================
debian/patches/series
=====================================
@@ -56,3 +56,4 @@ check_graphite/python2to3
check_mongodb/python2to3
percona-nagios-plugins/python2to3
check_email_delivery/check_smtp_send-hello
+dsa/python2to3
=====================================
dsa/control
=====================================
@@ -16,5 +16,5 @@ Description: plugins from the Debian System Administrators
* check_soas: check SOA records
* check_statusfile: deliver the content of a status file
as check result
-Recommends: ruby | ruby-interpreter, openssl, libnet-dns-perl, binutils
+Recommends: ruby | ruby-interpreter, openssl, libnet-dns-perl, binutils, python3
Version: 2300473
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/-/compare/060b5b1c006c3387b169d07604d8f85af16a414b...6b10aa5c3dbef37382a137d3308487686558d3cf
--
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-nagios-plugins-contrib/-/compare/060b5b1c006c3387b169d07604d8f85af16a414b...6b10aa5c3dbef37382a137d3308487686558d3cf
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/20200508/5231924d/attachment-0001.html>
More information about the pkg-nagios-changes
mailing list