PowerNap Improvements for Natty

For all of those who don’t know, “PowerNap is a screen saver for servers except it doesn’t save your screen, it saves the environment and lowers your energy bill.” Dustin Kirkland :) . PowerNap was originally created by Dustin to be integrated with (UEC), but it has been extended for Home use. Originally, it put to sleep machines (suspend, hibernate, poweroff) when a list of Processes were not found in the process table for  a determined period of time. However, during the Natty cycle improvements were made. So, PowerNap now puts to sleep (suspend, poweroff, powersave) machines that are tagged as underutilized  by a set if Monitors.

Improvements Overview

  • PowerNap, has a set of Monitors to be able to detect activity within the server and determine if it is idled or not. If it is, PowerNap will execute an ACTION. Administrators can chose what monitors to enable/disable. These are:
    • ProcessMonitor: Looks for a process in the process table.
    • IOMonitor: Monitors IO activity by process name.
    • InputMonitor: Monitors Mouse/Keyboard input activity connected to USB.
    • LoadMonitor: Monitors a server load threshold.
    • TCPMonitor: Monitors active TCP connections (i.e. SSH).
    • UDPMonitor: Monitors activity received in any user defined UDP port.
    • WoLMonitor: Monitors WoL packets on ports 7 and/or 9.
    • ConsoleMonitor: Monitors console activity.
  • The process starts when PowerNap begins monitoring for an ABSENT_PERIOD (i.e. 300secs). If within that period no activity has been detected, then PowerNap executes an ACTION.
    • Before the ACTION is taken, PowerNap enters to the GRACE_PERIOD (I.e 30 seconds), notifying the user that the ACTION will be taken in GRACE_PERIOD amount of seconds. (i.e. On second 270 PowerNap will notifies its users and the period between 270 and 300 seconds is known as GRACE_PERIOD).
  • The possible ACTIONS are:
    • Best-effort – Automatically decide between a user defined action or any of the other methods listed below (these methods rely on pm-utils)
    • Suspend (Command: pm-suspend)
    • Hibernate (Command: pm-hibernate)
    • Poweroff (Command: poweroff)
    • Powersave – Newly added method that reduces the Power Consumption (Command: pm-powersave)
  • The PowerSave method executes a set of scripts both provided by pm-utils and PowerNap. These scripts have the objective to reduce the power consumption of the machine by turning off hardware capabilities or tuning the OS. It is possible to provide any custom script as well as chose which to enable or disable. Examples of these scripts are:
    • Turn off all the CPU cores except of one.
    • Reduce the cores frequency to the lowest possible.
    • Disable WoL from Network Cards.
    • Change the NIC speed from 1Gbps to 100Mbps.
    • Turn off USB ports.
    • Disable HAL polling.
  • Now, when the PowerSave ACTION is taken, the machine keeps running in a lower power state. PowerNap keeps Monitoring until activity is detected. Once any of the Monitors detects activity, the PowerSave action is reverted.

 

PowerWake

  • PowerWake is simply a tool that sends WoL packets to an specified IP/Broadcast address to be able to wakeup a server.

 

Additional Tools

  • powernap-now: Sends a signal to the PowerNap daemon to execute the ACTION regardless of the state of the monitors.
  • powerwake-now: Sends a signal to the PowerNap daemon to wakeup during the PowerSave mode.
  • Note that these commands have to be executed in the machine running PowerNap. If this needs to be done through the network, then the command will have to be sent remotely to be executed in the machine.


The Future

  • Second Stage Action: Second Stage Action when entered into PowerSave mode. (i.e. Suspend after 2 hours after running in PowerSave mode).
  • Client/Server Model: The main Idea is to create a powerwaked Server that tracks all the machines using PowerNap in the network and is able to schedule wakeups, upstates, etc, etc.

Leave a Reply