Rsyslog 故障排除

Rsyslog 故障排除

请帮助我,我是一个新的 Linux 用户,我似乎无法看到这个脚本的问题出在哪里。

#!/bin/bash

sudo mkdir -v /var/spool/rsyslog
if [ "$(lsb_release -ds | grep Ubuntu)" != "" ]; then
    sudo chown -R syslog:adm /var/spool/rsyslog
fi

sudo mkdir -i /etc/rsyslog.d/21-logzio-sample.conf
{#   -------------------------------------------------------
#        File Logging Directives for Logz.io
#   -------------------------------------------------------
$ModLoad imfile
$InputFilePollInterval 10
$PrivDropToGroup adm
$WorkDirectory /var/spool/rsyslog
# File access file:
$InputFileName PATH_TO_FILE
$InputFileTag TYPE:
$InputFileStateFile stat-TYPE
$InputFileSeverity info
$InputFilePersistStateInterval 20000
$InputRunFileMonitor
$template logzFormatFileTagName,"[{{API_TOKEN}}] <%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [type=TYPE] %msg%\n"
if $programname == 'TYPE' then @@{{LOGZ_LISTENER}}:5000;logzFormatFileTagName
if $programname == 'TYPE' then ~
} >> /etc/rsyslog.d/21-logzio-sample.conf

sudo service rsyslog restart

答案1

sudo mkdir -i /etc/rsyslog.d/21-logzio-sample.conf将会失败

mkdir: invalid option -- 'i'
Try 'mkdir --help' for more information.

关于创建文件/etc/rsyslog.d/21-logzio-sample.conf,你应该使用如下命令:

cat > filename <<- "EOF"
file contents
more contents
EOF

脚本借自这里

相关内容