clean:
rm -f $(AWK_EXECUTABLES)
-
bin/khatus_bar: \
src/awk/exe/bar.awk \
src/awk/lib/cache.awk \
bin/khatus_actuate_device_add_to_automount: \
src/awk/exe/actuate_device_add_to_automount.awk \
src/awk/lib/msg_in.awk \
- src/awk/lib/msg_out.awk \
- src/awk/lib/alert.awk
+ src/awk/lib/msg_out.awk
$(BUILD_AWK_EXE)
bin/khatus_actuate_status_bar_to_xsetroot_name: \
bin/khatus_monitor_devices: \
src/awk/exe/monitor_devices.awk \
src/awk/lib/msg_in.awk \
- src/awk/lib/msg_out.awk \
- src/awk/lib/alert.awk
+ src/awk/lib/msg_out.awk
$(BUILD_AWK_EXE)
bin/khatus_monitor_energy: \
src/awk/exe/monitor_energy.awk \
src/awk/lib/msg_in.awk \
src/awk/lib/msg_out.awk \
- src/awk/lib/alert.awk \
src/awk/lib/util.awk
$(BUILD_AWK_EXE)
bin/khatus_monitor_errors: \
src/awk/exe/monitor_errors.awk \
src/awk/lib/msg_in.awk \
- src/awk/lib/msg_out.awk \
- src/awk/lib/alert.awk
+ src/awk/lib/msg_out.awk
$(BUILD_AWK_EXE)
bin/khatus_parse_bluetoothctl_show: \
}
$1 == "OK" && \
-$3 == "alert" {
+$3 ~ /^alert/ {
src = $2
- priority = $4
- subject = $5
+ key = $3
+ split(key, key_parts, Kfs)
+ priority = key_parts[2]
+ subject = key_parts[3]
# Not just using $6 for body - because body might contain a character
# identical to FS
path_mnt=line
sub("^Mounted " path_dev " at ", "", path_mnt)
sub("\.$", "", path_mnt)
- alert("low", "successfully-mounted", path_dev " to " path_mnt)
+ msg_out_ok_alert("low", "successfully-mounted", path_dev " to " path_mnt)
if (Execute_On_Mount) {
system(Execute_On_Mount " '" path_mnt "'")
}
} else {
- alert("hi", "unexpected-success-line", line)
+ msg_out_ok_alert("hi", "unexpected-success-line", line)
}
}
} else {
- alert("hi", "failed-to-mount-device", path)
+ msg_out_ok_alert("hi", "failed-to-mount-device", path)
}
}
$1 == "OK" && \
$2 == "khatus_sensor_devices" \
{
- alert("low", "BlockDeviceEvent", $3 " " $4)
+ msg_out_ok_alert("low", "BlockDeviceEvent", $3 " " $4)
}
line_power_prev = line_power_curr
line_power_curr = $4
if (line_power_curr == "no" && line_power_prev != "no") {
- alert("low", "PowerUnplugged", "")
+ msg_out_ok_alert("low", "PowerUnplugged", "")
}
}
priority = msg[1]
subject = msg[2]
body = sprintf("%d%% %s", battery_percentage, msg[3])
- alert(priority, subject, body)
+ msg_out_ok_alert(priority, subject, body)
_alerted[threshold]++
}
}
len_head = length($1 FS $2 FS)
len_body = len_line - len_head
body = substr($0, len_head + 1, len_body)
- alert("hi", "ERROR_IN_" src, body)
+ msg_out_ok_alert("hi", "ERROR_IN_" src, body)
}
+++ /dev/null
-function alert(priority, subject, body) {
- # priority : "low" | "med" | "hi"
- # subject : string without spaces
- # body : anything
- print("OK", Module, "alert", priority, subject, body)
-}
Kfs = Key_fs ? Key_fs : ":"
}
+function msg_out_ok_alert(priority, subject, body, key, val) {
+ # priority : "low" | "med" | "hi"
+ # subject : string without spaces
+ # body : anything
+ key = "alert" Kfs priority Kfs subject
+ val = body
+ msg_out_ok(key, val)
+}
+
function msg_out_ok(key, val) {
msg_out("OK", key, val, "/dev/stdout")
}