]> git.michaelhowe.org Git - packages/n/nagios-plugins-local.git/commitdiff
Update server plugins to be python3 compatible
authorMichael Howe <michael@michaelhowe.org>
Tue, 21 Dec 2021 10:07:42 +0000 (10:07 +0000)
committerMichael Howe <michael@michaelhowe.org>
Tue, 21 Dec 2021 10:07:42 +0000 (10:07 +0000)
debian/changelog
debian/control
plugins/check_owntracks

index fff8674724aaf2b219551f63e6e5b65ca6957ce6..6db357258c96bcb4c4c5f77a116b3bd3f41547e4 100644 (file)
@@ -1,3 +1,9 @@
+nagios-plugins-local (0.24) unstable; urgency=medium
+
+  * Update nagios-plugins-local-server checks to support python3 
+
+ -- Michael Howe <michael@michaelhowe.org>  Tue, 21 Dec 2021 10:07:23 +0000
+
 nagios-plugins-local (0.23) unstable; urgency=medium
 
   * Fix postrm 
index 72eeaf1e28d0438fa5248d54d426c20b20689d6a..5ebadaa483f00ece1148bd43beb9a973c60760fb 100644 (file)
@@ -17,14 +17,13 @@ Package: nagios-plugins-local-server
 Architecture: any
 Depends: ${misc:Depends},
  perl, 
- python,
+ python3,
  libc6,
  libnet-telnet-perl,
  libregexp-common-perl,
  libauthen-krb5-perl,
  nagios-plugins-local-client (= ${source:Version})
- , python-requests
-# check_mqtt
+ , python3-requests
  , python3-paho-mqtt
 Breaks: nagios-plugins-local (<0.11)
 Description: Local nagios plugins
index 81ca82190c90edfb88518012f1e04651670500d9..e10020b96224ea858f9a2666fed4640b37b342f8 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 # From <https://github.com/owntracks/recorder/tree/master/contrib/ot-ping.py>
 
@@ -24,9 +24,9 @@ __license__ = 'MIT'
 
 parser = argparse.ArgumentParser()
 parser.add_argument('-M', '--mqtt-hostname', metavar='<mqtt_hostname>', help='mqtt host to connect to (defaults to localhost)', dest='mqtt_hostname', default='localhost')
-parser.add_argument('-P', '--mqtt-port', metavar='<mqtt_port>', help='mqtt port to connect to (defaults to 1883)', dest='mqtt_port', default=1883)
+parser.add_argument('-P', '--mqtt-port', metavar='<mqtt_port>', help='mqtt port to connect to (defaults to 1883)', dest='mqtt_port', default=1883, type=int)
 parser.add_argument('-H', '--recorder-hostname', metavar='<recorder_hostname>', help='recorder host to connect to (defaults to localhost)', dest='recorder_hostname', default='localhost')
-parser.add_argument('-p', '--recorder-port', metavar='<recorder_port>', help='recorder port to connect to (defaults to 8083)', dest='recorder_port', default='8083')
+parser.add_argument('-p', '--recorder-port', metavar='<recorder_port>', help='recorder port to connect to (defaults to 8083)', dest='recorder_port', default='8083', type=int)
 parser.add_argument('-U', '--recorder-url', metavar='<recorder_url>', help='url path to recorder (defaults to /)', dest='recorder_url', default='/')
 parser.add_argument('-r', '--recorder-protocol', metavar='<recorder_protocol>', help='protocol to access recorder (defaults to http)', dest='recorder_protocol', default='http')
 parser.add_argument('-u', '--username', metavar='<username>', help='mqtt username to use (defaults to none)', dest='username', default=None)
@@ -95,7 +95,7 @@ def pingping(tics):
                 auth=auth,
                 tls=tls,
                 **params)
-    except Exception, e:
+    except Exception as e:
         status = CRITICAL
         msg = msg + " mqtt failed: " + str(e)
 
@@ -113,7 +113,7 @@ def check_response(url, tics):
     try:
         r = requests.post(url + "/api/0/last", params= { 'user' : 'ping', 'device' : 'ping' })
         data = json.loads(r.text)[0]    # Return is an array
-    except Exception, e:
+    except Exception as e:
         return CRITICAL, "check_response failed: " + str(e)
 
     tst = data['tst']
@@ -132,7 +132,7 @@ if __name__ == '__main__':
 
     status, msg = pingping(tics)
     if status != OK:
-        print "%s ot-recorder pingping failed: %s" % (codes[status], msg)
+        print("%s ot-recorder pingping failed: %s" % (codes[status], msg))
         sys.exit(status)
 
     # pause for a moment to give mqtt a chance to catch up
@@ -141,6 +141,6 @@ if __name__ == '__main__':
     recorder_full_url = "%s://%s:%s%s" % ( args.recorder_protocol, args.recorder_hostname, args.recorder_port, args.recorder_url )
     status, msg = check_response(recorder_full_url, tics)
 
-    print "%s %s" % (codes[status], msg)
+    print("%s %s" % (codes[status], msg))
     sys.exit(status)