diff --git a/plugins/check_otp b/plugins/check_otp index 460bba9..7c7072b 100755 --- a/plugins/check_otp +++ b/plugins/check_otp @@ -1,11 +1,11 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # check_otp - Nagios check plugin for LinOTP/PrivacyIDEA OTP validation # -# Version 1.1, latest version, documentation and bugtracker available at: +# Version 1.2, latest version, documentation and bugtracker available at: # https://gitlab.lindenaar.net/scripts/nagios-plugins # -# Copyright (c) 2018 Frederik Lindenaar +# Copyright (c) 2018 - 2024 Frederik Lindenaar # # This script is free software: you can redistribute and/or modify it under the # terms of version 3 of the GNU General Public License as published by the Free @@ -23,8 +23,8 @@ from time import time from struct import pack from hashlib import sha1 from getpass import getpass -from urllib import urlencode -from urllib2 import Request, HTTPError, URLError, urlopen +from urllib.parse import urlencode +from urllib.request import Request, HTTPError, URLError, urlopen from ssl import CertificateError, \ create_default_context as create_default_SSL_context, \ _create_unverified_context as create_unverified_SSL_context @@ -33,7 +33,7 @@ from argparse import ArgumentParser as StandardArgumentParser, FileType, \ _StoreAction as StoreAction, _StoreConstAction as StoreConstAction # Constants (no need to change but allows for easy customization) -VERSION="1.1" +VERSION="1.2" PROG_NAME=os.path.splitext(os.path.basename(__file__))[0] PROG_VERSION=PROG_NAME + ' ' + VERSION HTTP_AGENT=PROG_NAME + '/' + VERSION @@ -404,7 +404,7 @@ def nagios_exit(status, message, data=None): if isinstance(v,list) else v) for k,v in data ]) else: perfdata = '' - print 'OTP %s: %s%s' % (status[0], message, perfdata) + print('OTP %s: %s%s' % (status[0], message, perfdata)) sys.exit(status[1]) @@ -412,9 +412,9 @@ if __name__ == '__main__': try: args = parse_args() except ArgumentParserError as e: - nagios_exit(NAGIOS_UNKNOWN,'error with setup: ' + e.message) + nagios_exit(NAGIOS_UNKNOWN,'error with setup: ' + ','.join(e.args)) except (KeyboardInterrupt, EOFError) as e: - print + print() nagios_exit(NAGIOS_UNKNOWN,'initialization aborted') message = args.func.__name__ + ' authentication' diff --git a/plugins/check_temperature b/plugins/check_temperature index f9a79e9..6f1e27a 100755 --- a/plugins/check_temperature +++ b/plugins/check_temperature @@ -1,11 +1,11 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # # check_temperature - Nagios temperature check for RaspberryPi-connected sensors # -# Version 1.2, latest version, documentation and bugtracker available at: -# https://gitlab.lindenaar.net/scripts/nagios-plugins +# Version 1.3 latest version, documentation and bugtracker available at: +# https://gitlab.lindenaar.net/scripts/nagios-plugins # -# Copyright (c) 2017 - 2019 Frederik Lindenaar +# Copyright (c) 2017 - 2024 Frederik Lindenaar # # This script is free software: you can redistribute and/or modify it under the # terms of version 3 of the GNU General Public License as published by the Free @@ -27,7 +27,7 @@ from argparse import ArgumentParser as StandardArgumentParser, FileType, \ import logging # Constants (no need to change but allows for easy customization) -VERSION="1.2" +VERSION="1.3" PROG_NAME=splitext(basename(__file__))[0] PROG_VERSION=PROG_NAME + ' ' + VERSION @@ -397,7 +397,7 @@ def parse_args(): parser.add_argument('-l', '--logfile', action=SetLogFile, help='send logging output to logfile') - subparser = parser.add_subparsers(title='Supported temperature sensors') + subparser = parser.add_subparsers(title='Supported temperature sensors', required=True) cpuparser = ArgumentParser(add_help=False) cpuparser.add_argument('-f', '--file', default=CPU_SENSOR_DEV, @@ -469,7 +469,7 @@ def nagios_exit(status, message, data=None): if isinstance(v,list) else v) for k,v in data ]) else: perfdata = '' - print 'Temperature %s: %s%s' % (status[0], message, perfdata) + print('Temperature %s: %s%s' % (status[0], message, perfdata)) exit(status[1]) @@ -478,9 +478,9 @@ if __name__ == '__main__': try: args = parse_args() except ArgumentParserError as e: - nagios_exit(NAGIOS_UNKNOWN,'error with setup: ' + e.message) + nagios_exit(NAGIOS_UNKNOWN,'error with setup: ' + ','.join(e.args)) except (KeyboardInterrupt, EOFError) as e: - print + print() nagios_exit(NAGIOS_UNKNOWN,'initialization aborted') try: