Removed last remaining trace of last_alarm, only alert if it's new

This commit is contained in:
Trey Blancher 2023-08-25 18:06:02 -04:00
parent 427fb181d1
commit 7c6742a1b2
1 changed files with 17 additions and 16 deletions

View File

@ -282,7 +282,6 @@ while true; do
integer elapsed=$(( now - ${secs[${alarm}]} ))
if is_clear "${alarm}" && (( elapsed >= 300 )); then
current_alarms=$(sed -E "s/${alarm}\|?//" <<< "${current_alarms}")
last_alarm=$(awk -F'|' '{print $NF}' <<< "${current_alarms}")
unset "notice_sent[${alarm}]"
unset "secs[${alarm}]"
fi
@ -296,21 +295,23 @@ while true; do
continue
fi
last_line="${line}"
local psi_type="$(grep -Eo "(CPU|MEM|IO) PSI event" <<< "${line}" | grep -Eo "CPU|MEM|IO")"
if [[ -n "${psi_type}" ]]; then
secs+=(${psi_type} ${now})
if [[ ! ${notice_sent[${psi_type}]} ]]; then
last_dunst_id=$(exec_notices "${psi_type}" "${current_alarms}")
notice_sent+=(${psi_type} true)
elif (( last_dunst_id >= 0 )) && check_dunst_id_is_visible "${last_dunst_id}"; then
sleep 1
continue
fi
if [[ -z "${current_alarms}" ]]; then
current_alarms="${psi_type}"
else
if ! grep -q "${psi_type}" <<< "${current_alarms}"; then
current_alarms="${current_alarms}|${psi_type}"
if (( time_diff < 3 )); then
local psi_type="$(grep -Eo "(CPU|MEM|IO) PSI event" <<< "${line}" | grep -Eo "CPU|MEM|IO")"
if [[ -n "${psi_type}" ]]; then
secs+=(${psi_type} ${now})
if [[ ! ${notice_sent[${psi_type}]} ]]; then
last_dunst_id=$(exec_notices "${psi_type}" "${current_alarms}")
notice_sent+=(${psi_type} true)
elif (( last_dunst_id >= 0 )) && check_dunst_id_is_visible "${last_dunst_id}"; then
sleep 1
continue
fi
if [[ -z "${current_alarms}" ]]; then
current_alarms="${psi_type}"
else
if ! grep -q "${psi_type}" <<< "${current_alarms}"; then
current_alarms="${current_alarms}|${psi_type}"
fi
fi
fi
fi