Kea 2.5.9
isc::perfmon::PerfMonMgr Class Reference

Singleton which provides overall configuration, control, and state of the PerfMon hook library. More...

#include <perfmon_mgr.h>

+ Inheritance diagram for isc::perfmon::PerfMonMgr:

Public Member Functions

 PerfMonMgr (uint16_t family)
 Constructor.
 
virtual ~PerfMonMgr ()=default
 Destructor.
 
void addDurationSample (DurationKeyPtr key, const Duration &sample)
 Adds a duration sample to a MonitoredDuration.
 
void configure (const isc::data::ConstElementPtr &params)
 Parses the hook library 'parameters' element.
 
Duration getAlarmReportInterval ()
 Get the alarm report interval.
 
MonitoredDurationStorePtr getDurationStore ()
 Get the duration store.
 
Duration getIntervalDuration ()
 Get the interval duration.
 
virtual void init ()
 Sets convenience values and (re)creates the duration store.
 
void processPktEventStack (isc::dhcp::PktPtr query, isc::dhcp::PktPtr response, const isc::dhcp::SubnetPtr subnet)
 Processes the event stack of a query packet.
 
void reportAlarm (AlarmPtr alarm, const Duration &average)
 Emits a report for a given alarm.
 
void reportTimerExpired ()
 Handler invoked when the report timer expires.
 
Duration reportToStatsMgr (MonitoredDurationPtr duration)
 Emits an entry to StatsMgr for a given duration.
 
void setNextReportExpiration ()
 Updates the report timer.
 
- Public Member Functions inherited from isc::perfmon::PerfMonConfig
 PerfMonConfig (uint16_t family)
 Constructor.
 
virtual ~PerfMonConfig ()=default
 Destructor.
 
uint32_t getAlarmReportSecs () const
 Fetches the value of alarm-report-secs.
 
AlarmStorePtr getAlarmStore ()
 Get the alarm store.
 
bool getEnableMonitoring () const
 Fetches the value of enable-monitoring.
 
uint16_t getFamily ()
 Get protocol family.
 
uint32_t getIntervalWidthSecs () const
 Fetches the value of interval-width-secs.
 
bool getStatsMgrReporting () const
 Fetches the value of stats-mgr-reporting.
 
void parse (data::ConstElementPtr config)
 Extracts member values from an Element::map.
 
void parseAlarms (data::ConstElementPtr config)
 Re-creates the AlarmStore and populates it by parsing a list of alarm elements.
 
void setAlarmReportSecs (uint32_t value)
 Sets the value of alarm-report-secs.
 
void setEnableMonitoring (bool value)
 Sets the value of enable-monitoring.
 
void setIntervalWidthSecs (uint32_t value)
 Sets the value of interval-width-secs.
 
void setStatsMgrReporting (bool value)
 Sets the value of stats-mgr-reporting.
 

Protected Attributes

Duration alarm_report_interval_
 Length of time between raised Alarm reports.
 
MonitoredDurationStorePtr duration_store_
 In-memory store of MonitoredDurations.
 
Duration interval_duration_
 Length of time a MonitoredDuration accumulates samples until reporting.
 
asiolink::IOServicePtr io_service_
 Tracks whether or not the server is processing DHCP packets.
 
const boost::scoped_ptr< std::mutex > mutex_
 The mutex used to protect internal state.
 
asiolink::IntervalTimerPtr report_timer_
 Timer which tracks the next duration due to report.
 
- Protected Attributes inherited from isc::perfmon::PerfMonConfig
uint32_t alarm_report_secs_
 Number of seconds between reports of a raised alarm.
 
AlarmStorePtr alarm_store_
 Stores the configured alarms.
 
bool enable_monitoring_
 If true, performance data is processed/reported.
 
uint16_t family_
 Protocol family AF_INET or AF_INET6.
 
uint32_t interval_width_secs_
 Number of seconds a duration accumulates samples until reporting.
 
bool stats_mgr_reporting_
 If true durations report to StatsMgr at the end of each interval.
 

Additional Inherited Members

- Static Public Attributes inherited from isc::perfmon::PerfMonConfig
static const data::SimpleKeywords CONFIG_KEYWORDS
 List of valid parameters and expected types.
 
static const data::SimpleDefaults SIMPLE_DEFAULTS
 List of valid parameter defaults.
 

Detailed Description

Singleton which provides overall configuration, control, and state of the PerfMon hook library.

It owns the MonitoredDurationStore and AlarmStore instances and supplies callout and command API handlers. It derives from PerfMonConfig.

Definition at line 27 of file perfmon_mgr.h.

Constructor & Destructor Documentation

◆ PerfMonMgr()

isc::perfmon::PerfMonMgr::PerfMonMgr ( uint16_t  family)
explicit

Constructor.

Parameters
familyProtocol family AF_INET or AF_INET6.

Definition at line 28 of file perfmon_mgr.cc.

References init().

+ Here is the call graph for this function:

◆ ~PerfMonMgr()

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

Destructor.

Member Function Documentation

◆ addDurationSample()

void isc::perfmon::PerfMonMgr::addDurationSample ( DurationKeyPtr  key,
const Duration sample 
)

Adds a duration sample to a MonitoredDuration.

The MonitoredDuration identified by the given key is fetched from the store and updated with the sample. If the update returns the duration this means it is time to report the duration via StatsMgr. The reported average is then checked against an alarm, if one exists. If the check returns the alarm, then the alarm has undergone a reportable event and is passed to reporting.

Parameters
keyidentifies the duration to update.
sampleamount of time that elapsed between the two events identified in the key.

Definition at line 146 of file perfmon_mgr.cc.

References alarm_report_interval_, isc::perfmon::PerfMonConfig::alarm_store_, duration_store_, reportAlarm(), and reportToStatsMgr().

Referenced by processPktEventStack().

+ Here is the call graph for this function:

◆ configure()

void isc::perfmon::PerfMonMgr::configure ( const isc::data::ConstElementPtr params)

Parses the hook library 'parameters' element.

Parameters
paramsmap of configuration parameters to parse.

Definition at line 44 of file perfmon_mgr.cc.

References init(), isc_throw, isc::data::Element::map, isc::perfmon::PerfMonConfig::parse(), isc::perfmon::PerfMonConfig::setEnableMonitoring(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ getAlarmReportInterval()

Duration isc::perfmon::PerfMonMgr::getAlarmReportInterval ( )
inline

Get the alarm report interval.

Returns
alarm-report-secs as a Duration.

Definition at line 118 of file perfmon_mgr.h.

References alarm_report_interval_.

◆ getDurationStore()

MonitoredDurationStorePtr isc::perfmon::PerfMonMgr::getDurationStore ( )
inline

Get the duration store.

Returns
pointer to the duration store.

Definition at line 125 of file perfmon_mgr.h.

References duration_store_.

◆ getIntervalDuration()

Duration isc::perfmon::PerfMonMgr::getIntervalDuration ( )
inline

Get the interval duration.

Returns
interval-width-secs as a Duration.

Definition at line 111 of file perfmon_mgr.h.

References interval_duration_.

◆ init()

void isc::perfmon::PerfMonMgr::init ( )
virtual

Sets convenience values and (re)creates the duration store.

Called by the constructor and also by configure().

Definition at line 34 of file perfmon_mgr.cc.

References alarm_report_interval_, isc::perfmon::PerfMonConfig::alarm_report_secs_, duration_store_, isc::perfmon::PerfMonConfig::family_, interval_duration_, and isc::perfmon::PerfMonConfig::interval_width_secs_.

Referenced by PerfMonMgr(), and configure().

◆ processPktEventStack()

void isc::perfmon::PerfMonMgr::processPktEventStack ( isc::dhcp::PktPtr  query,
isc::dhcp::PktPtr  response,
const isc::dhcp::SubnetPtr  subnet 
)

Processes the event stack of a query packet.

Todo:
DETAILS TO FOLLOW
Parameters
queryquery packet whose stack is to be processed.
responseresponse packet generated for the query.
subnetselected subnet, if empty use the global subnet id.

Definition at line 68 of file perfmon_mgr.cc.

References addDurationSample(), isc::log::DBGLVL_TRACE_DETAIL, isc::dhcp::DHCP_NOTYPE, DHCPV6_NOTYPE, isc::perfmon::PerfMonConfig::enable_monitoring_, isc::perfmon::PerfMonConfig::family_, isc_throw, LOG_DEBUG, PERFMON_DHCP4_PKT_EVENTS, PERFMON_DHCP6_PKT_EVENTS, isc::perfmon::perfmon_logger, and isc::perfmon::DurationKey::validateMessagePair().

+ Here is the call graph for this function:

◆ reportAlarm()

void isc::perfmon::PerfMonMgr::reportAlarm ( AlarmPtr  alarm,
const Duration average 
)

Emits a report for a given alarm.

Emits a WARN log if the alarm state is TRIGGERED or an INFO log if it is CLEARED. This may expand in the future to accommodate additional reporting mechanisms.

Parameters
alarmAlarm to report.
averageDuration average which caused the state transition.

Definition at line 186 of file perfmon_mgr.cc.

References isc::perfmon::PerfMonConfig::alarm_store_, isc::perfmon::Alarm::CLEAR, isc::perfmon::Alarm::DISABLED, LOG_INFO, LOG_WARN, PERFMON_ALARM_CLEARED, PERFMON_ALARM_TRIGGERED, isc::perfmon::perfmon_logger, isc::util::ptimeToText(), and isc::perfmon::Alarm::TRIGGERED.

Referenced by addDurationSample().

+ Here is the call graph for this function:

◆ reportTimerExpired()

void isc::perfmon::PerfMonMgr::reportTimerExpired ( )

Handler invoked when the report timer expires.

Fetches a list of the durations which are overdue to report and submits them for reporting.

Definition at line 213 of file perfmon_mgr.cc.

References isc_throw.

◆ reportToStatsMgr()

Duration isc::perfmon::PerfMonMgr::reportToStatsMgr ( MonitoredDurationPtr  duration)

Emits an entry to StatsMgr for a given duration.

Calculates the average duration for the reportable interval and reports the value to StatsMgr if stat-mgr-reporting is true.

Parameters
durationduration to report.
Returns
Always returns the average duration for reportable interval.
Todo:
  • decide if we want to report min and max values too.

Definition at line 164 of file perfmon_mgr.cc.

References isc::perfmon::PerfMonConfig::getStatsMgrReporting(), isc::stats::StatsMgr::instance(), isc_throw, and isc::stats::StatsMgr::setValue().

Referenced by addDurationSample().

+ Here is the call graph for this function:

◆ setNextReportExpiration()

void isc::perfmon::PerfMonMgr::setNextReportExpiration ( )

Updates the report timer.

MonitoredDurationPtr next = durations->getReportsNext() if next reschedule report timer for (next->getIntervalStart() + interval_duration_); else cancel report timer

Definition at line 218 of file perfmon_mgr.cc.

References isc_throw.

Member Data Documentation

◆ alarm_report_interval_

Duration isc::perfmon::PerfMonMgr::alarm_report_interval_
protected

Length of time between raised Alarm reports.

It's a conversion of alarm-report-secs to a Duration set during configuration parsing.

Definition at line 136 of file perfmon_mgr.h.

Referenced by addDurationSample(), getAlarmReportInterval(), and init().

◆ duration_store_

MonitoredDurationStorePtr isc::perfmon::PerfMonMgr::duration_store_
protected

In-memory store of MonitoredDurations.

Definition at line 139 of file perfmon_mgr.h.

Referenced by addDurationSample(), getDurationStore(), and init().

◆ interval_duration_

Duration isc::perfmon::PerfMonMgr::interval_duration_
protected

Length of time a MonitoredDuration accumulates samples until reporting.

Definition at line 131 of file perfmon_mgr.h.

Referenced by getIntervalDuration(), and init().

◆ io_service_

asiolink::IOServicePtr isc::perfmon::PerfMonMgr::io_service_
protected

Tracks whether or not the server is processing DHCP packets.

Todo:
Not sure if we really care. When not in service, traffic will effectively stop. Any active durations will eventually report once via timer but nothing more until traffic resumes.

IOService instance used by the timer.

Definition at line 149 of file perfmon_mgr.h.

◆ mutex_

const boost::scoped_ptr<std::mutex> isc::perfmon::PerfMonMgr::mutex_
protected

The mutex used to protect internal state.

Definition at line 155 of file perfmon_mgr.h.

◆ report_timer_

asiolink::IntervalTimerPtr isc::perfmon::PerfMonMgr::report_timer_
protected

Timer which tracks the next duration due to report.

Definition at line 152 of file perfmon_mgr.h.


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