Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rsyslog';s imfile插件在CentOS 7上不工作?_File_Logging_Plugins_Centos7_Rsyslog - Fatal编程技术网

Rsyslog';s imfile插件在CentOS 7上不工作?

Rsyslog';s imfile插件在CentOS 7上不工作?,file,logging,plugins,centos7,rsyslog,File,Logging,Plugins,Centos7,Rsyslog,我正在尝试让Rsyslog的imfile插件在没有 任何真正的成功 以下是有用的操作系统版本信息: # cat /etc/centos-release CentOS Linux release 7.1.1503 (Core) # rsyslogd -v rsyslogd 7.4.7, compiled with: FEATURE_REGEXP: Yes FEATURE_LARGEFILE:

我正在尝试让Rsyslog的
imfile
插件在没有 任何真正的成功

以下是有用的操作系统版本信息:

# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
# rsyslogd -v
rsyslogd 7.4.7, compiled with:
        FEATURE_REGEXP:                         Yes
        FEATURE_LARGEFILE:                      No
        GSSAPI Kerberos 5 support:              Yes
        FEATURE_DEBUG (debug build, slow code): No
        32bit Atomic operations supported:      Yes
        64bit Atomic operations supported:      Yes
        Runtime Instrumentation (slow code):    No
        uuid support:                           Yes

See http://www.rsyslog.com for more information.
以下是Rsyslog版本信息:

# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
# rsyslogd -v
rsyslogd 7.4.7, compiled with:
        FEATURE_REGEXP:                         Yes
        FEATURE_LARGEFILE:                      No
        GSSAPI Kerberos 5 support:              Yes
        FEATURE_DEBUG (debug build, slow code): No
        32bit Atomic operations supported:      Yes
        64bit Atomic operations supported:      Yes
        Runtime Instrumentation (slow code):    No
        uuid support:                           Yes

See http://www.rsyslog.com for more information.
我尝试了配置的传统和RainerScript格式。 遗憾的是,它们都不适合我。我一定是做错了什么事 但我根本无法决定它会是什么

这是我的实际测试配置(在RainerScript中 我测试的前遗留版本的含义完全相同):

没有上述Rsyslog产生警告或错误 配置,但也不能从
/tmp/test input.in
文件中获取任何信息 被复制到
/tmp/test file.log

(当然,我还仔细检查了
/var/log/audit/audit.log
,然后。。。 没什么可疑的。对发生的事情感到绝望,我也 试图
setEnforce0
完全关闭SELinux并重新启动 Rsyslog随后被删除。它没有帮助解决问题的根本原因 可能与SELinux无关。)

此外,在全局数据库中正确创建了
测试输入.state
文件
workDirectory
路径(在本测试案例中为
/tmp
)。我也试过了 标准路径(日志位于
/var/log
,状态文件位于
/var/lib/rsyslog
) 尽管所有相关文件都已正确创建,但它也不起作用

奇怪的是:如果我填充 即使在Rsyslog重新启动后,也可以使用
#systemctl restart rsyslog
(默认情况下应更新状态文件)

需要指出的是:
imjournal
imuxsock
插件可以正常工作并填充回退日志文件
/tmp/rsyslog testing.log
。阿尔索 使用
-D
和/或
-D
选项在前台手动运行Rsyslog 没有帮助我澄清为什么
imfile
插件不起作用 对于我来说,在这个特定的配置中

那么,你能不能

  • 检查我的RainerScript语法是否没有明显的错误(我想没有明显的错误)
  • 演示EL7上的一些工作
    imfile
    插件配置
  • 多谢各位

    --
    mjf

    经过一些小改动,它终于开始正常工作。我认为 在我的案例中,问题的主要根本原因一定是我在中进行了测试
    /tmp
    目录,其中Rsyslog在某些情况下似乎无法正常工作 CentOS 7上的原因

    (可能是文件系统名称空间填充了
    /tmp
    ) 尽管Systemd选项
    PrivateTmp
    在中未设置为
    true
    Rsyslog单位文件和此选项应设置为
    false
    根据Systemd手册页面的默认设置?这是非常不可能的,但是 我还没想办法深入研究如果我发现了, 我将更新此答案。)

    另一个次要原因可能是写入的筛选器不正确 RainerScript(我的真实测试实例包含一个可怕的打字错误I 只是看得太多了)。所以这里是最终的测试配置 对我来说很有魅力

    # cat /etc/rsyslog.conf
    global(
        workDirectory = "/var/lib/rsyslog"
    )
    
    module(
        load = "imuxsock"
    )
    
    module(
        load = "imjournal"
        stateFile = "journal.state"
    )
    
    module(
        load = "imfile"
        pollingInterval = "10"
    )
    
    ruleset(name = "test-ruleset") {
        if $programname == "test-syslogtag" then {
            action(
                type = "omfile"
                file = "/var/log/test-file.log"
            )
            stop
        }
    }
    
    input(
        type = "imfile"
        tag = "test-syslogtag:"
        stateFile = "test-input.state"
        facility = "daemon"
        severity = "debug"
        file = "/var/log/test-input.in"
        ruleset = "test-ruleset"
    )
    
    if prifilt("*.*") then {
        action(
            type = "omfile"
            file = "/var/log/rsyslog-testing.log"
        )
    }
    
    给那些不知道它的人一点提示-
    $syslogtag
    $programname
    似乎是近亲:
    $syslogtag:=$programname:“
    。 您可以轻松找到所有可以匹配的
    $
    前缀变量 使用已在中编译的
    RSYSLOG\u DebugFormat
    输出模板

    我希望有帮助

    --
    mjf