Added some stuff to the misc.dummy and misc.random service for testing. (0.21.4)
This commit is contained in:
parent
1b14770a50
commit
6a5fd9041c
4 changed files with 40 additions and 12 deletions
9
Makefile
9
Makefile
|
|
@ -33,11 +33,14 @@ help:
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# make daemon
|
# make daemon
|
||||||
|
|
||||||
|
daemon:
|
||||||
|
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VRESION)/site-packages/ bin/linspector -d ./etc
|
||||||
|
|
||||||
|
follow:
|
||||||
|
tail -F ./log/linspector.log
|
||||||
|
|
||||||
run:
|
run:
|
||||||
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VERSION)/site-packages/ bin/linspector ./etc
|
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VERSION)/site-packages/ bin/linspector ./etc
|
||||||
|
|
||||||
rundev:
|
rundev:
|
||||||
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VERSION)/site-packages/ bin/linspector ./etc.test.local
|
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VERSION)/site-packages/ bin/linspector ./etc.test.local
|
||||||
|
|
||||||
daemon:
|
|
||||||
PYTHONPATH=$(shell pwd):$(shell pwd)/venv/lib/python$(PYTHON_VRESION)/site-packages/ bin/linspector -d ./etc
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,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.21.3'
|
__version__ = '0.21.4'
|
||||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ class DummyService(Service):
|
||||||
self.__environment = environment
|
self.__environment = environment
|
||||||
self.__log = log
|
self.__log = log
|
||||||
|
|
||||||
def execute(self, **kwargs):
|
def execute(self, identifier, monitor, service, **kwargs):
|
||||||
self.__log.debug('DummyService object ' + str(self) + ' using kwargs: ' + str(kwargs))
|
self.__log.info('identifier=' + identifier +
|
||||||
# log('debug', 'dummy object @' + str(self) + str(self.__kwargs['foo']))
|
' host=' + monitor.get_host() +
|
||||||
return
|
' service=' + service +
|
||||||
|
' status=' + 'OK')
|
||||||
|
return True
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,42 @@ This file is part of Linspector (https://linspector.org/)
|
||||||
Copyright (c) 2022 Johannes Findeisen <you@hanez.org>. All Rights Reserved.
|
Copyright (c) 2022 Johannes Findeisen <you@hanez.org>. All Rights Reserved.
|
||||||
See LICENSE (MIT license).
|
See LICENSE (MIT license).
|
||||||
"""
|
"""
|
||||||
|
import hashlib
|
||||||
|
import random
|
||||||
|
|
||||||
from linspector.service import Service
|
from linspector.service import Service
|
||||||
|
|
||||||
|
|
||||||
def create(configuration, environment, log):
|
def create(configuration, environment, log):
|
||||||
return RandomService(configuration, environment, log)
|
return DummyService(configuration, environment, log)
|
||||||
|
|
||||||
|
|
||||||
class RandomService(Service):
|
class DummyService(Service):
|
||||||
def __init__(self, configuration, environment, log):
|
def __init__(self, configuration, environment, log):
|
||||||
super().__init__(configuration, environment, log)
|
super().__init__(configuration, environment, log)
|
||||||
self.__configuration = configuration
|
self.__configuration = configuration
|
||||||
self.__environment = environment
|
self.__environment = environment
|
||||||
self.__log = log
|
self.__log = log
|
||||||
|
|
||||||
def execute(self, **kwargs):
|
def execute(self, identifier, monitor, service, **kwargs):
|
||||||
return
|
result = random.randint(0, 1)
|
||||||
|
rnd1 = random.randint(0, 99999999999999)
|
||||||
|
rnd2 = random.randint(0, 99999999999999)
|
||||||
|
rnd3 = random.randint(0, 99999999999999)
|
||||||
|
rnd4 = random.randint(0, 99999999999999)
|
||||||
|
rnd5 = random.randint(0, 99999999999999)
|
||||||
|
rnd6 = random.randint(0, 99999999999999)
|
||||||
|
rnd7 = random.randint(0, 99999999999999)
|
||||||
|
rnd8 = random.randint(0, 99999999999999)
|
||||||
|
sha512_1 = hashlib.sha512(str((str(rnd1) + str(rnd2) + str(rnd3) + str(rnd4) +
|
||||||
|
str(rnd5) + str(rnd6) + str(rnd7) + str(rnd8))).
|
||||||
|
encode('utf-8')).hexdigest()
|
||||||
|
sha512_2 = hashlib.sha512(str((str(rnd1) + str(rnd2) + str(rnd3) + str(rnd4) +
|
||||||
|
str(rnd5) + str(rnd6) + str(rnd7) + str(rnd8) + str(sha512_1))).
|
||||||
|
encode('utf-8')).hexdigest()
|
||||||
|
self.__log.info('identifier=' + identifier +
|
||||||
|
' host=' + monitor.get_host() +
|
||||||
|
' service=' + service +
|
||||||
|
' status=' + ('OK' if result == 0 else 'ERROR') + ' sha512=' +
|
||||||
|
sha512_2)
|
||||||
|
return True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue