|
|
78c0ed |
From eb2dc4ec0879290f42e35a7facc345ca1c70ba69 Mon Sep 17 00:00:00 2001
|
|
|
98d1c2 |
From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= <raphael.pinson@camptocamp.com>
|
|
|
98d1c2 |
Date: Tue, 12 Nov 2019 13:33:26 +0100
|
|
|
78c0ed |
Subject: [PATCH 2/8] Rsyslog: support multiple actions in filters and
|
|
|
78c0ed |
selectors (#653)
|
|
|
98d1c2 |
|
|
|
98d1c2 |
(cherry picked from commit 5181105bae84dc7819a00886f068ad0bb4e6d05a)
|
|
|
98d1c2 |
---
|
|
|
98d1c2 |
lenses/rsyslog.aug | 11 ++++++++---
|
|
|
98d1c2 |
lenses/tests/test_rsyslog.aug | 37 +++++++++++++++++++++++++++++++++++
|
|
|
98d1c2 |
2 files changed, 45 insertions(+), 3 deletions(-)
|
|
|
98d1c2 |
|
|
|
98d1c2 |
diff --git a/lenses/rsyslog.aug b/lenses/rsyslog.aug
|
|
|
98d1c2 |
index 7b9f7dc9..29ff9b10 100644
|
|
|
98d1c2 |
--- a/lenses/rsyslog.aug
|
|
|
98d1c2 |
+++ b/lenses/rsyslog.aug
|
|
|
98d1c2 |
@@ -65,11 +65,17 @@ let hostname = [ label "hostname" .
|
|
|
98d1c2 |
( Syslog.plus | [ Build.xchgs "-" "reverse" ] ) .
|
|
|
98d1c2 |
Syslog.hostnames . Util.eol . Syslog.entries ]
|
|
|
98d1c2 |
|
|
|
98d1c2 |
+(* View: actions *)
|
|
|
98d1c2 |
+let actions =
|
|
|
98d1c2 |
+ let prop_act = [ label "action" . action ]
|
|
|
98d1c2 |
+ in let act_sep = del /[ \t]*\n&[ \t]*/ "\n& "
|
|
|
98d1c2 |
+ in Build.opt_list prop_act act_sep
|
|
|
98d1c2 |
+
|
|
|
98d1c2 |
(* View: entry
|
|
|
98d1c2 |
An entry contains selectors and an action
|
|
|
98d1c2 |
*)
|
|
|
98d1c2 |
let entry = [ label "entry" . Syslog.selectors . Syslog.sep_tab .
|
|
|
98d1c2 |
- [ label "action" . action ] . Util.eol ]
|
|
|
98d1c2 |
+ actions . Util.eol ]
|
|
|
98d1c2 |
|
|
|
98d1c2 |
(* View: prop_filter
|
|
|
98d1c2 |
Parses property-based filters, which start with ":" and the property name *)
|
|
|
98d1c2 |
@@ -78,9 +84,8 @@ let prop_filter =
|
|
|
98d1c2 |
in let prop_name = [ Util.del_str ":" . label "property" . store Rx.word ]
|
|
|
98d1c2 |
in let prop_oper = [ label "operation" . store /[A-Za-z!-]+/ ]
|
|
|
98d1c2 |
in let prop_val = [ label "value" . Quote.do_dquote (store /[^\n"]*/) ]
|
|
|
98d1c2 |
- in let prop_act = [ label "action" . action ]
|
|
|
98d1c2 |
in [ label "filter" . prop_name . sep . prop_oper . sep . prop_val .
|
|
|
98d1c2 |
- Sep.space . prop_act . Util.eol ]
|
|
|
98d1c2 |
+ Sep.space . actions . Util.eol ]
|
|
|
98d1c2 |
|
|
|
98d1c2 |
let entries = ( Syslog.empty | Util.comment | entry | macro | config_object | prop_filter )*
|
|
|
98d1c2 |
|
|
|
98d1c2 |
diff --git a/lenses/tests/test_rsyslog.aug b/lenses/tests/test_rsyslog.aug
|
|
|
98d1c2 |
index 9011a2b3..e83613a2 100644
|
|
|
98d1c2 |
--- a/lenses/tests/test_rsyslog.aug
|
|
|
98d1c2 |
+++ b/lenses/tests/test_rsyslog.aug
|
|
|
98d1c2 |
@@ -222,3 +222,40 @@ test Rsyslog.lns get "*.* ?DynamicFile\n" =
|
|
|
98d1c2 |
{ "dynamic" = "DynamicFile" }
|
|
|
98d1c2 |
}
|
|
|
98d1c2 |
}
|
|
|
98d1c2 |
+
|
|
|
98d1c2 |
+(* Multiple actions in filters and selectors *)
|
|
|
98d1c2 |
+test Rsyslog.lns get ":msg, startswith, \"iptables:\" -/var/log/iptables.log
|
|
|
98d1c2 |
+& ~
|
|
|
98d1c2 |
+# Save boot messages also to boot.log
|
|
|
98d1c2 |
+local7.* /var/log/boot.log
|
|
|
98d1c2 |
+local3.err /var/log/nfsen/nfsenlog
|
|
|
98d1c2 |
+& /var/log/also.log
|
|
|
98d1c2 |
+\n" =
|
|
|
98d1c2 |
+ { "filter"
|
|
|
98d1c2 |
+ { "property" = "msg" }
|
|
|
98d1c2 |
+ { "operation" = "startswith" }
|
|
|
98d1c2 |
+ { "value" = "iptables:" }
|
|
|
98d1c2 |
+ { "action"
|
|
|
98d1c2 |
+ { "no_sync" }
|
|
|
98d1c2 |
+ { "file" = "/var/log/iptables.log" } }
|
|
|
98d1c2 |
+ { "action"
|
|
|
98d1c2 |
+ { "discard" } }
|
|
|
98d1c2 |
+ }
|
|
|
98d1c2 |
+ { "#comment" = "Save boot messages also to boot.log" }
|
|
|
98d1c2 |
+ { "entry"
|
|
|
98d1c2 |
+ { "selector"
|
|
|
98d1c2 |
+ { "facility" = "local7" }
|
|
|
98d1c2 |
+ { "level" = "*" } }
|
|
|
98d1c2 |
+ { "action"
|
|
|
98d1c2 |
+ { "file" = "/var/log/boot.log" } }
|
|
|
98d1c2 |
+ }
|
|
|
98d1c2 |
+ { "entry"
|
|
|
98d1c2 |
+ { "selector"
|
|
|
98d1c2 |
+ { "facility" = "local3" }
|
|
|
98d1c2 |
+ { "level" = "err" } }
|
|
|
98d1c2 |
+ { "action"
|
|
|
98d1c2 |
+ { "file" = "/var/log/nfsen/nfsenlog" } }
|
|
|
98d1c2 |
+ { "action"
|
|
|
98d1c2 |
+ { "file" = "/var/log/also.log" } } }
|
|
|
98d1c2 |
+ { }
|
|
|
98d1c2 |
+
|
|
|
98d1c2 |
--
|
|
|
78c0ed |
2.31.1
|
|
|
98d1c2 |
|