Skip to content

Commit

Permalink
Add push test for monitoring
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Bisserie <[email protected]>
  • Loading branch information
Vincent Bisserie committed Jun 20, 2023
1 parent 1b4aaad commit f4744e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ default_gh_list: # Liste des codes barres par default

sentry: # Configuration du DSN sentry
dsn: "https://foo.bar"

push_test_urls:
- https://push.statuscake.com/...
```
`python main.py` pour lancer la boucle de lecture/ouverture

Expand Down
18 changes: 17 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import sys
import time
import threading
from logging.handlers import RotatingFileHandler

import requests
Expand All @@ -16,6 +17,7 @@
"0003:0C2E:0200",
"0003:05E0:1200",
]
PUSH_TEST_SLEEP = 60

logger = logging.getLogger()
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -123,8 +125,22 @@ def refresh():
logging.error(f"Erreur {r.status_code}: {r.text}")


def push_test():
while True:
for push_test_url in CONFIG.get("push_test_urls", []):
requests.get(push_test_url)
time.sleep(PUSH_TEST_SLEEP)


if __name__ == "__main__":
if len(sys.argv) <= 1 or sys.argv[1] == "scan":
scanette()
t1 = threading.Thread(target=scanette)
t2 = threading.Thread(target=push_test)

t1.start()
t2.start()

t1.join()
t2.join()
elif sys.argv[1] == "refresh":
refresh()

0 comments on commit f4744e1

Please sign in to comment.