Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • perun/perun-proxyidp/perun-proxy-utils
1 result
Show changes
Commits on Source (3)
# [1.4.0](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/compare/v1.3.0...v1.4.0) (2023-06-07)
### Features
* check_exabgp_propagation, check_dockers, webserver_availability, check_syncrepl ([5106f36](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/commit/5106f3656227a02d8d17ac5fa3fb819b9bdf75fd))
# [1.3.0](https://gitlab.ics.muni.cz/perun-proxy-aai/python/perun-proxy-utils/compare/v1.2.0...v1.3.0) (2023-06-07)
......
#!/usr/bin/env python3
import argparse
import docker
from docker.errors import NotFound, APIError
def get_docker_states(req_containers):
client = docker.from_env()
containers = {}
for item in req_containers:
try:
container = client.containers.get(item)
containers[container.name] = container.status
except (NotFound, APIError):
containers[item] = "ERROR"
return containers
def get_args():
"""
Supports the command-line arguments listed below.
"""
parser = argparse.ArgumentParser(description="Check dockers")
parser.add_argument(
"-c",
"--containers",
required=True,
help='list of container names to check in following format: "[cont1, cont2]"',
)
return parser.parse_args()
def main():
args = get_args()
containers_list = args.containers.replace(" ", "").strip("[]").split(",")
containers_status = get_docker_states(containers_list)
status = 0
status_info = ""
for container_name in containers_status:
container_status = containers_status[container_name]
if container_status != "running":
status = 2
status_info += container_name + ": " + container_status + "; "
print(str(status) + " docker_containers - [" + status_info + "]")
return status
if __name__ == "__main__":
exit(main())
#!/usr/bin/env python3
from subprocess import run
def main():
result = run(
["/usr/bin/docker", "exec", "exabgp", "exabgpcli", "show", "adj-rib", "out"],
text=True,
capture_output=True,
)
exit_code = result.returncode
out = result.stdout
status = 0
status_txt = "OK"
if exit_code != 0 or len(out) == 0:
status = 2
status_txt = "CRITICAL"
print(status_txt, end=" ")
if len(out) != 0:
print("-", end=" ")
print(out)
return status
if __name__ == "__main__":
exit(main())
#!/usr/bin/env python3
from check_syncrepl_extended.check_syncrepl_extended import main
# for program arguments check
# https://gitlab.ics.muni.cz/perun-proxy-aai/python/check_syncrepl_extended
if __name__ == "__main__":
main()
#!/usr/bin/env python3
import argparse
import requests
def get_args():
"""
Supports the command-line arguments listed below.
"""
parser = argparse.ArgumentParser(description="Check webserver")
parser.add_argument(
"-u",
"--url",
required=True,
help="webserver url",
)
parser.add_argument("-p", "--port", help="webserver port")
return parser.parse_args()
def main():
args = get_args()
url = args.url
if args.port:
url += f":{args.port}"
status = 2
status_txt = "ERROR"
try:
res = requests.get(url, allow_redirects=False)
if res.status_code == 200 or res.status_code == 301:
status = 0
status_txt = "OK"
except requests.RequestException:
pass
print(str(status) + " webserver_availability - " + status_txt)
return status
if __name__ == "__main__":
exit(main())
[metadata]
version = 1.3.0
version = 1.4.0
license_files = LICENSE
......@@ -15,5 +15,7 @@ setuptools.setup(
"beautifulsoup4~=4.12",
"requests~=2.31",
"ldap3~=2.9.1",
"check_syncrepl_extended @ git+https://gitlab.ics.muni.cz/perun-proxy-aai/"
"python/check_syncrepl_extended.git@main",
],
)