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_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: