-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (47 loc) · 1.75 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
import os
import yaml
from utils import verif
from utils.webdriver import WebBrowser
def send_message(message):
driver = WebBrowser()
driver.connexion()
driver.send_msg("4349594458421719", message)
driver.browser.close()
if __name__ == "__main__":
USER = os.environ.get("SSH_USER")
PASS = os.environ.get("SSH_PASS")
with open('check-list.yaml', 'r') as file:
check_list = yaml.safe_load(file)
v = verif.Verif()
for url in check_list["api"]:
verif_api = v.http(url, type="api")
if verif_api is not True:
send_message(f"{url} : {str(verif_api)}")
else:
print(f"[API CHECKED] {url}")
for url in check_list["web"]:
verif_web = v.http(url, type="web")
if verif_web is not True:
send_message(f"{url} : {str(verif_web)}")
else:
print(f"[SITE CHECKED] {url}")
ssh_client = v.ssh("iteam-s.mg", USER, PASS)
if type(ssh_client) == str:
send_message(f"SSH: {str(ssh_client)} :-(")
else:
print("[SSH CONNECTED xD]")
for service in check_list["services"]:
verif_srv = v.service(service, ssh_client)
if verif_srv is not True:
send_message(f"{service} : INACTIVE or DEAD")
else:
print(f"[ACTIVE] {service}")
for pm2_app in check_list["pm2"]:
verif_pm2 = v.service(pm2_app, ssh_client)
if verif_pm2 is not True:
send_message(pm2_app + str(verif_pm2))
else:
print(f"[ONLINE] {pm2_app}")
ssh_client.close()
print("[ANALYSE DONE]")