Initial commit - working mvp
This commit is contained in:
parent
4bae94ae03
commit
7db55fe2db
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.venv/
|
||||
**/__pycache__/
|
||||
47
hosts.yaml
Normal file
47
hosts.yaml
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
hosts:
|
||||
webassets:
|
||||
hostname: webassets.confederationcollege.ca
|
||||
actions:
|
||||
- ping
|
||||
- httpcheck
|
||||
secureassets:
|
||||
hostname: secureassets.confederationcollege.ca
|
||||
actions:
|
||||
- ping
|
||||
cognos-test:
|
||||
hostname: cc-cognotest-01.confederationc.on.ca
|
||||
port: 9300
|
||||
actions:
|
||||
- ping
|
||||
Solarwinds Service Desk:
|
||||
hostname: itsupport.confederationcollege.ca
|
||||
actions:
|
||||
- ping
|
||||
Aruba Mobility Conductor:
|
||||
hostname: aruba.confederationcollege.ca
|
||||
port: 4343
|
||||
actions:
|
||||
- ping
|
||||
cc-aruba-7210-01:
|
||||
hostname: cc-aruba-7210-01.confederationcollege.ca
|
||||
port: 4343
|
||||
actions:
|
||||
- ping
|
||||
cc-aruba-7210-02:
|
||||
hostname: cc-aruba-7210-02.confederationcollege.ca
|
||||
port: 4343
|
||||
actions:
|
||||
- ping
|
||||
barracuda:
|
||||
hostname: barracuda.confederationcollege.ca
|
||||
inbound_decrypt: yes
|
||||
proxy: yes
|
||||
actions:
|
||||
- ping
|
||||
Maintenance Connection:
|
||||
hostname: facilitymaint.confederationcollege.ca
|
||||
server: cc-apps-01
|
||||
actions:
|
||||
- ping
|
||||
|
||||
20
monitor.py
Executable file
20
monitor.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
import yaml
|
||||
import pprint
|
||||
import json
|
||||
import sys
|
||||
sys.path.append('plugins')
|
||||
import pkgutil
|
||||
import importlib
|
||||
plugins = {}
|
||||
for finder, name, ispkg in pkgutil.iter_modules(path=['plugins']):
|
||||
plugins[name] = importlib.import_module(name)
|
||||
row_format = "{:<30}{:<10}{:<6}{:<20}"
|
||||
|
||||
with open('hosts.yaml', 'r') as file:
|
||||
hosts = yaml.safe_load(file)
|
||||
|
||||
for host, details in hosts['hosts'].items():
|
||||
for action in details['actions']:
|
||||
result = getattr(plugins[action], action)(details['hostname'])
|
||||
print(row_format.format(host, action, result[0], result[1]))
|
||||
8
plugins/httpcheck.py
Normal file
8
plugins/httpcheck.py
Normal file
@ -0,0 +1,8 @@
|
||||
import requests
|
||||
|
||||
def httpcheck(host):
|
||||
try:
|
||||
r = requests.head(f"https://{host}")
|
||||
return [True, r.status_code]
|
||||
except requests.ConnectionError:
|
||||
return [False, r.status_code]
|
||||
13
plugins/ping.py
Normal file
13
plugins/ping.py
Normal file
@ -0,0 +1,13 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def ping(host):
|
||||
response = subprocess.run(["ping","-c","1",host],
|
||||
stdout = subprocess.DEVNULL, stderr = subprocess.PIPE)
|
||||
if response.returncode == 0:
|
||||
return [True, ""]
|
||||
elif response.stderr:
|
||||
return [False, response.stderr]
|
||||
else:
|
||||
return [False, ""]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user