confd: extend syslogd support with hostname-based filtering

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-11-20 14:05:36 +01:00
parent f71755d8ca
commit 18e80ceb11
5 changed files with 30 additions and 3 deletions
@@ -1,5 +1,7 @@
# -l :: Keep kernel looging to console
# -H :: Log remote messages using hostname from the message
# -l :: Keep kernel logging to console
# -m0 :: Disable periodic syslog MARK entries
# -n :: Disable DNS query for every request, trust hostname in message
# -s :: Enable secure mode, don't listen to remote logs
# -r 1M:5 :: Log rotation every 1 MiB and keep 5 rotated ones
SYSLOGD_ARGS="-l -m0"
SYSLOGD_ARGS="-H -l -m0"
+14
View File
@@ -104,6 +104,20 @@ static size_t selector(sr_session_ctx_t *session, struct action *act)
char *pattern;
int rc;
/* Check for hostname-filter (infix-syslog augment) */
snprintf(xpath, sizeof(xpath), "%s/infix-syslog:hostname-filter", act->xpath);
rc = sr_get_items(session, xpath, 0, 0, &list, &count);
if (rc == SR_ERR_OK && count > 0) {
fprintf(act->fp, "+");
for (size_t i = 0; i < count; i++)
fprintf(act->fp, "%s%s", i ? "," : "", list[i].data.string_val);
fprintf(act->fp, "\n");
sr_free_values(list, count);
list = NULL;
count = 0;
}
/* Check for pattern-match (select-match feature) */
pattern = srx_get_str(session, "%s/pattern-match", act->xpath);
if (pattern) {
+1 -1
View File
@@ -19,7 +19,7 @@ MODULES=(
# NOTE: ietf-tls-client must be version matched with ietf-tls-server, used by netopeer2!
"ietf-tls-client@2023-12-28.yang"
"ietf-syslog@2024-03-21.yang -e file-action -e file-limit-size -e remote-action -e select-adv-compare -e select-match"
"infix-syslog@2024-07-19.yang"
"infix-syslog@2025-11-17.yang"
"iana-hardware@2018-03-13.yang"
"ietf-hardware@2018-03-13.yang -e hardware-state -e hardware-sensor"
"infix-hardware@2025-10-30.yang"
+11
View File
@@ -16,6 +16,11 @@ module infix-syslog {
contact "kernelkit@googlegroups.com";
description "Infix augments and deviations to ietf-syslog, draft 32.";
revision 2025-11-17 {
description "Add hostname-filter support.";
reference "internal";
}
revision 2024-07-19 {
description "Initial revision, based on IETF syslog YANG draft 32.
The following changes have been made in this model:
@@ -164,6 +169,12 @@ module infix-syslog {
}
}
}
leaf-list hostname-filter {
type inet:domain-name;
description "Filter messages by hostname. Messages from the listed
hostnames will be logged to this file.";
}
}
augment "/syslog:syslog/syslog:actions/syslog:remote/syslog:destination" {