Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
collector_plugin.h File Reference

Plugin interface for metric collectors. More...

#include <chrono>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "../interfaces/metric_types_adapter.h"
#include "../collectors/collector_base.h"
Include dependency graph for collector_plugin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kcenon::monitoring::plugin_metadata
 Metadata describing a collector plugin. More...
 
class  kcenon::monitoring::collector_plugin
 Pure virtual interface for metric collector plugins. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::monitoring
 

Typedefs

using kcenon::monitoring::plugin_factory_fn = std::unique_ptr<collector_plugin> (*)()
 Type alias for plugin factory function.
 

Enumerations

enum class  kcenon::monitoring::plugin_category {
  kcenon::monitoring::system , kcenon::monitoring::hardware , kcenon::monitoring::platform , kcenon::monitoring::network ,
  kcenon::monitoring::process , kcenon::monitoring::custom
}
 Categorization of collector plugins. More...
 

Detailed Description

Plugin interface for metric collectors.

This file defines the plugin architecture for dynamically loadable metric collectors. It provides a common interface that all collectors must implement, enabling runtime registration, discovery, and lifecycle management.

Design Goals:

  • Fewest Elements: Single interface for all collector types
  • Reveals Intention: Clear contract for plugin behavior
  • Separation of Concerns: Collection logic separate from registration
  • Extensibility: Support for both built-in and dynamic plugins

Usage:

class my_collector_plugin : public collector_plugin {
public:
auto name() const -> std::string_view override {
return "my_collector";
}
auto collect() -> std::vector<metric> override {
// Collect and return metrics
return metrics;
}
auto interval() const -> std::chrono::milliseconds override {
return std::chrono::seconds(5);
}
auto is_available() const -> bool override {
// Check platform/resource availability
return true;
}
};
// Register with registry
registry.register_plugin(std::make_unique<my_collector_plugin>());

Definition in file collector_plugin.h.