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(): ...@@ -47,32 +47,33 @@ def check_munin():
if not os.path.exists(MUNIN_WWW_PATH): if not os.path.exists(MUNIN_WWW_PATH):
print_red('Munin directory "%s" not found.' % MUNIN_WWW_PATH) print_red('Munin directory "%s" not found.' % MUNIN_WWW_PATH)
return 1 return 1
path = os.path.join(MUNIN_WWW_PATH, 'localdomain', 'localhost.localdomain', 'cpu-day.png')
if not os.path.exists(path): # get cpu day graph of each host
path = None paths = list()
for name in os.listdir(MUNIN_WWW_PATH): 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')): 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)): 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') path = os.path.join(MUNIN_WWW_PATH, name, sub_name, 'cpu-day.png')
if sub_name != 'index.html' and os.path.exists(p): if sub_name != 'index.html' and os.path.exists(path):
path = p paths.append(path)
break if not paths:
if path: print_red('No Munin host directory was found in "%s".' % MUNIN_WWW_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.')
return 1 return 1
else:
print_green('Monitoring data is not older than 1 hour, everything seems fine.') # check graph mtime
return 0 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() 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