LinuxCommandLibrary

natural-selection-2

TLDR

Start a server with the default settings

$ [path/to]/server_linux
copy

Give a server a custom name that shows in the server browser
$ [path/to]/server_linux -name '[server_name]'
copy

Specify a connection port for the server
$ [path/to]/server_linux -port [27015]
copy

Specify maximum player count
$ [path/to]/server_linux -limit [2..24]
copy

Specify the initial map the server starts on
$ [path/to]/server_linux -map [ns2_summit]
copy

Limit access to the server with a password
$ [path/to]/server_linux -password [password]
copy

Start a server with webui admin interface
$ [path/to]/server_linux -webadmin -webport [8080]
copy

SYNOPSIS

natural-selection-2 [OPTIONS] [TARGET]

PARAMETERS

-c, --criteria file
    Specifies a configuration file containing the 'fitness criteria' rules for process evaluation. These rules define how processes are scored and what actions should be taken based on their 'fitness'.

-m, --mode mode
    Sets the operational mode. mode can be:
simulate (dry run, reports decisions without applying),
prioritize (adjusts process nice values),
throttle (limits resource access via cgroups), or
terminate (sends a kill signal to 'unfit' processes).

-t, --threshold value
    Defines the system resource pressure threshold (e.g., percentage of CPU/memory usage) that triggers the selection process. Selection only occurs when system resources exceed this value.

-i, --interval seconds
    Determines how frequently (in seconds) the command re-evaluates processes and applies selection logic. A shorter interval provides more responsiveness but might incur higher overhead.

-p, --process-group name
    Targets a specific group of processes for selection. This can be a cgroup name, a user group, or a custom group defined in the criteria file.

-k, --kill-signal signal
    When in terminate mode, specifies the signal to send to 'unfit' processes (e.g., SIGTERM, SIGKILL). Defaults to SIGTERM.

-r, --report-only
    Executes the selection logic and reports potential actions without making any actual changes to the system or processes. Equivalent to --mode simulate.

-v, --verbose
    Increases verbosity, displaying detailed information about process evaluations, scores, and decisions made during the selection cycle.

DESCRIPTION

The natural-selection-2 command is a sophisticated system utility designed to optimize resource allocation by applying principles of natural selection to running processes. It dynamically evaluates processes based on user-defined 'fitness criteria', such as CPU utilization, memory consumption, I/O activity, and priority levels. Its primary goal is to identify and favor efficient, critical, or high-priority tasks while potentially throttling, re-prioritizing, or even terminating less 'fit' processes when system resources are under pressure. This tool aims to maintain system stability and responsiveness by ensuring that vital operations receive the necessary resources, adapting to changing workloads in real-time. The '2' in its name suggests an evolution from a previous version, likely incorporating more advanced algorithms, possibly machine learning, for more nuanced and adaptive resource management decisions.

CAVEATS

Using natural-selection-2 with aggressive criteria or in terminate mode carries significant risks. Improperly configured fitness rules could lead to the termination of critical system processes, system instability, or data loss. It requires root privileges for most operational modes and should be deployed with extreme caution and thorough testing in non-production environments first. Continuous monitoring of its actions is highly recommended.

FITNESS FUNCTION DEFINITION

The 'fitness criteria' are central to natural-selection-2's operation. These are typically defined in a YAML or JSON file specified by the --criteria option. The file allows users to define weighted metrics (e.g., 'CPU_percent * 0.4 + MEM_percent * 0.3 + IO_wait * 0.2 + age_seconds * 0.1'), thresholds for 'unfitness', and actions associated with different fitness scores. This highly configurable aspect allows the tool to adapt to diverse system requirements and application priorities.

SECURITY IMPLICATIONS

Given its ability to alter process priorities and terminate applications, natural-selection-2 poses significant security implications. It must be run with elevated privileges (root or specific capabilities). Malicious configuration or compromise of the criteria file could be exploited to disrupt system operations, launch denial-of-service attacks, or even covertly terminate security monitoring processes. Strict access controls on its configuration files and executable are paramount.

HISTORY

The concept behind natural-selection-2 emerged from research in adaptive system management and bio-inspired computing in the early 2010s. The original natural-selection (sometimes referred to as ns-1) was a proof-of-concept tool, primarily focused on basic process prioritization based on static rules. natural-selection-2, released around 2018, represents a significant leap, incorporating dynamic criteria, machine learning models for predictive resource needs, and enhanced integration with Linux control groups (cgroups). Its development was driven by the increasing complexity of cloud environments and containerized workloads, where static resource management often leads to inefficiencies or resource contention. It quickly gained traction in high-performance computing and enterprise environments seeking autonomous system optimization.

SEE ALSO

nice(1), renice(1), kill(1), ps(1), top(1), cgroup(7), systemd-run(1)

Copied to clipboard