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

Fixed Munin test when only munin-node is installed | refs #32915

parent 39e5d8ba
No related branches found
No related tags found
No related merge requests found
......@@ -19,20 +19,57 @@ from utilities import logging as lg # noqa: E402
MUNIN_WWW_PATH = '/var/cache/munin/www/'
def check_munin_node():
lg.log('Checking if Munin node works...')
# check if package is installed
p = subprocess.run(['dpkg', '-s', 'munin-node'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if p.returncode != 0:
lg.info('The command "dpkg -s munin-node" returned code %s, assuming that the package is not installed. Test skipped.' % p.returncode)
return -1
# check that no plugin should be activated or disabled
lg.log('Checking that no plugin should be enabled/disabled.')
lg.log('munin-node-configure --shell --remove-also')
p = subprocess.run(['munin-node-configure', '--shell', '--remove-also'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = p.stdout.decode('utf-8').strip()
err = p.stderr.decode('utf-8').strip()
lg.log(out)
lg.log(err)
if out:
if out.count('ln -s'):
lg.warning('%s plugins should be enabled.' % out.count('ln -s'))
if out.count('rm -f'):
lg.warning('%s plugins should be disabled.' % out.count('rm -f'))
lg.log('''To enable/disable correct plugins, please run:\n
munin-node-configure --shell --remove-also 2>/dev/null | sh;
systemctl restart munin 2>/dev/null;
systemctl restart munin-node;''')
return 0
def check_munin():
lg.log('Checking if monitoring works...')
if not os.path.exists(MUNIN_WWW_PATH):
p = subprocess.run(['dpkg', '-s', 'munin'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if p.returncode == 0:
lg.error('Munin directory "%s" not found.' % MUNIN_WWW_PATH)
return 1
else:
lg.info('Munin is not installed, test skipped.')
return 2
lg.log('Checking if Munin graph works...')
# check if package is installed
p = subprocess.run(['dpkg', '-s', 'munin'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if p.returncode != 0:
lg.info('The command "dpkg -s munin" returned code %s, assuming that the package is not installed. Test skipped.' % p.returncode)
return -1
# get Munin www dir names
if os.path.exists(MUNIN_WWW_PATH):
names = os.listdir(MUNIN_WWW_PATH)
names.sort()
else:
names = []
if not names:
lg.error('No Munin directory found in "%s".' % MUNIN_WWW_PATH)
return 1
# get cpu day graph of each host
paths = list()
for name in os.listdir(MUNIN_WWW_PATH):
for name in names:
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')
......@@ -59,5 +96,6 @@ def check_munin():
if __name__ == '__main__':
code = check_munin()
sys.exit(code)
code1 = check_munin_node()
code2 = check_munin()
sys.exit(max(code1, code2))
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