Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
hardware_plugin.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6
34#include <atomic>
35#include <memory>
36#include <mutex>
37#include <string>
38#include <unordered_map>
39#include <vector>
40
42
43namespace kcenon {
44namespace monitoring {
45
46// Forward declarations for internal collectors
47class battery_collector;
48class power_collector;
49class temperature_collector;
50class gpu_collector;
51
52namespace plugins {
53
60 bool enable_battery = true;
61
63 bool enable_power = true;
64
66 bool enable_temperature = true;
67
69 bool enable_gpu = false;
70
74
77 bool power_collect_rapl = true;
78
82
85 bool gpu_collect_memory = true;
87 bool gpu_collect_power = true;
88 bool gpu_collect_clock = true;
89 bool gpu_collect_fan = true;
90};
91
107 public:
113 static std::unique_ptr<hardware_plugin> create(const hardware_plugin_config& config = {});
114
116
117 // Disable copy
120
121 // metric_collector_plugin interface
122 bool initialize(const std::unordered_map<std::string, std::string>& config) override;
123 std::vector<metric> collect() override;
124 std::string get_name() const override;
125 std::vector<std::string> get_metric_types() const override;
126 bool is_healthy() const override;
127 std::unordered_map<std::string, double> get_statistics() const override;
128
134
139 bool is_power_available() const;
140
146
151 bool is_gpu_available() const;
152
158
159 private:
161
162 // Internal collectors
163 std::unique_ptr<battery_collector> battery_collector_;
164 std::unique_ptr<power_collector> power_collector_;
165 std::unique_ptr<temperature_collector> temperature_collector_;
166 std::unique_ptr<gpu_collector> gpu_collector_;
167
168 // Configuration
170 bool initialized_{false};
171
172 // Statistics
173 mutable std::mutex stats_mutex_;
174 std::atomic<size_t> total_collections_{0};
175 std::atomic<size_t> collection_errors_{0};
176
177 // Helper methods
179};
180
181} // namespace plugins
182} // namespace monitoring
183} // namespace kcenon
Hardware monitoring plugin aggregating battery, power, temperature, and GPU collectors.
std::unique_ptr< power_collector > power_collector_
std::vector< std::string > get_metric_types() const override
hardware_plugin & operator=(const hardware_plugin &)=delete
std::unique_ptr< battery_collector > battery_collector_
static std::unique_ptr< hardware_plugin > create(const hardware_plugin_config &config={})
hardware_plugin_config get_config() const
std::unordered_map< std::string, double > get_statistics() const override
std::vector< metric > collect() override
hardware_plugin(const hardware_plugin_config &config)
std::unique_ptr< gpu_collector > gpu_collector_
hardware_plugin(const hardware_plugin &)=delete
std::string get_name() const override
std::unique_ptr< temperature_collector > temperature_collector_
bool initialize(const std::unordered_map< std::string, std::string > &config) override
Plugin-based metric collector with dynamic discovery and registration.
Configuration options for the hardware monitoring plugin.
bool enable_battery
Enable battery monitoring (default: true)
bool enable_gpu
Enable GPU monitoring (default: false, requires GPU hardware)
bool temperature_collect_thresholds
Temperature-specific options.
bool enable_power
Enable power consumption monitoring (default: true)
bool enable_temperature
Enable temperature monitoring (default: true)