Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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)

Florent Thiery
committed
host = conf.get('MS_SERVER_NAME')
suffix = '.'.join(host.split('.')[1:])

Florent Thiery
committed
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")
def check_munin():
print('Checking if monitoring works')
mtime = os.path.getmtime(MUNIN_CHECK_PATH)
d = datetime.fromtimestamp(mtime)
now = datetime.now()
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)