24#include <unordered_map>
148class metrics_provider;
211 auto name() const -> std::string_view
override {
return "gpu"; }
212 auto collect() -> std::vector<metric>
override;
213 auto interval() const -> std::chrono::milliseconds
override {
return std::chrono::seconds(5); }
220 .description =
"GPU metrics (utilization, memory, temperature, power)",
224 .requires_platform_support =
true
265 const std::string& unit =
"")
const;
Pure virtual interface for metric collector plugins.
GPU metrics monitoring collector implementing collector_plugin interface.
auto interval() const -> std::chrono::milliseconds override
Get the collection interval for this plugin.
auto get_metadata() const -> plugin_metadata override
Get plugin metadata.
gpu_collector(gpu_collector &&)=delete
auto is_available() const -> bool override
Check if this plugin is available on the current system.
std::atomic< size_t > collection_count_
gpu_collector(const gpu_collector &)=delete
std::atomic< size_t > collection_errors_
auto collect() -> std::vector< metric > override
Collect current metrics from this plugin.
void shutdown() override
Shutdown plugin and release resources.
gpu_collector & operator=(gpu_collector &&)=delete
auto get_metric_types() const -> std::vector< std::string > override
Get supported metric types.
bool is_gpu_available() const
auto get_statistics() const -> stats_map override
Get plugin statistics.
std::atomic< size_t > gpus_found_
bool collect_utilization_
std::vector< gpu_reading > get_last_readings() const
bool collect_temperature_
auto initialize(const config_map &config) -> bool override
Initialize plugin with configuration.
void add_gpu_metrics(std::vector< metric > &metrics, const gpu_reading &reading)
metric create_metric(const std::string &name, double value, const gpu_reading &reading, const std::string &unit="") const
gpu_collector & operator=(const gpu_collector &)=delete
~gpu_collector() override=default
std::vector< gpu_reading > last_readings_
std::unique_ptr< gpu_info_collector > collector_
auto name() const -> std::string_view override
Get the unique name of this plugin.
GPU data collector using platform abstraction layer.
bool is_gpu_available() const
gpu_info_collector & operator=(gpu_info_collector &&)=delete
std::vector< gpu_reading > read_all_gpu_metrics()
std::unique_ptr< platform::metrics_provider > provider_
gpu_info_collector(const gpu_info_collector &)=delete
gpu_info_collector(gpu_info_collector &&)=delete
std::vector< gpu_device_info > enumerate_gpus()
gpu_info_collector & operator=(const gpu_info_collector &)=delete
Plugin interface for metric collectors.
Adapter for metric types to support interface definitions.
std::unordered_map< std::string, double > stats_map
Type alias for statistics map.
std::string gpu_vendor_to_string(gpu_vendor vendor)
Convert gpu_vendor to string representation.
gpu_type
GPU type classification.
@ virtual_gpu
Virtual GPU (cloud/VM)
@ discrete
Discrete GPU (dedicated graphics card)
@ unknown
Unknown GPU type.
@ integrated
Integrated GPU (part of CPU/SoC)
@ hardware
Hardware sensors (GPU, temperature, battery, power)
std::string gpu_type_to_string(gpu_type type)
Convert gpu_type to string representation.
std::unordered_map< std::string, std::string > config_map
Type alias for configuration map.
gpu_vendor
GPU vendor identification.
@ apple
Apple (Apple Silicon GPU)
@ intel
Intel Corporation.
@ nvidia
NVIDIA Corporation.
@ amd
Advanced Micro Devices.
@ platform
Platform/system power domain.
Information about a GPU device.
std::string id
Unique device identifier (e.g., "gpu0")
uint32_t device_index
Device index for multi-GPU systems.
std::string driver_version
Driver version string.
std::string device_path
Platform-specific path (e.g., /sys/class/drm/card0)
gpu_vendor vendor
GPU vendor.
gpu_type type
GPU type (discrete/integrated)
std::string name
Human-readable device name.
A single GPU metrics reading.
uint64_t memory_used_bytes
VRAM currently used.
bool fan_available
Whether fan metrics available.
double power_watts
Current power consumption.
double fan_speed_percent
Fan speed (0-100)
bool memory_available
Whether memory metrics available.
gpu_device_info device
GPU device information.
bool temperature_available
Whether temperature metrics available.
bool power_available
Whether power metrics available.
double temperature_celsius
GPU temperature.
bool utilization_available
Whether utilization metrics available.
uint64_t memory_total_bytes
Total VRAM capacity.
double utilization_percent
GPU compute utilization (0-100)
double clock_mhz
Current GPU clock speed.
bool clock_available
Whether clock metrics available.
std::chrono::system_clock::time_point timestamp
Reading timestamp.
double memory_clock_mhz
Current memory clock speed.
double power_limit_watts
Power limit/TDP.
Basic metric structure for interface compatibility.