X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=src%2Fawk%2Flib%2Fmsg.awk;fp=src%2Fawk%2Flib%2Fmsg.awk;h=0000000000000000000000000000000000000000;hb=53d24ad688ea39892dbf3c748c1e40514eeb2763;hp=fba25e7884af648ca5318c924e13352d1811a57c;hpb=0c4f892ec9d0cd7dc87c83c01b52259d0aed1ae3;p=khatus.git diff --git a/src/awk/lib/msg.awk b/src/awk/lib/msg.awk deleted file mode 100644 index fba25e7..0000000 --- a/src/awk/lib/msg.awk +++ /dev/null @@ -1,91 +0,0 @@ -BEGIN { - FS1 = "|" # Fiels separator, level 1 (record to fields) - FS2 = ":" # Fiels separator, level 2 (field to subfields - - OFS = FS1 - Kfs = FS2 -} - -function msg_parse(msg, line, status, fields, type) { - split(line, fields, FS1) - msg["node"] = fields[1] - msg["module"] = fields[2] - type = fields[3] - msg["type"] = type - - status = 1 - if (type == "data") { - msg["key"] = fields[4] - msg["val"] = str_tail(str_join(fields, 1, 4, FS1) FS1, line) - } else if (type == "error") { - msg["line"] = str_tail(str_join(fields, 1, 3, FS1) FS1, line) - } else if (type == "alert") { - msg["priority"] = fields[4] - msg["subject"] = fields[5] - msg["body"] = str_tail(str_join(fields, 1, 5, FS1) FS1, line) - } else if (type == "log") { - msg["location"] = fields[4] - msg["level"] = fields[5] - msg["msg"] = str_tail(str_join(fields, 1, 5, FS1) FS1, line) - } else if (type == "status_bar") { - msg["status_bar"] = str_tail(str_join(fields, 1, 3, FS1) FS1, line) - } else { - msg_out_log_error(\ - "msg_parse", - "Unexpected msg type: " type " in given input line: " line \ - ) - status = 0 - } - return status -} - -# ----------------------------------------------------------------------------- -# alert -# ----------------------------------------------------------------------------- -function msg_out_alert_low(subject, body) { - msg_out_alert("low", subject, body) -} - -function msg_out_alert_med(subject, body) { - msg_out_alert("med", subject, body) -} - -function msg_out_alert_hi(subject, body) { - msg_out_alert("hi", subject, body) -} - -function msg_out_alert(priority, subject, body) { - # priority : "low" | "med" | "hi" - # subject : string without spaces - # body : anything - print(Node, Module, "alert", priority, subject, body) -} - -# ----------------------------------------------------------------------------- -# log -# ----------------------------------------------------------------------------- -function msg_out_log_info(location, msg) { - msg_out_log("info", location, msg) -} - -function msg_out_log_error(location, msg) { - msg_out_log("error", location, msg) -} - -function msg_out_log(level, location, msg) { - print(Node, Module, "log", location, level, msg) > "/dev/stderr" -} - -# ----------------------------------------------------------------------------- -# status_bar -# ----------------------------------------------------------------------------- -function msg_out_status_bar(bar) { - print(Node, Module, "status_bar", bar) -} - -# ----------------------------------------------------------------------------- -# data -# ----------------------------------------------------------------------------- -function msg_out_data(key, val) { - print(Node, Module, "data", key, val) -}