Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
665e7fdc
Commit
665e7fdc
authored
4 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Munin test when only munin-node is installed | refs
#32915
parent
39e5d8ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/scripts/test_monitoring.py
+50
-12
50 additions, 12 deletions
tests/scripts/test_monitoring.py
with
50 additions
and
12 deletions
tests/scripts/test_monitoring.py
+
50
−
12
View file @
665e7fdc
...
...
@@ -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
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment