d32f2a109a
It consists of two main steps: 1. Generating Bindings with `bindgen`: - The `build.rs` script uses `bindgen` to generate Rust FFI (Foreign Function Interface) bindings for the AMD SMI C library. This step automatically exports all enums, structs, unions, and unsafe functions from the C library into Rust. This provides a comprehensive low-level interface to the AMD SMI library. 2. Implementing Safe Rust Wrappers: - The generated bindings are then wrapped in safe Rust functions. These safe wrappers handle error checking, resource management, and provide a more idiomatic Rust interface. This ensures that users of the library can interact with the AMD SMI functions without dealing with unsafe code directly. Change-Id: I7d5e49e59826164fc911ced04ef7ca5706b7cc05 Signed-off-by: Tim Huang <tim.huang@amd.com>
97 lines
2.8 KiB
Markdown
97 lines
2.8 KiB
Markdown
# AMDSMI Exporter
|
|
|
|
The `AMDSMI Exporter` is a tool that exports AMD SMI metrics and runs an HTTP server to serve these metrics. It provides options to list supported GPUs and metrics' information, as well as to export metrics with optional filtering using whitelist and blacklist. This enables fine-grained control over which metrics are included or excluded.
|
|
|
|
## Features
|
|
|
|
- List supported GPUs and detailed metrics information.
|
|
- Export AMD SMI metrics and serve them via an HTTP server.
|
|
- Filter metrics using whitelist and blacklist.
|
|
- Filter metrics by GPU BDF or ID.
|
|
|
|
## Usage
|
|
|
|
### List Supported GPUs and Metrics
|
|
|
|
To list the supported GPUs and metrics' information, use the `list` subcommand:
|
|
|
|
```sh
|
|
amdsmi_exporter list
|
|
```
|
|
|
|
### Export Metrics and Run HTTP Server
|
|
|
|
To export AMD SMI metrics and run the HTTP server, use the `metric` subcommand:
|
|
|
|
```sh
|
|
amdsmi_exporter metric [OPTIONS]
|
|
```
|
|
|
|
#### Options
|
|
|
|
- `-p, --port <PORT>`: Sets the port to listen on (default: 9898).
|
|
- `-g, --gpu <GPU>`: Sets the GPU BDF or the zero-based index of the socket ID and processor ID for export.
|
|
Example:
|
|
- `--gpu 0000:03:00.0`
|
|
- `--gpu 0.0`
|
|
- `-w, --whitelist <METRIC>`: Comma-separated list of metric field names to include.
|
|
- `-b, --blacklist <METRIC>`: Comma-separated list of metric field names to exclude.
|
|
|
|
### Examples
|
|
|
|
#### List Supported GPUs and Metrics
|
|
|
|
```sh
|
|
amdsmi_exporter list
|
|
```
|
|
|
|
#### Export Metrics and Run HTTP Server on Port 8080 for a Specific GPU
|
|
|
|
```sh
|
|
amdsmi_exporter metric --port 8080 --gpu 0000:03:00.0
|
|
```
|
|
|
|
#### Export Metrics with Whitelist Filter
|
|
|
|
```sh
|
|
amdsmi_exporter metric --whitelist AMDSMI_FI_GFX_ACTIVITY,AMDSMI_FI_UMC_ACTIVITY
|
|
```
|
|
|
|
#### Export Metrics with Blacklist Filter
|
|
|
|
```sh
|
|
amdsmi_exporter metric --blacklist AMDSMI_FI_GFX_VOLTAGE,AMDSMI_FI_SOC_VOLTAGE
|
|
```
|
|
|
|
### Set Up Prometheus Docker Server to Connect to This Client Exporter
|
|
|
|
To set up a Prometheus Docker server to connect to this client exporter, follow these steps:
|
|
|
|
1. **Create a Prometheus Configuration File**
|
|
|
|
Create a file named prometheus.yml with the following content:
|
|
|
|
```yaml
|
|
global:
|
|
scrape_interval: 15s
|
|
|
|
scrape_configs:
|
|
- job_name: 'amdsmi_exporter'
|
|
static_configs:
|
|
- targets: ['localhost:9898']
|
|
```
|
|
|
|
Replace `localhost:9898` with the appropriate address and port if you are running the exporter on a different host or port.
|
|
|
|
2. **Run Prometheus Docker Container**
|
|
|
|
Run the Prometheus Docker container with the configuration file:
|
|
|
|
```sh
|
|
docker run -d --name=prometheus -p 9090:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
|
|
```
|
|
|
|
3. **Access Prometheus Web Interface**
|
|
|
|
Open your web browser and go to `http://localhost:9090` to access the Prometheus web interface. You should see the `amdsmi_exporter` job listed under the "Targets" section.
|