From caf667dd2bc0e4453216ceb14d4bb8c1068474a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Mon, 4 Apr 2022 17:53:09 +0200 Subject: [PATCH] Implement python3 support --- check_linux_metrics.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/check_linux_metrics.py b/check_linux_metrics.py index f0a9216..ad0a08e 100755 --- a/check_linux_metrics.py +++ b/check_linux_metrics.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # File: check_linux_metrics.py # URL: https://github.com/kxr/check_linux_metrics @@ -25,6 +25,9 @@ # along with this program. If not, see . # +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import sys import time import os @@ -112,7 +115,7 @@ def check_cpu( warn=None, crit=None ): #update the interim file shutil.copyfile( '/proc/stat', interim_file ) - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_load( warn=None, crit=None ): @@ -169,7 +172,7 @@ def check_load( warn=None, crit=None ): #remove last space perfdata = perfdata[:-1] - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_threads( warn=None, crit=None ): @@ -213,7 +216,7 @@ def check_threads( warn=None, crit=None ): #remove last space perfdata = perfdata[:-1] - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_openfiles( warn=None, crit=None ): @@ -260,7 +263,7 @@ def check_openfiles( warn=None, crit=None ): #remove last space perfdata = perfdata[:-1] - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) @@ -371,7 +374,7 @@ def check_procs( warn=None, crit=None ): #update the interim file shutil.copyfile( '/proc/stat', interim_file ) - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_diskio( dev, warn=None, crit=None ): @@ -478,7 +481,7 @@ def check_diskio( dev, warn=None, crit=None ): #update the interim file shutil.copyfile( '/proc/diskstats', interim_file ) - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_disku( mount, warn=None, crit=None): @@ -526,7 +529,7 @@ def check_disku( mount, warn=None, crit=None): if warn is not None and crit is not None: perfdata += ';' + str(warn) + ';' + str(crit) - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_memory ( warn=None, crit=None ): @@ -589,7 +592,7 @@ def check_memory ( warn=None, crit=None ): #remove last space perfdata = perfdata[:-1] - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_swap ( warn=None, crit=None ): status_code = 3 @@ -645,7 +648,7 @@ def check_swap ( warn=None, crit=None ): #remove last space perfdata = perfdata[:-1] - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) def check_net ( interface, warn=None, crit=None ): @@ -740,7 +743,7 @@ def check_net ( interface, warn=None, crit=None ): #update the interim file shutil.copyfile( '/proc/net/dev', interim_file ) - print status_outp + ' | ' + perfdata + print ( status_outp + ' | ' + perfdata ) sys.exit( status_code ) if __name__ == '__main__':