check_federation_tester, make stuff executable

This commit is contained in:
Cyberes 2023-04-21 23:54:17 -06:00
parent a804606502
commit bafcf422b9
13 changed files with 50 additions and 21 deletions

0
check_federation.py Normal file → Executable file
View File

50
check_federation_tester.py Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python3
import argparse
import sys
import traceback
import requests
import checker.nagios as nagios
parser = argparse.ArgumentParser(description='Test federation between two homeservers.')
parser.add_argument('--endpoint', required=True, help='Endpoint to parse. See fed.mau.dev or federationtester.matrix.org')
parser.add_argument('--timeout', type=float, default=90, help='Request timeout limit.')
parser.add_argument('--warn', type=float, default=2.0, help='Manually set warn level.')
parser.add_argument('--crit', type=float, default=2.5, help='Manually set critical level.')
args = parser.parse_args()
def main() -> None:
r = requests.get(args.endpoint, timeout=args.timeout)
if not r.status_code:
print(f'UNKNOWN: tester endpoint failed with status code {r.status_code}\n', r.text)
sys.exit(nagios.UNKNOWN)
r_json = r.json()
if r_json.get('FederationOK'):
print('OK: federation tester reported success.')
print(f"Version: {r_json.get('Version', {}).get('name')}/{r_json.get('Version', {}).get('version')}")
print('WellKnown:', r_json.get('WellKnownResult', {}).get('m.server'))
nagios_output = nagios.OK
else:
print('CRITICAL: federation tester reported failure.')
print('Server Version:', r_json.get('m.server'))
print('WellKnown:', r_json.get('WellKnownResult', {}).get('m.server'))
print('WellKnown Result:', r_json.get('WellKnownResult', {}).get('result'))
print('DNS Result:', r_json.get('DNSResult', {}).get('SRVError', {}).get('Message', {}))
print('Version:', r_json.get('Version', {}).get('error'))
print('Connection Report:', r_json.get('ConnectionReports'))
print('Connection Errors:', r_json.get('ConnectionErrors'))
nagios_output = nagios.CRITICAL
sys.exit(nagios_output)
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"UNKNOWN: exception\n{e}")
print(traceback.format_exc())
sys.exit(nagios.UNKNOWN)

0
check_matrix_synapse.py Normal file → Executable file
View File

0
check_media_cdn.py Normal file → Executable file
View File

0
check_monitor_bot.py Normal file → Executable file
View File

View File

@ -1,4 +0,0 @@
python3 Matrix\ Synapse/check_monitor_bot.py \
--metrics-endpoint "https://matrix.your-hs.com/matrix-monitor-bot/" \
--domain your-hs.com \
--ignore canarymod.net catgirl.cloud

0
check_pve/check_pve.py Normal file → Executable file
View File

0
check_redis.py Normal file → Executable file
View File

0
icinga2kuma.py Normal file → Executable file
View File

0
matrix-host-notification.py Normal file → Executable file
View File

0
matrix-service-notification.py Normal file → Executable file
View File

View File

@ -1,9 +0,0 @@
python3 Matrix\ Synapse/check_federation.py \
--bot1-user '@bot1:your-hs.com' \
--bot1-pw password1234 \
--bot1-hs https://matrix.your-hs.com \
--bot1-auth-file /opt/custom-nagios-checks/auth-fed-test-bot1.json \
--bot2-user '@bot2:matrix.org' \
--bot2-pw password1234 \
--bot2-hs https://matrix-federation.matrix.org \
--bot2-auth-file /opt/custom-nagios-checks/auth-fed-test-bot2.json

View File

@ -1,8 +0,0 @@
python3 Matrix\ Synapse/check_media_cdn.py \
--user '@bot1:your-hs.com' \
--pw password1234 \
--hs https://matrix.your-hs.com \
--room '!banana:your-hs.com' \
--auth-file ./auth-cdn.json \
--media-cdn-domain matrix-media-cdn.your-hs.com \
--admin-endpoint https://172.0.2.118