Module: check_mk
Branch: master
Commit: 8b37b9143ec743a457051b9e5f67399fb9455a19
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b37b9143ec743…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 26 09:43:13 2018 +0200
mtr: Removed distutils dependency of agent plugin
Change-Id: Idc02ed801b5fab2ffb128e0011a8097ea1fc8946
---
agents/plugins/mtr | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/agents/plugins/mtr b/agents/plugins/mtr
index 05cb3c9..2ac9cf6 100755
--- a/agents/plugins/mtr
+++ b/agents/plugins/mtr
@@ -35,7 +35,7 @@
# MTR results are stored in $VARDIR/mtr_${host}.report
# return previous host data
-import sys, os, re, time, glob, ConfigParser, StringIO, distutils.spawn
+import sys, os, re, time, glob, ConfigParser, StringIO
from unicodedata import normalize
import subprocess
@@ -52,13 +52,32 @@ if '-d' in sys.argv[2:] or '--debug' in sys.argv[1:]:
else:
debug = False
+
+def which(program):
+ def is_exe(fpath):
+ return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+ fpath, fname = os.path.split(program)
+ if fpath:
+ if is_exe(program):
+ return program
+ else:
+ for path in os.environ["PATH"].split(os.pathsep):
+ exe_file = os.path.join(path, program)
+ if is_exe(exe_file):
+ return exe_file
+
+ return None
+
+
# See if we have mtr
-mtr_prog = distutils.spawn.find_executable('mtr')
+mtr_prog = which('mtr')
if mtr_prog == None:
if debug:
sys.stdout.write("Could not find mtr binary\n")
sys.exit(0)
+
def read_config():
default_options = {
'type' : 'icmp',