Moved the container name var to the global space where it belongs.

This commit is contained in:
Ivaylo Novakov 2020-11-20 22:08:04 +01:00
parent 801597ccde
commit 41460f155f
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
1 changed files with 5 additions and 6 deletions

View File

@ -18,6 +18,11 @@ health-checker reads the /health-check endpoint of the portal and dispatches
messages to a Discord channel. messages to a Discord channel.
""" """
# Get the container name as an argument or use "sia" as default.
CONTAINER_NAME = "sia"
if len(sys.argv) > 2:
CONTAINER_NAME = sys.argv[2]
# Get the number of hours to look back in the logs or use 1 as default. # Get the number of hours to look back in the logs or use 1 as default.
CHECK_HOURS = 1 CHECK_HOURS = 1
if len(sys.argv) > 3: if len(sys.argv) > 3:
@ -133,7 +138,6 @@ async def check_disk():
async def check_health(): async def check_health():
print("\nChecking portal health status...") print("\nChecking portal health status...")
try: try:
res_check = requests.get("http://localhost/health-check", verify=False) res_check = requests.get("http://localhost/health-check", verify=False)
json_check = res_check.json() json_check = res_check.json()
@ -239,11 +243,6 @@ def contains_string(string_to_check, string_to_find):
async def check_alerts(): async def check_alerts():
print("\nChecking portal siad alerts...") print("\nChecking portal siad alerts...")
CONTAINER_NAME = "sia"
if len(sys.argv) > 2:
CONTAINER_NAME = sys.argv[2]
# Execute siac alerts and read the response # Execute siac alerts and read the response
cmd_string = "docker exec {} siac alerts".format(CONTAINER_NAME) cmd_string = "docker exec {} siac alerts".format(CONTAINER_NAME)
siac_alert_output = os.popen(cmd_string).read().strip() siac_alert_output = os.popen(cmd_string).read().strip()