Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
container_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
38#include <atomic>
39#include <memory>
40#include <mutex>
41#include <string>
42#include <unordered_map>
43#include <vector>
44
46
47namespace kcenon {
48namespace monitoring {
49
50// Forward declarations
51class container_collector;
52
53namespace plugins {
54
61 docker,
63 podman,
64 cri_o
65};
66
74
76 bool enable_docker = true;
77
79 bool enable_kubernetes = false;
80
82 bool enable_cgroup = true;
83
85 std::string docker_socket = "/var/run/docker.sock";
86
88 std::string kubeconfig_path;
89
91 std::string namespace_filter;
92
95
98
101};
102
117 public:
123 static std::unique_ptr<container_plugin> create(const container_plugin_config& config = {});
124
126
127 // Disable copy
130
131 // metric_collector_plugin interface
132 bool initialize(const std::unordered_map<std::string, std::string>& config) override;
133 std::vector<metric> collect() override;
134 std::string get_name() const override;
135 std::vector<std::string> get_metric_types() const override;
136 bool is_healthy() const override;
137 std::unordered_map<std::string, double> get_statistics() const override;
138
144
150
156
162
168
174
180
181 private:
183
184 // Internal collectors
185 std::unique_ptr<container_collector> container_collector_;
186
187 // Configuration
189 bool initialized_{false};
190
191 // Statistics
192 mutable std::mutex stats_mutex_;
193 std::atomic<size_t> total_collections_{0};
194 std::atomic<size_t> collection_errors_{0};
195 std::atomic<size_t> containers_found_{0};
196
197 // Helper methods
199};
200
201} // namespace plugins
202} // namespace monitoring
203} // namespace kcenon
Container monitoring plugin aggregating Docker, Kubernetes, and cgroup collectors.
std::string get_name() const override
std::unordered_map< std::string, double > get_statistics() const override
bool initialize(const std::unordered_map< std::string, std::string > &config) override
std::vector< std::string > get_metric_types() const override
static std::unique_ptr< container_plugin > create(const container_plugin_config &config={})
container_plugin(const container_plugin &)=delete
std::unique_ptr< container_collector > container_collector_
container_plugin_config get_config() const
container_plugin(const container_plugin_config &config)
static container_runtime detect_runtime()
container_plugin & operator=(const container_plugin &)=delete
std::vector< metric > collect() override
container_runtime
Supported container runtimes.
@ auto_detect
Automatically detect the container runtime.
Plugin-based metric collector with dynamic discovery and registration.
Configuration options for the container monitoring plugin.
std::string docker_socket
Docker socket path (default: /var/run/docker.sock)
std::string namespace_filter
Kubernetes namespace filter (empty = all namespaces)
std::string kubeconfig_path
Kubeconfig path (empty = in-cluster config)
bool enable_cgroup
Enable cgroup-based metrics collection (default: true)
bool enable_docker
Enable Docker metrics collection (default: true)
bool enable_kubernetes
Enable Kubernetes metrics collection (default: false, requires K8s support)
bool collect_blkio_metrics
Collect block I/O metrics (default: true)
container_runtime runtime
Container runtime to use (default: auto_detect)
bool collect_network_metrics
Collect network metrics (default: true)
bool collect_pid_metrics
Collect process/PID metrics (default: true)