updated plugins to python3

made specifying which temperatur for plugins/check_temperature mandatory
This commit is contained in:
2024-12-29 15:36:33 +01:00
parent bbad51d9ca
commit c1cfdd7d21
2 changed files with 18 additions and 18 deletions

View File

@@ -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'