2 FS1 =
"|" # Fields separator, level 1 (record to fields)
3 FS2 =
":" # Fields separator, level 2 (field to subfields
9 function msg_parse
(msg
, line
, status
, fields
, type
) {
10 split(line
, fields
, FS1
)
11 msg
["node"] = fields
[1]
12 msg
["module"] = fields
[2]
18 msg
["key"] = fields
[4]
19 msg
["val"] = str_tail
(str_join
(fields
, 1, 4, FS1
) FS1
, line
)
20 } else if (type ==
"error") {
21 msg
["line"] = str_tail
(str_join
(fields
, 1, 3, FS1
) FS1
, line
)
22 } else if (type ==
"alert") {
23 msg
["priority"] = fields
[4]
24 msg
["subject"] = fields
[5]
25 msg
["body"] = str_tail
(str_join
(fields
, 1, 5, FS1
) FS1
, line
)
26 } else if (type ==
"log") {
27 msg
["location"] = fields
[4]
28 msg
["level"] = fields
[5]
29 msg
["msg"] = str_tail
(str_join
(fields
, 1, 5, FS1
) FS1
, line
)
30 } else if (type ==
"status_bar") {
31 msg
["status_bar"] = str_tail
(str_join
(fields
, 1, 3, FS1
) FS1
, line
)
35 "Unexpected msg type: " type
" in given input line: " line \
42 # -----------------------------------------------------------------------------
44 # -----------------------------------------------------------------------------
45 function msg_out_alert_low
(subject
, body
) {
46 msg_out_alert
("low", subject
, body
)
49 function msg_out_alert_med
(subject
, body
) {
50 msg_out_alert
("med", subject
, body
)
53 function msg_out_alert_hi
(subject
, body
) {
54 msg_out_alert
("hi", subject
, body
)
57 function msg_out_alert
(priority
, subject
, body
) {
58 # priority : "low" | "med" | "hi"
59 # subject : string without spaces
61 print(Node
, Module
, "alert", priority
, subject
, body
)
64 # -----------------------------------------------------------------------------
66 # -----------------------------------------------------------------------------
67 function msg_out_log_info
(location
, msg
) {
68 msg_out_log
("info", location
, msg
)
71 function msg_out_log_error
(location
, msg
) {
72 msg_out_log
("error", location
, msg
)
75 function msg_out_log
(level
, location
, msg
) {
76 print(Node
, Module
, "log", location
, level
, msg
) > "/dev/stderr"
79 # -----------------------------------------------------------------------------
81 # -----------------------------------------------------------------------------
82 function msg_out_status_bar
(bar
) {
83 print(Node
, Module
, "status_bar", bar
)
86 # -----------------------------------------------------------------------------
88 # -----------------------------------------------------------------------------
89 function msg_out_data
(key
, val
) {
90 print(Node
, Module
, "data", key
, val
)
This page took 0.081069 seconds and 4 git commands to generate.