logger: add support for -H NAME to override system hostname
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
parent
c7f65e11c9
commit
f32ca837c1
@ -37,6 +37,7 @@
|
|||||||
.Op Fl d Ar SD
|
.Op Fl d Ar SD
|
||||||
.Op Fl f Ar FILE
|
.Op Fl f Ar FILE
|
||||||
.Op Fl h Ar HOST
|
.Op Fl h Ar HOST
|
||||||
|
.Op Fl H Ar HOSTNAME
|
||||||
.Op Fl m Ar MSGID
|
.Op Fl m Ar MSGID
|
||||||
.Op Fl p Ar PRIO
|
.Op Fl p Ar PRIO
|
||||||
.Op Fl P Ar PORT
|
.Op Fl P Ar PORT
|
||||||
@ -95,6 +96,11 @@ accepts
|
|||||||
.Fl f-
|
.Fl f-
|
||||||
as an alias for
|
as an alias for
|
||||||
.Ar stdout .
|
.Ar stdout .
|
||||||
|
.It Fl H Ar hostname
|
||||||
|
Set the hostname in the header of the message to specified value.
|
||||||
|
If not specified, host part of
|
||||||
|
.Xr gethostname 3
|
||||||
|
will be used.
|
||||||
.It Fl h Ar host
|
.It Fl h Ar host
|
||||||
Send the message to the remote system
|
Send the message to the remote system
|
||||||
.Ar host
|
.Ar host
|
||||||
|
@ -236,6 +236,7 @@ static int usage(int code)
|
|||||||
" -d SD Log SD as RFC5424 style 'structured data' in message\n"
|
" -d SD Log SD as RFC5424 style 'structured data' in message\n"
|
||||||
" -f FILE Log file to write messages to, instead of syslog daemon\n"
|
" -f FILE Log file to write messages to, instead of syslog daemon\n"
|
||||||
" -h HOST Send (UDP) message to this remote syslog server (IP or DNS name)\n"
|
" -h HOST Send (UDP) message to this remote syslog server (IP or DNS name)\n"
|
||||||
|
" -H NAME Use NAME instead of system hostname in message header\n"
|
||||||
" -i Log process ID of the logger process with each line (LOG_PID)\n"
|
" -i Log process ID of the logger process with each line (LOG_PID)\n"
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
" -k Log to kernel /dev/kmsg if /dev/log doesn't exist yet\n"
|
" -k Log to kernel /dev/kmsg if /dev/log doesn't exist yet\n"
|
||||||
@ -277,7 +278,7 @@ int main(int argc, char *argv[])
|
|||||||
int c, num = 5;
|
int c, num = 5;
|
||||||
int rotate = 0;
|
int rotate = 0;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "46?bcd:f:h:ikm:np:P:r:st:u:v")) != EOF) {
|
while ((c = getopt(argc, argv, "46?bcd:f:h:H:ikm:np:P:r:st:u:v")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '4':
|
case '4':
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
@ -307,6 +308,10 @@ int main(int argc, char *argv[])
|
|||||||
host = optarg;
|
host = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'H':
|
||||||
|
strlcpy(log.log_hostname, optarg, sizeof(log.log_hostname));
|
||||||
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
log_opts |= LOG_PID;
|
log_opts |= LOG_PID;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user