ans2dev.general.sar_facts module – Collect info from sar.
Note
This module is part of the ans2dev.general collection (version 0.2.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ans2dev.general
.
To use it in a playbook, specify: ans2dev.general.sar_facts
.
New in ans2dev.general 0.1.0
Synopsis
Retrieves SAR data using the
sar
command from system logs.Supports filtering by date range, time range, and partition details.
Returns performance metrics such as CPU utilization, memory usage, disk activity, and network statistics.
ans2dev.general.sar_facts only supports sar data with a
12H
time format and automatically converts format to24H
.
Parameters
Parameter |
Comments |
---|---|
Whether to retrieve only the average values. Choices:
|
|
End date for collecting SAR data (format YYYY-MM-DD). |
|
Start date for collecting SAR data (format YYYY-MM-DD). |
|
Whether to retrieve partition-specific disk statistics. Choices:
|
|
End time for collecting SAR data (format HH:MM:SS). |
|
Start time for collecting SAR data (format HH:MM:SS). |
|
Type of SAR data to retrieve. Choices:
|
Examples
# Gather CPU performance metrics for a specific date and time range.
- name: Gather CPU SAR facts between 08:00 and 10:00
ans2dev.general.sar_facts:
date_start: "2025-05-01"
date_end: "2025-05-01"
time_start: "08:00:00"
time_end: "10:00:00"
type: cpu
# Gather memory usage SAR data for a single day.
- name: Retrieve memory usage data for a day
ans2dev.general.sar_facts:
date_start: "2025-05-01"
type: memory
# Retrieve disk statistics with partition details.
- name: Gather disk usage statistics with partition information
ans2dev.general.sar_facts:
date_start: "2025-05-01"
type: disk
partition: true
# Retrieve average load statistics.
- name: Gather average load statistics
ans2dev.general.sar_facts:
date_start: "2025-05-01"
type: load
average: true
Returned Facts
Facts returned by this module are added/updated in the hostvars
host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Key |
Description |
---|---|
Dictionary that contains It contains Most common keys are Returned: when |
|
Dictionary that contains It contains Most common keys are Returned: when |
|
Dictionary that contains It contains Most common keys are Returned: when |
|
Dictionary that contains It contains Most common keys are Returned: when |
|
Dictionary that contains It contains Most common keys are Returned: when |
|
Dictionary that contains It contains Most common keys are Returned: when |