Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Create a user **systemd-journal-netlog**

The the address string format is similar to socket units. See systemd.socket(1)

Optional settings

StructuredData=
Meta information about the syslog message, which can be used for Cloud Based
syslog servers, such as Loggly

**EXAMPLE**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add to systemd-netlogd.conf.xml


Example 1. /etc/systemd/systemd-netlogd.conf
Expand All @@ -38,3 +44,9 @@ Example 2. /etc/systemd/systemd-netlogd.conf

[Network]
Address=192.168.8.101:514

Example 3. /etc/systemd/systemd-netlogd.conf

[Network]
Address=192.168.8.101:514
StructuredData=[1ab456b6-90bb-6578-abcd-5b734584aaaa@41058]
19 changes: 19 additions & 0 deletions man/systemd-netlogd.conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>StructuredData=</varname></term>
<listitem><para>Meta information about the syslog message,
which can be used for Cloud Based syslog servers, such as Loggly</para>

<para>The StructureData is only an optional setting</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand All @@ -103,6 +111,17 @@ Address=192.168.8.101:514
</example>
</refsect1>

<refsect1>
<title>Example</title>
<example>
<title>/etc/systemd/systemd-netlogd.conf</title>
<programlisting>[Network]
Address=192.168.8.101:514
StructuredData=[1ab456b6-90bb-6578-abcd-5b734584aaaa@41058]
</programlisting>
</example>
</refsect1>

<refsect1>
<title>See Also</title>
<para>
Expand Down
38 changes: 38 additions & 0 deletions src/conf-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,41 @@ int config_parse_many(const char *conf_file,
return 0; \
} \
struct __useless_struct_to_allow_trailing_semicolon__

int config_parse_string(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {

char **s = data, *n;

assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);

if (!utf8_is_valid(rvalue)) {
log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
return 0;
}

if (isempty(rvalue))
n = NULL;
else {
n = strdup(rvalue);
if (!n)
return log_oom();
}

free(*s);
*s = n;

return 0;
}
3 changes: 3 additions & 0 deletions src/conf-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ int config_parse_many(const char *conf_file, /* possibly NULL */
bool relaxed,
void *userdata);

/* Generic parsers */
int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);

#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \
int function(const char *unit, \
const char *filename, \
Expand Down
1 change: 1 addition & 0 deletions src/netlog-gperf.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ struct ConfigPerfItem;
%includes
%%
Network.Address, config_parse_netlog_remote_address, 0, 0
Network.StructuredData, config_parse_string, 0, offsetof(Manager, structured_data)
1 change: 1 addition & 0 deletions src/netlog-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct Manager {
char *state_file;

char *last_cursor, *current_cursor;
char *structured_data;
};

int manager_new(Manager **ret, const char *state_file, const char *cursor);
Expand Down
6 changes: 5 additions & 1 deletion src/netlog-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ int manager_push_to_network(Manager *m,
IOVEC_SET_STRING(iov[n++], " ");

/* Eighth: [structured-data] */
IOVEC_SET_STRING(iov[n++], RFC_5424_NILVALUE);
if (m->structured_data)
IOVEC_SET_STRING(iov[n++], m->structured_data);
else
IOVEC_SET_STRING(iov[n++], RFC_5424_NILVALUE);

IOVEC_SET_STRING(iov[n++], " ");

/* Ninth: message */
Expand Down