Support for sending messages to a custom port on remote server
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
ff4b9e0499
commit
533ca61faa
@ -59,6 +59,7 @@ Main differences from the original sysklogd package are:
|
|||||||
- Full [RFC3164][] and [RFC5424][] support
|
- Full [RFC3164][] and [RFC5424][] support
|
||||||
- Includes timestamp and hostname, RFC3164 style, in remote logging
|
- Includes timestamp and hostname, RFC3164 style, in remote logging
|
||||||
- Support for sending RFC5424 style remote syslog messages
|
- Support for sending RFC5424 style remote syslog messages
|
||||||
|
- Support for sending messages to a custom port on a remote server
|
||||||
- Includes a `logger` tool with RFC5424 capabilities (`msgid` etc.)
|
- Includes a `logger` tool with RFC5424 capabilities (`msgid` etc.)
|
||||||
- Includes a library and system header replacement for logging
|
- Includes a library and system header replacement for logging
|
||||||
- FreeBSD socket receive buffer size patch
|
- FreeBSD socket receive buffer size patch
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
** sysklogd v2.0
|
** sysklogd v2.0
|
||||||
|
|
||||||
*** TODO Add support for @host:port, i.e. custom remote port to send to
|
*** DONE Add support for @host:port, i.e. custom remote port to send to
|
||||||
*** DONE Add example application, test building and running it from Travis-CI
|
*** DONE Add example application, test building and running it from Travis-CI
|
||||||
*** DONE Check for memory/descriptor leaks, valgrind/Coverity
|
*** DONE Check for memory/descriptor leaks, valgrind/Coverity
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ RULE := SELECTOR ACTION [;OPTION]
|
|||||||
SELECTOR := [SELECTOR;]facility[,facility].[!=]severity
|
SELECTOR := [SELECTOR;]facility[,facility].[!=]severity
|
||||||
ACTION := /path/to/file
|
ACTION := /path/to/file
|
||||||
|= |/path/to/named/pipe
|
|= |/path/to/named/pipe
|
||||||
|= @remote[.host.tld]
|
|= @remote[.host.tld][:PORT]
|
||||||
OPTION := [OPTION,]
|
OPTION := [OPTION,]
|
||||||
|= RFC3164
|
|= RFC3164
|
||||||
|= RFC5424
|
|= RFC5424
|
||||||
@ -276,7 +276,9 @@ Full remote logging support is available in
|
|||||||
.Nm syslogd ,
|
.Nm syslogd ,
|
||||||
i.e. to send messages to a remote syslog server, and and to receive
|
i.e. to send messages to a remote syslog server, and and to receive
|
||||||
messages from remote hosts. To forward messages to another host,
|
messages from remote hosts. To forward messages to another host,
|
||||||
prepend the hostname with the at sign ('@').
|
prepend the hostname with the at sign ('@'). If a port number is added
|
||||||
|
after a colon (':') then that port will be used as the destination port
|
||||||
|
rather than the usual syslog port.
|
||||||
.Pp
|
.Pp
|
||||||
This feature makes it possible to collect all syslog messages in a
|
This feature makes it possible to collect all syslog messages in a
|
||||||
network on a central host. This reduces administration needs and
|
network on a central host. This reduces administration needs and
|
||||||
@ -488,13 +490,15 @@ command line option,
|
|||||||
*.*;kern.none -/var/log/messages ;rotate=100k:10
|
*.*;kern.none -/var/log/messages ;rotate=100k:10
|
||||||
.Ed
|
.Ed
|
||||||
.Ss Logging to Remote Syslog Server
|
.Ss Logging to Remote Syslog Server
|
||||||
This rule redirects all messages to a remote host called
|
This rule redirects all messages to one remote host called
|
||||||
.Ql finlandia
|
.Ql finlandia ,
|
||||||
with RFC5424 style formatting. This is useful especially in a cluster
|
with RFC5424 style formatting, and another remote host called
|
||||||
of machines where all syslog messages will be stored on only one
|
.Ql sibelius ,
|
||||||
machine.
|
but on a non-standard port and with RFC3164 formatting (i.e.,
|
||||||
|
including timestamp and hostname).
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
*.* @finlandia ;RFC5424
|
*.* @finlandia ;RFC5424
|
||||||
|
*.* @sibelius:5514 ;RFC3164
|
||||||
.Ed
|
.Ed
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -compact -width /etc/syslog.d/*.conf
|
.Bl -tag -compact -width /etc/syslog.d/*.conf
|
||||||
|
@ -1612,7 +1612,7 @@ void fprintlog(struct filed *f, struct buf_msg *buffer)
|
|||||||
f->f_type = F_FORW;
|
f->f_type = F_FORW;
|
||||||
goto f_forw;
|
goto f_forw;
|
||||||
} else {
|
} else {
|
||||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
logit(" %s:%s\n", f->f_un.f_forw.f_hname, f->f_un.f_forw.f_serv);
|
||||||
logit("Forwarding suspension not over, time left: %d.\n",
|
logit("Forwarding suspension not over, time left: %d.\n",
|
||||||
INET_SUSPEND_TIME - fwd_suspend);
|
INET_SUSPEND_TIME - fwd_suspend);
|
||||||
}
|
}
|
||||||
@ -1627,15 +1627,16 @@ void fprintlog(struct filed *f, struct buf_msg *buffer)
|
|||||||
* is started after syslogd.
|
* is started after syslogd.
|
||||||
*/
|
*/
|
||||||
case F_FORW_UNKN:
|
case F_FORW_UNKN:
|
||||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
logit(" %s:%s\n", f->f_un.f_forw.f_hname, f->f_un.f_forw.f_serv);
|
||||||
fwd_suspend = time(NULL) - f->f_time;
|
fwd_suspend = time(NULL) - f->f_time;
|
||||||
if (fwd_suspend >= INET_SUSPEND_TIME) {
|
if (fwd_suspend >= INET_SUSPEND_TIME) {
|
||||||
char *host = f->f_un.f_forw.f_hname;;
|
char *host = f->f_un.f_forw.f_hname;
|
||||||
|
char *serv = f->f_un.f_forw.f_serv;
|
||||||
|
|
||||||
logit("Forwarding suspension to %s over, retrying\n", host);
|
logit("Forwarding suspension to %s:%s over, retrying\n", host, serv);
|
||||||
err = nslookup(host, service, &ai);
|
err = nslookup(host, serv, &ai);
|
||||||
if (err) {
|
if (err) {
|
||||||
logit("Failure resolving %s:%s: %s\n", host, service, gai_strerror(err));
|
logit("Failure resolving %s:%s: %s\n", host, serv, gai_strerror(err));
|
||||||
logit("Retries: %d\n", f->f_prevcount);
|
logit("Retries: %d\n", f->f_prevcount);
|
||||||
if (--f->f_prevcount < 0) {
|
if (--f->f_prevcount < 0) {
|
||||||
flog(LOG_SYSLOG | LOG_WARN, "Still cannot find %s, "
|
flog(LOG_SYSLOG | LOG_WARN, "Still cannot find %s, "
|
||||||
@ -1667,7 +1668,7 @@ void fprintlog(struct filed *f, struct buf_msg *buffer)
|
|||||||
* sent the message, we don't send it anyway) -Joey
|
* sent the message, we don't send it anyway) -Joey
|
||||||
*/
|
*/
|
||||||
f_forw:
|
f_forw:
|
||||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
logit(" %s:%s\n", f->f_un.f_forw.f_hname, f->f_un.f_forw.f_serv);
|
||||||
if (strcmp(buffer->hostname, LocalHostName) && NoHops)
|
if (strcmp(buffer->hostname, LocalHostName) && NoHops)
|
||||||
logit("Not sending message to remote.\n");
|
logit("Not sending message to remote.\n");
|
||||||
else if (finet) {
|
else if (finet) {
|
||||||
@ -2598,10 +2599,17 @@ static struct filed *cfline(char *line)
|
|||||||
case '@':
|
case '@':
|
||||||
cfopts(p, f);
|
cfopts(p, f);
|
||||||
|
|
||||||
strlcpy(f->f_un.f_forw.f_hname, ++p, sizeof(f->f_un.f_forw.f_hname));
|
bp = strchr(++p, ':');
|
||||||
logit("forwarding host: '%s'\n", p); /*ASP*/
|
if (bp)
|
||||||
|
*bp++ = 0;
|
||||||
|
else
|
||||||
|
bp = service;
|
||||||
|
|
||||||
err = nslookup(p, service, &ai);
|
strlcpy(f->f_un.f_forw.f_hname, p, sizeof(f->f_un.f_forw.f_hname));
|
||||||
|
strlcpy(f->f_un.f_forw.f_serv, bp, sizeof(f->f_un.f_forw.f_serv));
|
||||||
|
logit("forwarding host: '%s:%s'\n", p, bp);
|
||||||
|
|
||||||
|
err = nslookup(p, bp, &ai);
|
||||||
if (err) {
|
if (err) {
|
||||||
flog(LOG_SYSLOG | LOG_WARN, "Cannot find %s, "
|
flog(LOG_SYSLOG | LOG_WARN, "Cannot find %s, "
|
||||||
"will try again later: %s", p, gai_strerror(err));
|
"will try again later: %s", p, gai_strerror(err));
|
||||||
|
@ -191,6 +191,7 @@ struct filed {
|
|||||||
char f_uname[MAXUNAMES][UNAMESZ + 1];
|
char f_uname[MAXUNAMES][UNAMESZ + 1];
|
||||||
struct {
|
struct {
|
||||||
char f_hname[MAXHOSTNAMELEN + 1];
|
char f_hname[MAXHOSTNAMELEN + 1];
|
||||||
|
char f_serv[20];
|
||||||
struct addrinfo *f_addr;
|
struct addrinfo *f_addr;
|
||||||
} f_forw; /* forwarding address */
|
} f_forw; /* forwarding address */
|
||||||
char f_fname[MAXFNAME];
|
char f_fname[MAXFNAME];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user