Bash

啟動collectd.service時如何解決“活動:啟動(自動重啟)”?

  • September 20, 2020

我在通過命令安裝的 Fedora 31 64 位作業系統中啟動collectd.serivce時遇到問題。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/system/*目錄中的文件。真正奇怪的是我在上述輸出中不斷收到啟動(自動重啟) **狀態=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.

非常感謝任何建議/指出我如何解決這個問題的正確方向。

在“實驗”之後,我設法找到了一個解決方案,並通過設置以下值來編輯ExecStart我的文件中的屬性來執行 collectd.service:/etc/systemd/system/collectd.service

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

…在此連結中找到。

如果有人遇到這種情況,希望會有所幫助。:)

乾杯!

引用自:https://serverfault.com/questions/1034560