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
|
||||
target/
|
||||
|
||||
config.yml
|
||||
|
@ -1,5 +1,6 @@
|
||||
from subprocess import CalledProcessError
|
||||
from subprocess import check_call
|
||||
from time import sleep
|
||||
|
||||
import yamlenv
|
||||
|
||||
@ -27,13 +28,15 @@ def alert_for_monitor(monitor, alerts):
|
||||
|
||||
def main():
|
||||
# TODO: get config file off command line
|
||||
config = get_config('./sample-config.yml')
|
||||
config = get_config('config.yml')
|
||||
alerts = config.get('alerts', {})
|
||||
for monitor in config.get('monitors', []):
|
||||
try:
|
||||
check_monitor(monitor)
|
||||
except CalledProcessError:
|
||||
alert_for_monitor(monitor, alerts)
|
||||
while True:
|
||||
for monitor in config.get('monitors', []):
|
||||
try:
|
||||
check_monitor(monitor)
|
||||
except CalledProcessError:
|
||||
alert_for_monitor(monitor, alerts)
|
||||
sleep(config.get('interval', 1))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,3 +1,5 @@
|
||||
interval: 5
|
||||
|
||||
monitors:
|
||||
- name: View
|
||||
command: [ 'curl', 'https://localhost:5000' ]
|
||||
|
Loading…
Reference in New Issue
Block a user