Powernap 在 Ubuntu 18.04 中不起作用,状态:活动(已退出)

Powernap 在 Ubuntu 18.04 中不起作用,状态:活动(已退出)

我无法让 Powernap 在 Ubuntu 18.04 中工作。我已多次使用 停止并启动它,systemctl stop powernap以下systemctl start powernap是 的输出systemctl status powernap

powernap.service - PowerNap
   Loaded: loaded (/lib/systemd/system/powernap.service; disabled; vendor preset: enabled)
   Active: active (exited) since Sun 2019-02-03 08:30:54 CST; 53min ago
  Process: 2318 ExecStart=/usr/sbin/powernapd (code=exited, status=0/SUCCESS)
  Process: 2313 ExecStartPre=/usr/share/powernap/powernap-ethtool (code=exited, status=0/SUCCESS)
 Main PID: 2319 (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/powernap.service
           └─2320 /usr/bin/python /usr/sbin/powernapd

我不知道是什么导致了活动(退出)状态。我认为应该是活动(正在运行)。

powernap 守护进程似乎正在按下列步骤运行:

root@Dennis:~# ps  -e|grep powernapd
 2320 ?        00:00:00 powernapd

这是powernap.err日志。有一个错误。有人能告诉我这是什么意思吗?

Traceback (most recent call last):
  File "/usr/sbin/powernapd", line 342, in <module>
    MONITORS = powernap.get_monitors()
  File "/usr/lib/python2.7/dist-packages/powernap/powernap.py", line 183, in get_monitors
    p = ConsoleMonitor.ConsoleMonitor(config)
  File "/usr/lib/python2.7/dist-packages/powernap/monitors/ConsoleMonitor.py", line 53, in __init__
    self._time, self._irqs = get_console_activity()
  File "/usr/lib/python2.7/dist-packages/powernap/monitors/ConsoleMonitor.py", line 28, in get_console_activity
    irqs = get_interrupts()
  File "/usr/lib/python2.7/dist-packages/powernap/monitors/ConsoleMonitor.py", line 42, in get_interrupts
    interrupts += int(i)
ValueError: invalid literal for int() with base 10: 'IO-APIC'

这是我的powernap.services文件。我已将其修改为“networking”,并根据以前的错误报告添加了“RemainAfterExit=yes”行。如果没有此行,powernap 将无法启动。

[Unit]
Description=PowerNap
Requires=networking.service
After=networking.service

[Service]
Type=forking
ExecStartPre=/usr/share/powernap/powernap-ethtool
ExecStart=/usr/sbin/powernapd
ExecStop=-/usr/sbin/powerwake-now
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

我尝试了配置文件中的各种设置,但都没有成功。目前,我已将其设置为在 60 秒后暂停,仅查看 [LoadMonitor] = 2。这是(长)文件:

[powernap]
# This is the configuration file for PowerNap.
# See powernap(1) for more information.

# This file is Python syntax, and will be sourced by the powernap daemon
# on start. To enact changes to this configuration, restart the daemon.
# Example:
#   sudo service powernap restart

# The ACTION_METHOD variable determines what action to take.
# The possible actions are:
# 0 - powersave
# 1 - suspend
# 2 - hibernate
# 3 - poweroff
# 4 - best-effort
# The default mode of operation is powersave. This method will use the
# "pm-powersave" command and will execute hooks locate in "/etc/pm/power.d" and
# "/usr/lib/pm-utils/power.d".
# The best-effort method, witll first, it will try a user-defined script
# at "/etc/powernap/action", or suspend, hibernate, poweroff.
ACTION_METHOD = 1

# Number of seconds that all monitors must have no activity or must be absent.
# The default is an absence period of 30 seconds.
# Example:
#   ABSENT_SECONDS = 30
ABSENT_SECONDS = 60

# Grace period, after (ABSENT_SECONDS - GRACE_SECONDS) have elapsed with all of
# the Monitors with absent activity, the system will send a Wall message for an
# administrator to warn that the system will perform the "/usr/sbin/powernap"
# action in GRACE_SECONDS.
# The default grace period is 6 seconds.
# Example:
#   GRACE_SECONDS = 6
GRACE_SECONDS = 6

# The powernap daemon will wake every INTERVAL_SECONDS and check for activity
# to all of the monitors.  Lower values of INTERVAL_SECONDS will provide
# more detailed process monitoring but will consume more system resources.
# Higher values of INTERVAL_SECONDS will consume less system resources, but
# might miss activity that execute for less than INTERVAL_SECONDS.
# The minimum runtime of any monitor should not be less than INTERVAL_SECONDS.
# The default interval is 1 second.
# Example:
#   INTERVAL_SECONDS = 1
INTERVAL_SECONDS = 1

# The powernap daemon will issue a warning message to the console whenever it
# has entered into GRACE period. This warning message will warn the user that
# it is about to perform an ACTION.
# This warning message is done using the "wall" command, notifying all the
# users connected to a console.
# The default is set to 'yes' to WARN the user. It can be disabled by setting
# the option to 'n' or 'no', or can simply be commented.
# Example
#   WARN = y
#   WARN = n
WARN = y

# The powernap daemon logs errors to /var/log/powernap.err, and some basic
# information to /var/log/powernap.log.  To change the verbosity of this
# logging, set DEBUG to 0, 1, 2, or 3:
# The default debug level is 0.
#    DEBUG = 1
#    DEBUG = 2
DEBUG = 2

# The powernap daemon can watch for changes in the configuration file in
# /etc/powernap directory without having to restart it.
# The default value is n.
#    WATCH_CONFIG = y
#    WATCH_CONFIG = n
WATCH_CONFIG = n

# Kernel Modules that are to be disabled when running PowerNap on Powersave
# mode
#KERN_MODULES = btusb sco tfcomm bnep

# Network Services that are to be disabled when running PowerNap on
# PowerSave mode
#SERVICES = postgresql-8.4 apache2 ntp network-manager

############################################################################
####                        STAGE2 ACTION                               ####
############################################################################
#[powernap-stage2]
# Number of seconds that all monitors must have no activity or must be absent
# while running in PowerSave mode to perform the STAGE2_ACTION_METHOD.
# The default value is to be disabled by default. If you wish to enable the
# Second Stage Action method, set the STAGE2_ABSENT_SECONDS and ensure that
# STAGE2_ACTION_METHOD is set correctly.
# Example:
#   STAGE2_ABSENT_SECONDS = 500
#STAGE2_ABSENT_SECONDS = 0

# The STAGE2_ACTION_METHOD variable determines what action should be taken
# after a period on inactivity while under PowerSave Mode (See ACTION_METHOD
# above).
# The possible actions are:
# 1 - suspend
# 2 - hibernate
# 3 - poweroff
# 4 - best-effort
# The default mode of operation is best-effort. This method will try to
# user-defined script  at "/etc/powernap/action", or suspend, hibernate,
# or poweroff the machine.
#STAGE2_ACTION_METHOD = 4

############################################################################
####                          MONITORS                                  ####
############################################################################

# The [WoLMonitor] section lists all ports on which the WoL Monitor will be
# listening for WoL Packets for any of the network interfaces.
# Once a WoL Packet is received, the WoLMonitor will compare the data received
# with all the network interfaces (eth's) to determine wether it is destined
# for any of the network interfaces.
# The default is to monitor ports 7 and 9 for WoL data packets. It can also be
# set to any other port on which the machine is receiving WoL packets
# Example:
#  wol1052 = 1052
[WoLMonitor]
#wol7 = n
#wol9 = n

# The [ConsoleMonitor] section enables or disables  monitoring of activity
# in the Console (tty), also tracking activity from any locally connected
# mouse and keyboard (PS2 Only).
# The default is enabled, set to 'y'. It can be disabled by setting it to 'n'.
# Examples:
#  console = y
#  console = n
[ConsoleMonitor]
ptmx = n

# The [ProcessMonitor] section lists all the processes to Monitor by using
# regular expressions.
# Each item listed will be compared against the output of "ps -eo args".
# The default is to monitor /sbin/init, which should always be running.
# Examples:
#  mplayer = "mplayer "
#  sshd = "sshd: .*\[priv\]$"
#  kvm = "kvm "
[ProcessMonitor]
#init = "^/sbin/init"

# The [LoadMonitor] section defines the load threshold.  When the system load
# according to /proc/loadavg is above this value, then system will be deemed
# 'active' and will not powernap.  If the system is already powernapping, then
# the system will awake out of the powernap mode if the load raises above the
# threshold.
# If the threshold is set to "n" (which is default), threshold is automatically
# calculated to be the number of online processors, as determined by:
#   getconf _NPROCESSORS_ONLN
# Example:
#   threshold = 1.5
#   threshold = 9999
#   threshold = 0
#   threshold = n
[LoadMonitor]
threshold = 2

# The [TCPMonitor] section lists all the TCP ports on which to watch for
# established connections using netstat(8). It supports both, single TCP
# as well as port ranges.
# There is no default TCP Monitor.
# Examples:
#  ssh = 22
#  http = 80
#  https = 443
#  other = 64500-65000
[TCPMonitor]
#ssh = 22

# The [UDPMonitor] section lists all the UDP ports on which to listen
# for data.
# Each item listed will BIND a UDP port and listen to any data. Keep
# in mind that this port will be bined and no other application will
# be able to use this port.
# There is no default UDP Monitor.
# Examples:
#  udp-1 = 1025
#  udp-2 = 2048
[UDPMonitor]
#udp-1025 = 1025

# The [IOMonitor] section lists all the processes to Monitor for IO
# activity. A regular expressions is used to find the processes PIDs, which
# are later used to monitor IO.
# There is no default IO Monitor.
# Examples:
#  kvm-io = "kvm"
#  mysqld-io = "mysql"
[IOMonitor]
#kvm-io = "kvm"
#mysqld-io = "mysql"

# The [InputMonitor] section lists the USB Input devices for which to track
# events. Currently, only two types of devices are supported, mouse and keyboard.
# Both InputMonitor's are enabled by default. In the case there are no USB
# devices connected, PowerNap will ignore these settings.
# To disable, set them to "n" or "no", or simply comment them.
# Examples:
#  keyboard = n
#  keyboard = y
[InputMonitor]
keyboard = n
mouse = n

# The [DiskMonitor] section lists the disk devices for which to track
# standby/sleep status.  If any of the devices are active/idle the
# system will be deemed 'active' and will not powernap. Generally useful
# for monitoring data drives (e.g. NAS), but will not typically work to
# monitor the root drive. Note also that this plugin only reacts to the
# state of the drive and does not modify the behavior of the drive
# directly. Therefore it only makes sense to monitor a drive that has
# already been configured to standby or sleep.
# To disable checking specific drives, set them to "n" or "no",
# or simply comment them.
# Examples:
#  sda = y
#  sdb = n
[DiskMonitor]
#sda = y

答案1

Powernap 似乎存在一些错误,但您可以尝试此处建议的修复方法: https://ubuntuforums.org/showthread.php?t=2304588

另一个选择似乎是禁用 ConsoleMonitor(例如,如果它是无头服务器),如下所建议: https://bugs.launchpad.net/powernap/+bug/1497782

相关内容