Kea 2.7.5
isc::perfmon::Alarm Class Reference

Defines an alarm for a duration. More...

#include <alarm.h>

+ Inheritance diagram for isc::perfmon::Alarm:

Public Types

enum  State { CLEAR , TRIGGERED , DISABLED }
 Defines Alarm states. More...
 

Public Member Functions

 Alarm (const DurationKey &key, const Duration &low_water, const Duration &high_water, bool enabled=true)
 Constructor.
 
 Alarm (uint16_t family, uint8_t query_type, uint8_t response_type, const std::string &start_event_label, const std::string &stop_event_label, dhcp::SubnetID subnet_id, const Duration &low_water, const Duration &high_water, bool enabled=true)
 Constructor.
 
virtual ~Alarm ()=default
 Destructor.
 
bool checkSample (const Duration &sample, const Duration &report_interval)
 Checks a duration against the high and low water thresholds and calls the appropriate event handler.
 
void clear ()
 Sets the alarm back to the CLEAR state.
 
void disable ()
 Disables the alarm by setting the state to DISABLED.
 
Duration getHighWater () const
 Get the high water threshold.
 
Timestamp getLastHighWaterReport ()
 Get the timestamp of the last high water report.
 
Duration getLowWater () const
 Get the low water threshold.
 
State getState ()
 Get the alarm's state.
 
Timestamp getStosTime ()
 Get the time the current state began.
 
void setHighWater (const Duration &high_water)
 Set the high water threshold.
 
void setLastHighWaterReport (const Timestamp &timestamp=dhcp::PktEvent::now())
 Set the timestamp of the last high water report.
 
void setLowWater (const Duration &low_water)
 Set the low water threshold.
 
void setState (State state)
 Sets the alarm state.
 
- Public Member Functions inherited from isc::perfmon::DurationKey
 DurationKey (uint16_t family, uint8_t query_type, uint8_t response_type, const std::string &start_event_label, const std::string &stop_event_label, dhcp::SubnetID subnet_id)
 Constructor.
 
virtual ~DurationKey ()=default
 Destructor.
 
uint16_t getFamily ()
 Get protocol family.
 
std::string getLabel () const
 Get a composite label of the member values with text message types.
 
uint8_t getQueryType () const
 Get the query packet type.
 
uint8_t getResponseType () const
 Get the response packet type.
 
std::string getStartEventLabel () const
 Get the start event label.
 
std::string getStatName (const std::string &value_name) const
 Get the StatsMgr formatted compatible name.
 
std::string getStopEventLabel () const
 Get the end event label.
 
dhcp::SubnetID getSubnetId () const
 Get the subnet id.
 
bool operator!= (const DurationKey &other) const
 Inequality operator.
 
bool operator< (const DurationKey &other) const
 Less than operator.
 
bool operator== (const DurationKey &other) const
 Equality operator.
 
void setSubnetId (dhcp::SubnetID subnet_id)
 Set the subnet id.
 
virtual data::ElementPtr toElement () const
 Renders the the duration key as an Element.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::perfmon::DurationKey
static std::string getMessageTypeLabel (uint16_t family, uint16_t msg_type)
 Get a label for a family-specific message type (e.g.
 
static void validateMessagePair (uint16_t family, uint8_t query_type, uint8_t response_type)
 Validates that a query and response message type pair is sane.
 
- Protected Attributes inherited from isc::perfmon::DurationKey
uint16_t family_
 Protocol family AF_INET or AF_INET6.
 
uint8_t query_type_
 Query message type (e.g. DHCPDISCOVER, DHCP6_SOLICIT).
 
uint8_t response_type_
 Response message type (e.g. DHCPOFFER, DHCP6_ADVERTISE).
 
std::string start_event_label_
 Label of the start event which begins the duration.
 
std::string stop_event_label_
 Label of the end event which ends the duration.
 
isc::dhcp::SubnetID subnet_id_
 Subnet ID of the subnet selected during query fulfillment.
 

Detailed Description

Defines an alarm for a duration.

Definition at line 20 of file alarm.h.

Member Enumeration Documentation

◆ State

Defines Alarm states.

Enumerator
CLEAR 
TRIGGERED 
DISABLED 

Definition at line 23 of file alarm.h.

Constructor & Destructor Documentation

◆ Alarm() [1/2]

isc::perfmon::Alarm::Alarm ( uint16_t family,
uint8_t query_type,
uint8_t response_type,
const std::string & start_event_label,
const std::string & stop_event_label,
dhcp::SubnetID subnet_id,
const Duration & low_water,
const Duration & high_water,
bool enabled = true )

Constructor.

Parameters
familyprotocol family AF_INET or AF_INET6
query_typemessage type of the query packet
response_typemessage type of the response packet
start_event_labellabel of the start event
stop_event_labellabel of the end event
subnet_idSubnetID of the selected subnet
low_waterthreshold below which the mean duration must fall to clear the alarm
high_waterthreshold above which the mean duration must rise to trigger the alarm
enabledtrue sets state to CLEAR, otherwise DISABLED, defaults to true

Definition at line 21 of file alarm.cc.

References isc_throw.

◆ Alarm() [2/2]

isc::perfmon::Alarm::Alarm ( const DurationKey & key,
const Duration & low_water,
const Duration & high_water,
bool enabled = true )

Constructor.

Parameters
keycomposite key that identifies the alarm
low_waterthreshold below which the mean duration must fall to clear the alarm
high_waterthreshold above which the mean duration must rise to trigger the alarm
enabledtrue sets state to CLEAR, otherwise DISABLED, defaults to true

Definition at line 42 of file alarm.cc.

References isc_throw.

◆ ~Alarm()

virtual isc::perfmon::Alarm::~Alarm ( )
virtualdefault

Destructor.

Member Function Documentation

◆ checkSample()

bool isc::perfmon::Alarm::checkSample ( const Duration & sample,
const Duration & report_interval )

Checks a duration against the high and low water thresholds and calls the appropriate event handler.

  1. If the sample is less than the low water threshold: If the state is TRIGGERED, transition to CLEAR and return true otherwise return false.
  2. If the sample is greater than high water threshold: If the state is not TRIGGERED, transition to TRIGGERED
  3. If the state is TRIGGERED and the last report time either not set or is more than report interval old, update the last report time to current time and return true.
  4. Otherwise return false.
Parameters
sampleduration to test against the thresholds.
report_intervalamount of time that must elapse between high water reports.
Returns
True if alarm state should be reported.
Exceptions
InvalidOperationif called when the state is DISABLED.

Definition at line 96 of file alarm.cc.

References CLEAR, DISABLED, isc::dhcp::PktEvent::EMPTY_TIME(), isc_throw, isc::dhcp::PktEvent::now(), setState(), and TRIGGERED.

+ Here is the call graph for this function:

◆ clear()

void isc::perfmon::Alarm::clear ( )

Sets the alarm back to the CLEAR state.

Definition at line 86 of file alarm.cc.

References CLEAR, and setState().

+ Here is the call graph for this function:

◆ disable()

void isc::perfmon::Alarm::disable ( )

Disables the alarm by setting the state to DISABLED.

Definition at line 91 of file alarm.cc.

References DISABLED, and setState().

+ Here is the call graph for this function:

◆ getHighWater()

Duration isc::perfmon::Alarm::getHighWater ( ) const
inline

Get the high water threshold.

Returns
Duration containing the high water threshold.

Definition at line 73 of file alarm.h.

◆ getLastHighWaterReport()

Timestamp isc::perfmon::Alarm::getLastHighWaterReport ( )
inline

Get the timestamp of the last high water report.

Returns
Timestamp containing the last high water report time.

Definition at line 108 of file alarm.h.

◆ getLowWater()

Duration isc::perfmon::Alarm::getLowWater ( ) const
inline

Get the low water threshold.

Returns
Duration containing the low water threshold.

Definition at line 59 of file alarm.h.

◆ getState()

State isc::perfmon::Alarm::getState ( )
inline

Get the alarm's state.

Definition at line 85 of file alarm.h.

◆ getStosTime()

Timestamp isc::perfmon::Alarm::getStosTime ( )
inline

Get the time the current state began.

Returns
Timestamp the alarm entered it's current state.

Definition at line 101 of file alarm.h.

◆ setHighWater()

void isc::perfmon::Alarm::setHighWater ( const Duration & high_water)

Set the high water threshold.

Parameters
high_waternew value for the high water threshold.
Exceptions
BadValueif new value is less than the current value of low water.

Definition at line 69 of file alarm.cc.

References isc_throw.

◆ setLastHighWaterReport()

void isc::perfmon::Alarm::setLastHighWaterReport ( const Timestamp & timestamp = dhcp::PktEvent::now())
inline

Set the timestamp of the last high water report.

This function is provided for test purposes only.

Parameters
timestampnew value of the last high water report, defaults to the current time.

Definition at line 118 of file alarm.h.

◆ setLowWater()

void isc::perfmon::Alarm::setLowWater ( const Duration & low_water)

Set the low water threshold.

Parameters
low_waternew value for the low water threshold.
Exceptions
BadValueif new value is greater than the current value of high water.

Definition at line 59 of file alarm.cc.

References isc_throw.

◆ setState()

void isc::perfmon::Alarm::setState ( State state)

Sets the alarm state.

Sets the alarm's state to the given value, sets the start of state time to the current time, and resets the last high water report.

Parameters
statenew state to which to transition.

Definition at line 79 of file alarm.cc.

References isc::dhcp::PktEvent::EMPTY_TIME(), and isc::dhcp::PktEvent::now().

Referenced by checkSample(), clear(), and disable().

+ Here is the call graph for this function:

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