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
c4d1384c
Commit
c4d1384c
authored
6 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Check all hosts cpu graph (refs
#24369
).
parent
c608809d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_monitoring.py
+26
-25
26 additions, 25 deletions
tests/test_monitoring.py
with
26 additions
and
25 deletions
tests/test_monitoring.py
+
26
−
25
View file @
c4d1384c
...
@@ -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
()
...
...
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