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

Health monitoring with dependency graphs, auto-recovery, and statistics. More...

#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <memory>
#include <mutex>
#include <queue>
#include <shared_mutex>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <kcenon/monitoring/interfaces/monitoring_core.h>
Include dependency graph for health_monitor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kcenon::monitoring::health_monitor_config
 Configuration for the health_monitor. More...
 
struct  kcenon::monitoring::health_monitor_stats
 Accumulated statistics for health monitoring operations. More...
 
class  kcenon::monitoring::health_check
 Abstract base class for health checks. More...
 
class  kcenon::monitoring::functional_health_check
 Health check implementation backed by a std::function. More...
 
class  kcenon::monitoring::composite_health_check
 Composite health check that aggregates multiple sub-checks. More...
 
class  kcenon::monitoring::health_dependency_graph
 Directed acyclic graph for health check dependencies. More...
 
class  kcenon::monitoring::health_check_builder
 Fluent builder for creating functional_health_check instances. More...
 
class  kcenon::monitoring::health_monitor
 Health monitor with dependency management, auto-recovery, and statistics. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::monitoring
 

Enumerations

enum class  kcenon::monitoring::health_check_type { kcenon::monitoring::liveness , kcenon::monitoring::readiness , kcenon::monitoring::startup }
 Types of health checks following Kubernetes probe conventions. More...
 

Functions

health_monitorkcenon::monitoring::global_health_monitor ()
 Get the global health monitor singleton instance.
 

Detailed Description

Health monitoring with dependency graphs, auto-recovery, and statistics.

Provides a comprehensive health monitoring framework including:

  • Pluggable health checks (functional, composite, dependency-aware)
  • DAG-based dependency graph for ordered checking
  • Automatic periodic monitoring with configurable intervals
  • Auto-recovery handlers for unhealthy components
  • Builder pattern for convenient health check creation

Thread Safety

health_monitor and health_dependency_graph use std::shared_mutex for concurrent read access and exclusive write access. The monitoring loop runs on a dedicated thread.

health_monitor monitor({
.check_interval = std::chrono::milliseconds(5000),
.enable_auto_recovery = true,
.max_consecutive_failures = 3
});
auto db_check = health_check_builder()
.with_name("database")
.with_type(health_check_type::readiness)
.with_check([]() { return check_db_connection(); })
.critical(true)
.build();
monitor.register_check("database", db_check);
monitor.start();
Author
kcenon
Since
1.0.0
See also
thread_context For request-scoped context during health checks

Definition in file health_monitor.h.