process_running¶
- Status:
● Development
- Category:
Linux System
- Function Name:
process_running
Tests if a process is running with expected number of instances (Linux only).
This test function checks if a specified process is running on the system and optionally validates the minimum number of instances. It uses process name matching to find running processes.
Parameters¶
Parameter |
Type |
Description |
|---|---|---|
|
string |
Required. The name of the process to check for. |
|
integer |
Optional. Minimum number of process instances expected. Default: 1. |
Usage Example¶
Basic Process Check¶
tests:
- name: test_process_running_single
function: linux.process_running
parameter:
process_name: 'systemd'
min_instances: 1
description: "Test process_running with single instance"
Multiple Instance Check¶
tests:
- name: test_apache_workers
function: linux.process_running
parameter:
process_name: 'apache2'
min_instances: 3
description: "Test that at least 3 Apache worker processes are running"
Expected Failure Cases¶
tests:
- name: test_process_not_running
function: linux.process_running
expect_to_fail: true
parameter:
process_name: 'nonexistent-process-12345'
min_instances: 1
description: "Test process_running with non-existent process"
Variable-Based Process Names¶
variables:
database_process:
type: string
value: "mysqld"
description: "Database server process"
tests:
- name: test_database_running
function: linux.process_running
parameter:
process_name: '{{database_process}}'
min_instances: 1
description: "Test database process is running"
Common Use Cases¶
- Service Process Monitoring
Verify that daemon processes are running for system services
- Application Health Checks
Ensure application processes haven’t crashed or stopped
- Load Balancer Validation
Check that multiple worker processes are running for high-load services
- Container Process Verification
Validate that containerized applications have spawned expected processes
- Security Process Monitoring
Ensure security-related processes like antivirus or monitoring tools are active
Process Detection¶
- Process Matching:
Uses process name matching against running processes
Matches against the command name in the process list
Case-sensitive process name matching
- Instance Counting:
Counts all processes matching the specified name
Validates that at least
min_instancesare runningUseful for services that spawn multiple worker processes
- Platform Requirements:
Linux operating system
Access to process information (typically via
/procfilesystem)Appropriate permissions to read process information
Return Values¶
- Success
Returns success when the required number of process instances are found running
- Failure
Returns failure when: - Process is not running - Fewer instances are running than the minimum required - Process name doesn’t match any running processes
- Execution Error
Returns execution error when: - Not running on Linux system - Permission denied accessing process information - System error occurs while checking processes
Example Results¶
# Success case
result: success
details:
- "process systemd found running with 1 instances (minimum: 1)"
# Failure case - process not found
result: failed
details:
- "process nonexistent-process-12345 not found running (minimum instances: 1)"
# Failure case - insufficient instances
result: failed
details:
- "process apache2 found running with 1 instances (minimum: 3)"
# Execution error case - wrong platform
result: execution_error
error: "This test only runs on Linux"