Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
test_health_check Class Reference
Inheritance diagram for test_health_check:
Inheritance graph
Collaboration diagram for test_health_check:
Collaboration graph

Public Member Functions

 test_health_check (const std::string &name, health_check_type type, health_status status=health_status::healthy, const std::string &message="OK")
 
std::string get_name () const override
 Get the human-readable name of this health check.
 
health_check_type get_type () const override
 Get the type of this health check (liveness, readiness, or startup).
 
health_check_result check () override
 Execute the health check and return the result.
 
void set_status (health_status status)
 
void set_message (const std::string &msg)
 
- Public Member Functions inherited from kcenon::monitoring::health_check
virtual ~health_check ()=default
 
virtual std::chrono::milliseconds get_timeout () const
 Get the maximum time allowed for this check to complete.
 
virtual bool is_critical () const
 Whether this check is critical for overall system health.
 

Private Attributes

std::string name_
 
health_check_type type_
 
std::atomic< health_statusstatus_
 
std::string message_
 
std::mutex mutex_
 

Detailed Description

Definition at line 21 of file test_health_monitoring.cpp.

Constructor & Destructor Documentation

◆ test_health_check()

test_health_check::test_health_check ( const std::string & name,
health_check_type type,
health_status status = health_status::healthy,
const std::string & message = "OK" )
inline

Definition at line 30 of file test_health_monitoring.cpp.

35 : name_(name), type_(type), status_(status), message_(message) {}
std::atomic< health_status > status_

Member Function Documentation

◆ check()

health_check_result test_health_check::check ( )
inlineoverridevirtual

Execute the health check and return the result.

Returns
A health_check_result indicating the current health status

Implements kcenon::monitoring::health_check.

Definition at line 40 of file test_health_monitoring.cpp.

40 {
41 std::lock_guard<std::mutex> lock(mutex_);
43 result.status = status_.load();
44 result.message = message_;
45 result.timestamp = std::chrono::system_clock::now();
46 result.check_duration = std::chrono::milliseconds(10);
47 return result;
48 }
Result of a health check operation.
std::chrono::system_clock::time_point timestamp
std::chrono::milliseconds check_duration

References kcenon::monitoring::health_check_result::check_duration, kcenon::monitoring::health_check_result::message, message_, mutex_, kcenon::monitoring::health_check_result::status, status_, and kcenon::monitoring::health_check_result::timestamp.

◆ get_name()

std::string test_health_check::get_name ( ) const
inlineoverridevirtual

Get the human-readable name of this health check.

Returns
The health check name

Implements kcenon::monitoring::health_check.

Definition at line 37 of file test_health_monitoring.cpp.

37{ return name_; }

References name_.

◆ get_type()

health_check_type test_health_check::get_type ( ) const
inlineoverridevirtual

Get the type of this health check (liveness, readiness, or startup).

Returns
The health check type

Implements kcenon::monitoring::health_check.

Definition at line 38 of file test_health_monitoring.cpp.

38{ return type_; }

References type_.

◆ set_message()

void test_health_check::set_message ( const std::string & msg)
inline

Definition at line 51 of file test_health_monitoring.cpp.

51 {
52 std::lock_guard<std::mutex> lock(mutex_);
53 message_ = msg;
54 }

References message_, and mutex_.

◆ set_status()

void test_health_check::set_status ( health_status status)
inline

Definition at line 50 of file test_health_monitoring.cpp.

50{ status_.store(status); }

References status_.

Member Data Documentation

◆ message_

std::string test_health_check::message_
private

Definition at line 26 of file test_health_monitoring.cpp.

Referenced by check(), and set_message().

◆ mutex_

std::mutex test_health_check::mutex_
mutableprivate

Definition at line 27 of file test_health_monitoring.cpp.

Referenced by check(), and set_message().

◆ name_

std::string test_health_check::name_
private

Definition at line 23 of file test_health_monitoring.cpp.

Referenced by get_name().

◆ status_

std::atomic<health_status> test_health_check::status_
private

Definition at line 25 of file test_health_monitoring.cpp.

Referenced by check(), and set_status().

◆ type_

health_check_type test_health_check::type_
private

Definition at line 24 of file test_health_monitoring.cpp.

Referenced by get_type().


The documentation for this class was generated from the following file: