bat_alert_spec[5] = "hi|Energy_CRITICALLY_Low|CHARGE NOW!!! GO GO GO!!!"
}
-$1 == "OK" && \
+$1 == Node && \
$2 == "khatus_sensor_energy" && \
-$3 == "line_power" {
+$3 == "data" && \
+$4 == "line_power" {
line_power_prev = line_power_curr
- line_power_curr = $4
+ line_power_curr = $5
if (line_power_curr == "no" && line_power_prev != "no") {
- msg_out_ok_alert("low", "PowerUnplugged", "")
+ msg_out_alert_low("PowerUnplugged", "")
}
}
-$1 == "OK" && \
+$1 == Node && \
$2 == "khatus_sensor_energy" && \
-$3 == "battery_state" {
+$3 == "data" && \
+$4 == "battery_state" {
battery_state_prev = battery_state_curr
- battery_state_curr = $4
+ battery_state_curr = $5
}
-$1 == "OK" && \
+$1 == Node && \
$2 == "khatus_sensor_energy" && \
-$3 == "battery_percentage" {
+$3 == "data" && \
+$4 == "battery_percentage" {
# TODO: Re-think the spec - can't rely on order of keys
- battery_percentage = util_ensure_numeric($4)
+ battery_percentage = num_ensure_numeric($5)
if (battery_state_curr == "discharging") {
for (threshold in bat_alert_spec) {
- threshold = util_ensure_numeric(threshold)
+ threshold = num_ensure_numeric(threshold)
if (battery_percentage <= threshold && !_alerted[threshold]) {
- split(bat_alert_spec[threshold], msg, "|")
- priority = msg[1]
- subject = msg[2]
- body = sprintf("%d%% %s", battery_percentage, msg[3])
- msg_out_ok_alert(priority, subject, body)
+ split(bat_alert_spec[threshold], alert, "|")
+ priority = alert[1]
+ subject = alert[2]
+ body = sprintf("%d%% %s", battery_percentage, alert[3])
+ msg_out_alert(priority, subject, body)
_alerted[threshold]++
}
}