Add check_matrix.py test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2023-11-12 01:45:56 +01:00
parent 1bf2c0ac0e
commit b061ba4368
2 changed files with 31 additions and 0 deletions

View File

@ -40,6 +40,7 @@ ADD https://raw.githubusercontent.com/stump/check_sshfp/master/check_sshfp /usr/
ADD https://raw.githubusercontent.com/matteocorti/check_ssl_cert/master/check_ssl_cert /usr/lib/nagios/plugins/check_ssl_cert
ADD https://gist.githubusercontent.com/nemunaire/9669659/raw/977cfce7246249c17e213b0b2b231220257754fa/nagios-status.pl /usr/bin/nagios-status.pl
RUN chmod 755 /usr/lib/nagios/plugins/check_sshfp /usr/lib/nagios/plugins/check_ssl_cert /usr/bin/nagios-status.pl
COPY check_matrix.py /usr/lib/nagios/plugins/check_matrix
ENTRYPOINT ["/docker-entrypoint.sh"]
USER nagios

30
check_matrix.py Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
import argparse
import http.client
import json
import sys
parser = argparse.ArgumentParser(description='Nagios plugin for Matrix federation test.')
parser.add_argument('domain')
args = parser.parse_args()
conn = http.client.HTTPSConnection("federation-tester.p0m.fr")
conn.request("GET", "/api/report?server_name=" + args.domain)
tester = json.load(conn.getresponse())
msg = ""
try:
msg += "- " + tester["Version"]["name"] + " " + tester["Version"]["version"]
except:
pass
if tester["FederationOK"]:
print("MATRIX FEDERATION OK " + msg)
sys.exit(0)
elif len(tester["ConnectionReports"]):
print("MATRIX FEDERATION WARNING " + msg)
sys.exit(1)
else:
print("MATRIX FEDERATION CRITICAL " + msg)
sys.exit(2)