Kea 2.7.5
|
Singleton which provides overall configuration, control, and state of the PerfMon hook library. More...
#include <perfmon_mgr.h>
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 ¶ms) |
Parses the hook library 'parameters' element. | |
data::ElementPtr | formatDurationDataAsElements (MonitoredDurationCollectionPtr durations) const |
Renders a list of MonitoredDurations as a map of individual Elements. | |
data::ElementPtr | formatDurationDataAsResultSet (MonitoredDurationCollectionPtr durations) const |
Renders a list of MonitoredDurations as a result set. | |
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. | |
int | perfmonControlHandler (hooks::CalloutHandle &handle) |
perfmon-control command handler | |
int | perfmonGetAllDurationsHandler (hooks::CalloutHandle &handle) |
perfmon-get-all-durations handler | |
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 &mean) |
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. | |
std::atomic< 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. | |
std::atomic< 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. | |
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 PerfMonConfiga and CmdsImpl.
Definition at line 29 of file perfmon_mgr.h.
|
explicit |
Constructor.
family | Protocol family AF_INET or AF_INET6. |
Definition at line 31 of file perfmon_mgr.cc.
References init().
|
virtualdefault |
Destructor.
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 mean 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.
key | identifies the duration to update. |
sample | amount of time that elapsed between the two events identified in the key. |
Definition at line 149 of file perfmon_mgr.cc.
References alarm_report_interval_, isc::perfmon::PerfMonConfig::alarm_store_, duration_store_, reportAlarm(), and reportToStatsMgr().
Referenced by processPktEventStack().
void isc::perfmon::PerfMonMgr::configure | ( | const isc::data::ConstElementPtr & | params | ) |
Parses the hook library 'parameters' element.
params | map of configuration parameters to parse. |
Definition at line 47 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().
ElementPtr isc::perfmon::PerfMonMgr::formatDurationDataAsElements | ( | MonitoredDurationCollectionPtr | durations | ) | const |
Renders a list of MonitoredDurations as a map of individual Elements.
durations | collection of durations to convert |
Definition at line 336 of file perfmon_mgr.cc.
References isc::data::Element::createList().
Referenced by perfmonGetAllDurationsHandler().
ElementPtr isc::perfmon::PerfMonMgr::formatDurationDataAsResultSet | ( | MonitoredDurationCollectionPtr | durations | ) | const |
Renders a list of MonitoredDurations as a result set.
The result set Element will be as shown below:
durations | collection of durations to convert |
Definition at line 350 of file perfmon_mgr.cc.
References isc::data::Element::createList(), isc::data::Element::createMap(), and isc::perfmon::MonitoredDuration::valueRowColumns().
Referenced by perfmonGetAllDurationsHandler().
|
inline |
Get the alarm report interval.
Definition at line 273 of file perfmon_mgr.h.
References alarm_report_interval_.
|
inline |
Get the duration store.
Definition at line 280 of file perfmon_mgr.h.
References duration_store_.
|
inline |
Get the interval duration.
Definition at line 266 of file perfmon_mgr.h.
References interval_duration_.
|
virtual |
Sets convenience values and (re)creates the duration store.
Called by the constructor and also by configure().
Definition at line 37 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().
int isc::perfmon::PerfMonMgr::perfmonControlHandler | ( | hooks::CalloutHandle & | handle | ) |
perfmon-control command handler
This command sets enable-monitoring and/or stats-mgr-reporting (affects in memory value(s) only).
It extracts the command name and arguments from the given CalloutHandle, attempts to process them, and then set's the handle's "response" arguments accordingly. Regardless of which arguments, if any, were specified the command will always return the new/current values for both settings.
handle | Callout context - which is expected to contain the command JSON text in the "command" argument |
Definition at line 226 of file perfmon_mgr.cc.
References isc::data::Element::boolean, isc::data::SimpleParser::checkKeywords(), isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_SUCCESS, isc::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createMap(), isc::perfmon::PerfMonConfig::enable_monitoring_, isc::config::CmdsImpl::extractCommand(), LOG_ERROR, LOG_INFO, PERFMON_CMDS_CONTROL_ERROR, PERFMON_CMDS_CONTROL_OK, isc::perfmon::perfmon_logger, isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), and isc::perfmon::PerfMonConfig::stats_mgr_reporting_.
int isc::perfmon::PerfMonMgr::perfmonGetAllDurationsHandler | ( | hooks::CalloutHandle & | handle | ) |
perfmon-get-all-durations handler
This command fetches all of the monitored durations and their previous intervals (if one).
It extracts the command name and arguments from the given CalloutHandle, attempts to process them, and then set's the handle's "response" arguments accordingly. If result-set-format is false (the default) the durations are returned as a list of Elements:
If result-set-format is true, the durations are returned in a more compact format, patterned after an SQL result set:
handle | Callout context - which is expected to contain the command JSON text in the "command" argument |
Definition at line 279 of file perfmon_mgr.cc.
References isc::data::Element::boolean, isc::data::SimpleParser::checkKeywords(), isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createMap(), duration_store_, isc::config::CmdsImpl::extractCommand(), formatDurationDataAsElements(), formatDurationDataAsResultSet(), isc::perfmon::PerfMonConfig::getIntervalWidthSecs(), LOG_ERROR, LOG_INFO, isc::dhcp::PktEvent::now(), PERFMON_CMDS_GET_ALL_DURATIONS_ERROR, PERFMON_CMDS_GET_ALL_DURATIONS_OK, isc::perfmon::perfmon_logger, isc::util::ptimeToText(), isc::config::CmdsImpl::setErrorResponse(), and isc::config::CmdsImpl::setResponse().
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.
query | query packet whose stack is to be processed. |
response | response packet generated for the query. |
subnet | selected subnet, if empty use the global subnet id. |
Definition at line 71 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().
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.
alarm | Alarm to report. |
mean | Duration mean which caused the state transition. |
Definition at line 189 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().
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 216 of file perfmon_mgr.cc.
References isc_throw.
Duration isc::perfmon::PerfMonMgr::reportToStatsMgr | ( | MonitoredDurationPtr | duration | ) |
Emits an entry to StatsMgr for a given duration.
Calculates the mean duration for the reportable interval and reports the value to StatsMgr if stat-mgr-reporting is true.
duration | duration to report. |
Definition at line 167 of file perfmon_mgr.cc.
References isc::perfmon::PerfMonConfig::getStatsMgrReporting(), isc::stats::StatsMgr::instance(), and isc_throw.
Referenced by addDurationSample().
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 221 of file perfmon_mgr.cc.
References isc_throw.
|
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 291 of file perfmon_mgr.h.
Referenced by addDurationSample(), getAlarmReportInterval(), and init().
|
protected |
In-memory store of MonitoredDurations.
Definition at line 294 of file perfmon_mgr.h.
Referenced by addDurationSample(), getDurationStore(), init(), and perfmonGetAllDurationsHandler().
|
protected |
Length of time a MonitoredDuration accumulates samples until reporting.
Definition at line 286 of file perfmon_mgr.h.
Referenced by getIntervalDuration(), and init().
|
protected |
Tracks whether or not the server is processing DHCP packets.
IOService instance used by the timer.
Definition at line 304 of file perfmon_mgr.h.
|
protected |
The mutex used to protect internal state.
Definition at line 310 of file perfmon_mgr.h.
|
protected |
Timer which tracks the next duration due to report.
Definition at line 307 of file perfmon_mgr.h.