SSH Exporter
English | Chinese
present (sb for a job etc)
SSH Exporter is a monitoring tool based on the Prometheus specification that remotely collects system performance data, such as CPU utilization, memory usage, disk and network I/O, from a target server via the SSH protocol and exposes this data as Prometheus-formatted metrics to be captured and stored by Prometheus Server to capture and store.
Functional characteristics
- RMON: Connects to a remote server via SSH protocol without installing an additional agent on the monitored server.
- Comprehensive system monitoring: Supports monitoring of performance metrics in a variety of areas such as CPU, memory, disk, and network.
- dynamic configuration: Supports reading monitoring targets and parameters from YAML configuration files to facilitate dynamic management of monitoring nodes.
- asynchronous collection: Collect data asynchronously using a thread pool to improve data collection efficiency.
- Error handling and retry mechanisms: Provide automatic retry mechanism for SSH connection failure to ensure the reliability of data collection.
- Multi-language environment support: When parsing the output of certain commands, it is automatically adapted according to the system language, supporting both Chinese and English environments.
Usage
1. Configuration
First, it needs to be edited file, configure the nodes and monitoring metrics to be monitored. Example:
nodes:
- ip: 192.168.1.101
port: 22
username: <username>
password: <password>
- ip: 192.168.1.102
port: 22
username: <username>
password: <password>
metrics:
- ssh_cpu_utilization
- ssh_cpu_utilization_user
- ssh_cpu_utilization_system
- ssh_cpu_utilization_top5
- ssh_cpu_percentage_wait
- ssh_cpu_percentage_idle
- ssh_cpu_count
- ssh_memory_utilization
- ssh_memory_utilization_top5
- ssh_memory_utilization_swap
- ssh_memory_available_bytes
- ssh_memory_available_swap_bytes
- ssh_disk_utilization
- ssh_disk_used_bytes
- ssh_disk_available_bytes
- ssh_disk_read_bytes_total
- ssh_disk_write_bytes_total
- ssh_network_receive_bytes_total
- ssh_network_transmit_bytes_total
2. Operation
run directlyssh_exporter.py
script to start the SSH Exporter service. The service will listen on the default port 9122 and wait for a crawl request from Prometheus Server.
python3 ssh_exporter.py
Supported Python versions: python>=3.8
3. Prometheus configuration
Add a new job to the Prometheus configuration file specifying the address of the SSH Exporter so that Prometheus can grab the data.
scrape_configs:
- job_name: 'ssh-exporter'
static_configs:
- targets: ['localhost:9122']
caveat
- safety: Make sure that your SSH credentials (username and password) are secure to avoid disclosure.
- Network Configuration: Ensure that Prometheus Server can access the server running the SSH Exporter.
- Performance Impact: Frequent SSH connections and data collection may cause some performance impact on the remote server, please adjust the data collection frequency according to the actual demand.
Development and Maintenance
- Question Feedback: please add the following to theGitHub Submit issues in the repository.
- Contribute code: Feel free to submit PRs to improve SSH Exporter together.