如何使用 Ossec 检查 Apache 是否停止或崩溃?

How to check if Apache is stopped or crashed with Ossec?

如何检查 Apache 是 运行 还是与 Ossec 一起崩溃?

我要在其中一个代理的 ossec.conf 中添加以下内容:

<localfile>
   <log_format>full_command</log_format>
   <command>service httpd status</command>
</localfile>

但是什么也没有出现,即使我停止了 apache。

可能是什么原因?

您应该编写您的规则(如果 /var/ossec/rules/ 中不存在)。 我的 rsyslog 服务设置是:

在代理处的/var/ossec/etc/ossec.conf中,我添加了

   <localfile>
      <log_format>command</log_format>
      <command>service rsyslog status</command>
      <frequency>45</frequency>
      <alias>Rsyslog Service Status</alias>
   </localfile>

在 /var/ossec/rules/local_rules.xml at ossec-server,

   <rule id="110102" level="1">
      <if_sid>530</if_sid>
      <match>ossec: output: 'Rsyslog Service Status':</match>
      <options>no_log</options>
      <group>rsyslog</group>
   </rule>

   <rule id="110103" level="10">
      <if_sid>110102</if_sid>
      <match>Active: inactive</match>
      <description>Rsyslog service is inactive (STOP).</description>
      <group>rsyslog</group>
   </rule>

   <rule id="110104" level="10">
      <if_sid>110102</if_sid>
      <match>Active: failed</match>
      <description>Rsyslog service is inactive (FAILED).</description>
      <group>rsyslog</group>
   </rule>

NOT 您也可以将 /var/ossec/etc/ossec.conf 中的第一部分部署在 ossec-server 而不是代理上。如果你这样做,你应该设置 logcollector.remote_commands=1

NOT别忘了./ossec-control restart