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
c608809d
Commit
c608809d
authored
6 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Changed monitoring test to find cpu graph dynamically (refs
#24369
).
parent
52b2ad6c
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/test_monitoring.py
+22
-10
22 additions, 10 deletions
tests/test_monitoring.py
with
22 additions
and
10 deletions
tests/test_monitoring.py
+
22
−
10
View file @
c608809d
...
...
@@ -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
)
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