启动collectd.service时出现“Active: activating (auto-restart)”如何解决?

启动collectd.service时出现“Active: activating (auto-restart)”如何解决?

我无法启动collectd.服务在我通过命令安装的 Fedora 31 64 位操作系统中sudo dnf install collectd。当我输入时,sudo systemctl status collectd.service我得到以下输出:

    ● collectd.service - statistics collection daemon
       Loaded: loaded (/etc/systemd/system/collectd.service; enabled; vendor preset: disabled)
       Active: activating (auto-restart) since Sat 2020-09-19 18:18:47 CEST; 3s ago
         Docs: man:collectd(1)
      Process: 3796 ExecStart=/usr/sbin/collectd (code=exited, status=0/SUCCESS)
     Main PID: 3796 (code=exited, status=0/SUCCESS)
          CPU: 7ms

顺便说一句,我必须手动创建collectd.service位于/etc/systemd/系统/目录。真正奇怪的是,我不断收到激活(自动重启) 状态=0/成功在上面提到的输出中。我还按相应的顺序执行了以下命令:

  1. sudo systemctl daemon-reload
  2. sudo systemctl stop collectd.service
  3. sudo systemctl start collectd.service

...但什么都没变,我尝试在完成所有操作后重新启动计算机并执行所有提到的 1)-3) 步骤,但没有任何帮助。顺便说一句,这是我的collectd.service

[Unit]
Description=statistics collection daemon
Documentation=man:collectd(1)
After=local-fs.target network.target
Requires=local-fs.target network.target

[Service]
ExecStart=/usr/sbin/collectd
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

我的/etc/collectd.conf文件如下所示:

#
# Config file for collectd(1).
# Please read collectd.conf(5) for a list of options.
# http://collectd.org/
#

##############################################################################
# Global                                                                     #
#----------------------------------------------------------------------------#
# Global settings for the daemon.                                            #
##############################################################################

#Hostname    "localhost"
FQDNLookup   true
#BaseDir     "/var/lib/collectd"
#PIDFile     "/var/run/collectd.pid"
PluginDir   "/usr/lib64/collectd"
TypesDB     "/usr/share/collectd/types.db"

LoadPlugin cpu

<Plugin cpu>
  ReportByCpu false
  ReportByState false
#  Interval 1
  ValuesPercentage true
#  ReportNumCpu false
#  ReportGuestState false
#  SubtractGuestState true
</Plugin>

<Plugin memory>
        ValuesAbsolute false
        ValuesPercentage true
</Plugin>

Include "/etc/collectd.d"
LoadPlugin syslog
LoadPlugin logfile
#LoadPlugin log_logstash

<Plugin logfile>
        LogLevel info
        File "/var/log/error_syslog"
        Timestamp true
#       PrintSeverity false
</Plugin>

#<Plugin log_logstash>
#       LogLevel info
#       File "/var/log/collectd.json.log"
#</Plugin>

<Plugin syslog>
        LogLevel info
</Plugin>
Include "/etc/collectd.d"

更新1:

这是输出我得到的日志文件(在文件中/var/log/error_syslog设置):collectd.conf

[2020-09-20 11:04:25] plugin_dispatch_values: No write callback has been registered. Please load at least one output plugin, if you want the collected data to be stored.
[2020-09-20 11:04:25] Filter subsystem: Built-in target `write': Dispatching value to all write plugins failed with status 2 (ENOENT). Most likely this means you didn't load any write plugins.
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] Available write targets:: [none]
[2020-09-20 11:04:25] collectd: Stopping 5 write threads.
[2020-09-20 11:04:35] plugin_load: plugin "cpu" successfully loaded.
[2020-09-20 11:04:35] plugin_load: plugin "memory" successfully loaded.
[2020-09-20 11:04:35] Initialization complete, entering read-loop.
[2020-09-20 11:04:35] Exiting normally.
[2020-09-20 11:04:35] plugin_dispatch_values: No write callback has been registered. Please load at least one output plugin, if you want the collected data to be stored.
[2020-09-20 11:04:35] collectd: Stopping 5 read threads.
[2020-09-20 11:04:35] Filter subsystem: Built-in target `write': Dispatching value to all write plugins failed with status 2 (ENOENT). Most likely this means you didn't load any write plugins.
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] Available write targets:: [none]
[2020-09-20 11:04:35] collectd: Stopping 5 write threads.

如果能提供任何关于如何解决此问题的建议或正确的方向,我将不胜感激。

答案1

ExecStart经过“试验”后,我设法找到了解决方案,并通过编辑文件中的属性/etc/systemd/system/collectd.service并设置以下值来使 collectd.service 运行:

ExecStart=/usr/sbin/collectd -C /etc/collectd.conf -f

...在此找到关联

如果有人遇到这种情况,希望这能有所帮助。:)
干杯!

相关内容