Add run loop and interval
This commit is contained in:
parent
2b5856ee30
commit
636ad103a3
1
.gitignore
vendored
1
.gitignore
vendored
@ -58,3 +58,4 @@ docs/_build/
|
|||||||
# PyBuilder
|
# PyBuilder
|
||||||
target/
|
target/
|
||||||
|
|
||||||
|
config.yml
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
import yamlenv
|
import yamlenv
|
||||||
|
|
||||||
@ -27,13 +28,15 @@ def alert_for_monitor(monitor, alerts):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
# TODO: get config file off command line
|
# TODO: get config file off command line
|
||||||
config = get_config('./sample-config.yml')
|
config = get_config('config.yml')
|
||||||
alerts = config.get('alerts', {})
|
alerts = config.get('alerts', {})
|
||||||
for monitor in config.get('monitors', []):
|
while True:
|
||||||
try:
|
for monitor in config.get('monitors', []):
|
||||||
check_monitor(monitor)
|
try:
|
||||||
except CalledProcessError:
|
check_monitor(monitor)
|
||||||
alert_for_monitor(monitor, alerts)
|
except CalledProcessError:
|
||||||
|
alert_for_monitor(monitor, alerts)
|
||||||
|
sleep(config.get('interval', 1))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
interval: 5
|
||||||
|
|
||||||
monitors:
|
monitors:
|
||||||
- name: View
|
- name: View
|
||||||
command: [ 'curl', 'https://localhost:5000' ]
|
command: [ 'curl', 'https://localhost:5000' ]
|
||||||
|
Loading…
Reference in New Issue
Block a user