Added error count to monitors and print more information on startup. (0.28.2)
This commit is contained in:
parent
3f5b7c69fd
commit
4753c28f81
3 changed files with 15 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ from linspector.environment import Environment
|
||||||
from linspector.linspector import Linspector
|
from linspector.linspector import Linspector
|
||||||
from linspector.monitors import Monitors
|
from linspector.monitors import Monitors
|
||||||
|
|
||||||
__version__ = '0.28.1'
|
__version__ = '0.28.2'
|
||||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||||
|
|
||||||
sys.stderr = open('/dev/null', 'w')
|
sys.stderr = open('/dev/null', 'w')
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ class Linspector:
|
||||||
}
|
}
|
||||||
if configuration.get_option('linspector', 'max_threads') and not \
|
if configuration.get_option('linspector', 'max_threads') and not \
|
||||||
configuration.get_option('linspector', 'scheduler_mode') == 'process':
|
configuration.get_option('linspector', 'scheduler_mode') == 'process':
|
||||||
|
print('Job execution mode: thread')
|
||||||
|
self._log.info('job execution mode: thread')
|
||||||
executors = {
|
executors = {
|
||||||
'default': ThreadPoolExecutor(int(configuration.get_option('linspector',
|
'default': ThreadPoolExecutor(int(configuration.get_option('linspector',
|
||||||
'max_threads')))
|
'max_threads')))
|
||||||
|
|
@ -68,6 +70,8 @@ class Linspector:
|
||||||
}
|
}
|
||||||
if configuration.get_option('linspector', 'scheduler_mode'):
|
if configuration.get_option('linspector', 'scheduler_mode'):
|
||||||
if configuration.get_option('linspector', 'scheduler_mode') == 'process':
|
if configuration.get_option('linspector', 'scheduler_mode') == 'process':
|
||||||
|
print('Job execution mode: process')
|
||||||
|
self._log.info('Job execution mode: process')
|
||||||
executors = {
|
executors = {
|
||||||
'default': ThreadPoolExecutor(
|
'default': ThreadPoolExecutor(
|
||||||
int(configuration.get_option('linspector', 'max_threads'))),
|
int(configuration.get_option('linspector', 'max_threads'))),
|
||||||
|
|
@ -88,6 +92,7 @@ class Linspector:
|
||||||
start_date = datetime.datetime.now()
|
start_date = datetime.datetime.now()
|
||||||
log.debug(monitors.get_monitors())
|
log.debug(monitors.get_monitors())
|
||||||
monitors = self._monitors.get_monitors()
|
monitors = self._monitors.get_monitors()
|
||||||
|
monitor_count = 0
|
||||||
for monitor in monitors:
|
for monitor in monitors:
|
||||||
log.debug(monitor)
|
log.debug(monitor)
|
||||||
if configuration.get_option('linspector', 'delta_range'):
|
if configuration.get_option('linspector', 'delta_range'):
|
||||||
|
|
@ -136,5 +141,9 @@ class Linspector:
|
||||||
' next=' + str(new_start_date) +
|
' next=' + str(new_start_date) +
|
||||||
' message=scheduling job')
|
' message=scheduling job')
|
||||||
|
|
||||||
|
monitor_count += 1
|
||||||
|
|
||||||
|
print('Number of monitors scheduled: ' + str(monitor_count))
|
||||||
|
|
||||||
if configuration.get_option('linspector', 'start_scheduler') == 'true':
|
if configuration.get_option('linspector', 'start_scheduler') == 'true':
|
||||||
self._scheduler['linspector'].start()
|
self._scheduler['linspector'].start()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Monitor:
|
||||||
self._configuration = configuration
|
self._configuration = configuration
|
||||||
self._enabled = True
|
self._enabled = True
|
||||||
self._environment = environment
|
self._environment = environment
|
||||||
|
self._error_count = 0
|
||||||
self._host = monitor_configuration.get('monitor', 'host')
|
self._host = monitor_configuration.get('monitor', 'host')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -24,7 +25,6 @@ class Monitor:
|
||||||
self._hostgroups = "None"
|
self._hostgroups = "None"
|
||||||
|
|
||||||
self._identifier = identifier
|
self._identifier = identifier
|
||||||
self._job_threshold = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._interval = int(monitor_configuration.get('monitor', 'interval'))
|
self._interval = int(monitor_configuration.get('monitor', 'interval'))
|
||||||
|
|
@ -120,6 +120,10 @@ class Monitor:
|
||||||
try:
|
try:
|
||||||
self._result = self._services[self._service].execute(self._identifier, self,
|
self._result = self._services[self._service].execute(self._identifier, self,
|
||||||
self._service, **self._args)
|
self._service, **self._args)
|
||||||
|
|
||||||
|
if self._result['status'] == 'ERROR':
|
||||||
|
self._error_count += 1
|
||||||
|
|
||||||
self._log.debug(self._result)
|
self._log.debug(self._result)
|
||||||
self._log.debug(self._tasks)
|
self._log.debug(self._tasks)
|
||||||
for task in self._tasks:
|
for task in self._tasks:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue