You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor alert handling in monitoring scripts to improve reliability
- Updated multiple monitoring scripts to conditionally send alerts based on the availability of the `send_alert` function, ensuring that alerts do not fail if the function is unavailable.
- Enhanced logging for various checks, including server resources, ETL job execution, and WMS service availability, to improve alert handling and robustness.
- Cleaned up code for better readability and consistency across the scripts, contributing to overall maintainability.
send_alert "WARNING""${COMPONENT}""Planet Notes check took too long: ${duration}s (threshold: ${planet_duration_threshold}s)"
111
+
# Only send alert if send_alert function is available
112
+
ifcommand -v send_alert >/dev/null 2>&1;then
113
+
send_alert "${COMPONENT}""WARNING""planet_check_duration""Planet Notes check took too long: ${duration}s (threshold: ${planet_duration_threshold}s)"||true
log_warning "${COMPONENT}: Newest backup is ${newest_backup_age}s old (threshold: ${threshold}s)"
166
-
send_alert "${COMPONENT}""WARNING""backup_freshness_exceeded""Newest backup is ${newest_backup_age}s old (threshold: ${threshold}s, directory: ${backup_dir})"
167
-
return 1
167
+
# Alert if newest backup is too old
168
+
if [[ ${newest_backup_age}-gt${threshold} ]];then
169
+
log_warning "${COMPONENT}: Newest backup is ${newest_backup_age}s old (threshold: ${threshold}s)"
170
+
ifcommand -v send_alert >/dev/null 2>&1;then
171
+
send_alert "${COMPONENT}""WARNING""backup_freshness_exceeded""Newest backup is ${newest_backup_age}s old (threshold: ${threshold}s, directory: ${backup_dir})"||true
log_warning "${COMPONENT}: Network connectivity check found ${connectivity_failures} failure(s)"
514
-
send_alert "${COMPONENT}""WARNING""network_connectivity_failure""Network connectivity check found ${connectivity_failures} failure(s) out of ${total_checks} hosts checked"
524
+
ifcommand -v send_alert >/dev/null 2>&1;then
525
+
send_alert "${COMPONENT}""WARNING""network_connectivity_failure""Network connectivity check found ${connectivity_failures} failure(s) out of ${total_checks} hosts checked"||true
log_warning "${COMPONENT}: Service dependencies check found ${service_failures} failure(s)"
664
-
send_alert "${COMPONENT}""WARNING""service_dependency_failure""Service dependencies check found ${service_failures} failure(s) out of ${total_services} services checked"
680
+
ifcommand -v send_alert >/dev/null 2>&1;then
681
+
send_alert "${COMPONENT}""WARNING""service_dependency_failure""Service dependencies check found ${service_failures} failure(s) out of ${total_services} services checked"||true
0 commit comments