Skip to content
Snippets Groups Projects
Commit c608809d authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Changed monitoring test to find cpu graph dynamically (refs #24369).

parent 52b2ad6c
No related branches found
No related tags found
No related merge requests found
......@@ -39,16 +39,31 @@ def print_green(txt):
print_color(txt, GREEN)
host = conf.get('MS_SERVER_NAME')
suffix = '.'.join(host.split('.')[1:])
MUNIN_CHECK_PATH = "/var/cache/munin/www/%s/%s/cpu-day.png" % (suffix, host)
if not os.path.exists(MUNIN_CHECK_PATH):
MUNIN_CHECK_PATH = "/var/cache/munin/www/%s/%s/cpu-day.png" % ("localdomain", "localhost.localdomain")
MUNIN_WWW_PATH = '/var/cache/munin/www/'
def check_munin():
print('Checking if monitoring works')
mtime = os.path.getmtime(MUNIN_CHECK_PATH)
print('Checking if monitoring works...')
if not os.path.exists(MUNIN_WWW_PATH):
print_red('Munin directory "%s" not found.' % MUNIN_WWW_PATH)
return 1
path = os.path.join(MUNIN_WWW_PATH, 'localdomain', 'localhost.localdomain', 'cpu-day.png')
if not os.path.exists(path):
path = None
for name in os.listdir(MUNIN_WWW_PATH):
if not name.endswith('.html') and name != 'static' and os.path.isfile(os.path.join(MUNIN_WWW_PATH, name, 'index.html')):
for sub_name in os.listdir(os.path.join(MUNIN_WWW_PATH, name)):
p = os.path.join(MUNIN_WWW_PATH, name, sub_name, 'cpu-day.png')
if sub_name != 'index.html' and os.path.exists(p):
path = p
break
if path:
break
if not path:
print_red('Munin host directory not found in "%s".' % MUNIN_WWW_PATH)
return 1
print('Found host directory: "%s".' % path)
mtime = os.path.getmtime(path)
d = datetime.fromtimestamp(mtime)
now = datetime.now()
diff_seconds = (now - d).total_seconds()
......@@ -59,9 +74,6 @@ def check_munin():
print_green('Monitoring data is not older than 1 hour, everything seems fine.')
return 0
if not os.path.exists(MUNIN_CHECK_PATH):
print_red('Munin data %s not found.' % MUNIN_CHECK_PATH)
sys.exit(1)
rc = check_munin()
sys.exit(rc)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment