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
0f6200a1
Commit
0f6200a1
authored
7 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
add munin check to tests, fixes
#21661
parent
6c4eea86
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
+61
-0
61 additions, 0 deletions
tests/test_monitoring.py
with
61 additions
and
0 deletions
tests/test_monitoring.py
0 → 100755
+
61
−
0
View file @
0f6200a1
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Criticality: Low
Check that the monitoring graphs work.
'''
import
os
from
datetime
import
datetime
import
sys
import
imp
YELLOW
=
'
\033
[93m
'
GREEN
=
'
\033
[92m
'
RED
=
'
\033
[91m
'
DEF
=
'
\033
[0m
'
os
.
chdir
(
os
.
path
.
dirname
(
__file__
))
if
not
os
.
path
.
isfile
(
'
../utils.py
'
):
print
(
'
The envsetup configuration was not found.
'
)
sys
.
exit
(
1
)
else
:
es_utils
=
imp
.
load_source
(
'
es_utils
'
,
'
../utils.py
'
)
conf
=
es_utils
.
load_conf
()
def
print_color
(
txt
,
col
):
print
(
'
%s%s%s
'
%
(
col
,
txt
,
DEF
))
def
print_yellow
(
txt
):
print_color
(
txt
,
YELLOW
)
def
print_red
(
txt
):
print_color
(
txt
,
RED
)
def
print_green
(
txt
):
print_color
(
txt
,
GREEN
)
MUNIN_CHECK_PATH
=
"
/var/cache/munin/www/localdomain/localhost.localdomain/cpu-day.png
"
def
check_munin
():
print
(
'
Checking if monitoring works
'
)
mtime
=
os
.
path
.
getmtime
(
MUNIN_CHECK_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
else
:
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