Available activity checks¶
The following checks for activity are currently implemented. Each of them is described with its available configuration options and required optional dependencies.
ActiveConnection¶
Check for active network connections on specific ports.
Checks whether there is currently a client connected to a TCP server at certain ports. Can be used to e.g. block suspending the system in case SSH users are connected or a web server is used by clients.
Options¶
- ports¶
list of comma-separated port numbers
ExternalCommand¶
Execute an external command to determine activity.
Executes an arbitrary command. In case this command returns 0, the system is assumed to be active.
The command is executed as is using shell execution. Beware of malicious commands in obtained configuration files.
See also
External command scripts for activity detection for a collection of user-provided scripts for some common use cases.
Options¶
- command¶
The command to execute including all arguments
Kodi¶
Check for Kodi media player activity.
Checks whether an instance of Kodi is currently playing.
Requires
Options¶
- url¶
Base URL of the JSON RPC API of the Kodi instance. Default:
http://localhost:8080/jsonrpc.
- suspend_while_paused¶
Also suspend the system when media playback is paused instead of only suspending when playback is stopped. Default:
false.
- timeout¶
Timeout for executed requests in seconds. Default:
5.
- username¶
Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided.
- password¶
Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided.
KodiIdleTime¶
Check for Kodi user interface activity.
Checks whether there has been interaction with the Kodi user interface recently. This prevents suspending the system in case someone is currently browsing collections etc. This check is redundant to XIdleTime on systems using an X server, but might be necessary in case Kodi is used standalone. It does not replace the Kodi check, as the idle time is not updated when media is playing.
Requires
Options¶
- url¶
Base URL of the JSON RPC API of the Kodi instance. Default:
http://localhost:8080/jsonrpc.
- idle_time¶
Marks the system active in case a user interaction has appeared within this amount of seconds until now. Default:
120.
- timeout¶
Timeout for executed requests in seconds. Default:
5.
- username¶
Optional user name to use for authenticating at a server requiring authentication. If used, also a password must be provided.
- password¶
Optional password to use for authenticating at a server requiring authentication. If used, also a user name must be provided.
Load¶
Check for system load.
Checks whether the system load 5 is below a certain value.
Options¶
- threshold¶
a float for the maximum allowed load value. Default:
2.5.
LogindSessionsIdle¶
Check for logind session idle hints.
Prevents suspending in case IdleHint for one of the running sessions logind sessions is set to no.
Support for setting this hint currently varies greatly across display managers, screen lockers etc.
Thus, check exactly whether the hint is set on your system via loginctl show-session.
Options¶
- types¶
A comma-separated list of sessions types to inspect for activity. The check ignores sessions of other types. Default:
tty,x11,wayland.
- states¶
A comma-separated list of session states to inspect. For instance,
lingeringsessions used for background programs might not be of interest. Default:active,online.
- classes¶
A comma-separated list of session classes to inspect. For instance,
greetersessions used by greeters such as lightdm might not be of interest. Default:user.
NetworkBandwidth¶
Check for network bandwidth usage.
Checks whether more network bandwidth is currently being used than specified.
A set of specified interfaces is checked in this regard, each of them individually, based on the average bandwidth on that interface.
This average is based on the global checking interval specified in the configuration file via the interval option.
Note
This check assumes stable network interface names. If this is not the case for your system, consider adding the required udev rules to ensure persistent device names. The Archlinux Wiki page on network configuration explains the necessary configuration steps.
Options¶
- interfaces¶
Comma-separated list of network interfaces to check
- threshold_send¶
If the average sending bandwidth of one of the specified interfaces is above this threshold, then activity is detected. Specified in bytes/s. Default:
100.
- threshold_receive¶
If the average receive bandwidth of one of the specified interfaces is above this threshold, then activity is detected. Specified in bytes/s. Default:
100.
Ping¶
Check if hosts respond to ping.
Checks whether one or more hosts answer to ICMP requests.
Options¶
- hosts¶
Comma-separated list of host names or IPs.
Processes¶
Check for running processes.
If currently running processes match an expression, the suspend will be blocked. You might use this to hinder the system from suspending when for example your rsync runs.
Options¶
- processes¶
list of comma-separated process names to check for
Smb¶
Check for active Samba connections.
Any active Samba connection will block suspend.
Requires
The smbstatus binary must be installed and executable.
Users¶
Check for logged in users.
Checks whether a user currently logged in at the system matches several criteria. All provided criteria must match to indicate activity on the host.
To find the applicable values for a given scenario on a system, use the following command:
$ python3 -c "import psutil; print(psutil.users())"
[suser(name='someone', terminal='tty7', host='', started=1670269568.0, pid=77179)]
All regular expressions are applied against the full string. Capturing substrings needs to be explicitly enabled using wildcard matching.
Options¶
- name¶
A regular expression specifying which users to capture. Default:
.*.
- terminal¶
A regular expression specifying the terminal on which the user needs to be logged in. Default:
.*.
- host¶
A regular expression specifying the host from which a user needs to be logged in. Users logged in locally on the machine are usually reported with an empty string as the host value. In case this check should only match local users, use
^$as the value for this option. Default:.*.
XIdleTime¶
Check for X11 idle time.
Checks whether all active local X displays have been idle for a sufficiently long time. Determining which X11 sessions currently exist on a running system is a harder problem than one might expect. Sometimes, the server runs as root, sometimes under the real user, and many other configuration variants exist. Thus, multiple sources for active X server instances are implemented for this check, each of them having different requirements and limitations. They can be changed using the provided configuration option.
The method to use for acquiring running X sessions can be configured:
socketsUses the X server sockets files found in
/tmp/.X11-unix. This method requires that all X server instances run with user permissions and not as root.logindUses logind to obtain the running X server instances. This does not support manually started servers.
Options¶
- timeout¶
required idle time in seconds. Default:
600.
- method¶
The method to use for acquiring running X sessions. Valid options are
socketsandlogind. Default:sockets.Allowed values:
sockets,logind.
- ignore_if_process¶
A regular expression to match against the process names executed by each X session owner. In case the user has a running process that matches this expression, the X idle time is ignored and the check continues as if there was no activity. This can be useful in case of processes which inevitably tinker with the idle time. Default:
a^.
- ignore_users¶
Do not check sessions of users matching this regular expressions. Default:
a^.