Skip to content

Commit

Permalink
Fix: copy monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Sep 16, 2024
1 parent 18c2ab8 commit 83aa492
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/utils/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def check_http_monitor(monitor, gauges):

if is_not_empty_key(monitor, 'username') and is_not_empty_key(monitor, 'password'):
auth = HTTPBasicAuth(monitor['username'], monitor['password'])
del_key_if_exists(monitor, 'username')
del_key_if_exists(monitor, 'password')

pmonitor = monitor.copy()
del_key_if_exists(pmonitor, 'username')
del_key_if_exists(pmonitor, 'password')

try:
if method == "GET":
Expand All @@ -69,7 +71,7 @@ def check_http_monitor(monitor, gauges):
"type": "monitor",
"time": vdate.isoformat(),
"message": "Not supported http method: actual = {}".format(method),
"monitor": monitor
"monitor": pmonitor
})
set_gauge(gauges['result'], 0)
return
Expand All @@ -81,7 +83,7 @@ def check_http_monitor(monitor, gauges):
"time": vdate.isoformat(),
"duration": duration,
"message": "Not expected status code: expected = {}, actual = {}".format(expected_http_code, response.status_code),
"monitor": monitor
"monitor": pmonitor
})
set_gauge(gauges['result'], 0)
return
Expand All @@ -93,7 +95,7 @@ def check_http_monitor(monitor, gauges):
"time": vdate.isoformat(),
"duration": duration,
"message": "Response not valid: expected = {}, actual = {}".format(expected_contain, response.text),
"monitor": monitor
"monitor": pmonitor
})
set_gauge(gauges['result'], 0)
return
Expand All @@ -105,7 +107,7 @@ def check_http_monitor(monitor, gauges):
"time": vdate.isoformat(),
"duration": duration,
"message": "Monitor is healthy",
"monitor": monitor
"monitor": pmonitor
})

except Exception as e:
Expand All @@ -116,7 +118,7 @@ def check_http_monitor(monitor, gauges):
"time": vdate.isoformat(),
"message": "Unexpected error",
"error": "{}".format(e),
"monitor": monitor
"monitor": pmonitor
})

gauges = {}
Expand Down

0 comments on commit 83aa492

Please sign in to comment.