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

Check all hosts cpu graph (refs #24369).

parent c608809d
No related branches found
No related tags found
No related merge requests found
......@@ -47,32 +47,33 @@ def check_munin():
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()
if diff_seconds > 3600:
print_red('Monitoring data is older than 1 hour and is probably not working.')
# get cpu day graph of each host
paths = list()
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)):
path = os.path.join(MUNIN_WWW_PATH, name, sub_name, 'cpu-day.png')
if sub_name != 'index.html' and os.path.exists(path):
paths.append(path)
if not paths:
print_red('No Munin host directory was found in "%s".' % MUNIN_WWW_PATH)
return 1
else:
print_green('Monitoring data is not older than 1 hour, everything seems fine.')
return 0
# check graph mtime
error = False
for path in paths:
print('Checking graph "%s" modification date...' % path)
mtime = os.path.getmtime(path)
d = datetime.fromtimestamp(mtime)
now = datetime.now()
diff_seconds = (now - d).total_seconds()
if diff_seconds > 3600:
print_red('The graph is older than 1 hour. The monitoring is probably not working.')
error = True
else:
print_green('The graph is not older than 1 hour.')
return 1 if error else 0
rc = check_munin()
......
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