26using namespace boost::posix_time;
59 }
catch (std::exception& ex) {
61 "PerfMonMgr::configure failed - " << ex.
what());
72 uint16_t query_type = query->getType();
76 uint16_t response_type;
81 response_type = response->getType();
87 auto events = query->getPktEvents();
88 if (events.size() < 2) {
94 SubnetID subnet_id = (subnet ? subnet->getID() : SUBNET_ID_GLOBAL);
98 .arg(query->getLabel())
99 .arg(query->dumpPktEvents());
106 boost::posix_time::ptime start_time;
107 boost::posix_time::ptime prev_time;
108 std::string prev_event_label;
109 bool first_pass =
true;
110 for (
auto const& event : events) {
112 prev_event_label =
event.label_;
113 prev_time =
event.timestamp_;
114 start_time = prev_time;
117 Duration sample =
event.timestamp_ - prev_time;
119 prev_event_label, event.label_, subnet_id));
123 if (subnet_id != SUBNET_ID_GLOBAL) {
124 key->setSubnetId(SUBNET_ID_GLOBAL);
128 prev_event_label =
event.label_;
129 prev_time =
event.timestamp_;
134 Duration sample = prev_time - start_time;
136 "composite",
"total_response", subnet_id));
139 if (subnet_id != SUBNET_ID_GLOBAL) {
140 key->setSubnetId(SUBNET_ID_GLOBAL);
169 auto previous_interval = duration->getPreviousInterval();
170 if (!previous_interval) {
174 auto average = previous_interval->getAverageDuration();
177 static_cast<int64_t
>(average.total_milliseconds()));
187 std::string label = alarm->getLabel();
188 switch(alarm->getState()) {
191 .arg(alarm->getLabel())
193 .arg(alarm->getLowWater().total_milliseconds());
198 .arg(alarm->getLabel())
201 .arg(alarm->getHighWater().total_milliseconds());
202 alarm->setLastHighWaterReport();
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
A generic exception that is thrown when an unexpected error condition occurs.
To be removed. Please use ConfigError instead.
Houses the composite key that uniquely identifies a duration:
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.
Maintains an in-memory store of durations.
Houses the PerfMon configuration parameters for a single scope (e.g.
uint32_t interval_width_secs_
Number of seconds a duration accumulates samples until reporting.
uint32_t alarm_report_secs_
Number of seconds between reports of a raised alarm.
void setEnableMonitoring(bool value)
Sets the value of enable-monitoring.
uint16_t family_
Protocol family AF_INET or AF_INET6.
bool getStatsMgrReporting() const
Fetches the value of stats-mgr-reporting.
void parse(data::ConstElementPtr config)
Extracts member values from an Element::map.
bool enable_monitoring_
If true, performance data is processed/reported.
AlarmStorePtr alarm_store_
Stores the configured alarms.
void processPktEventStack(isc::dhcp::PktPtr query, isc::dhcp::PktPtr response, const isc::dhcp::SubnetPtr subnet)
Processes the event stack of a query packet.
void reportTimerExpired()
Handler invoked when the report timer expires.
Duration interval_duration_
Length of time a MonitoredDuration accumulates samples until reporting.
void setNextReportExpiration()
Updates the report timer.
void addDurationSample(DurationKeyPtr key, const Duration &sample)
Adds a duration sample to a MonitoredDuration.
PerfMonMgr(uint16_t family)
Constructor.
Duration reportToStatsMgr(MonitoredDurationPtr duration)
Emits an entry to StatsMgr for a given duration.
void configure(const isc::data::ConstElementPtr ¶ms)
Parses the hook library 'parameters' element.
MonitoredDurationStorePtr duration_store_
In-memory store of MonitoredDurations.
void reportAlarm(AlarmPtr alarm, const Duration &average)
Emits a report for a given alarm.
Duration alarm_report_interval_
Length of time between raised Alarm reports.
virtual void init()
Sets convenience values and (re)creates the duration store.
static StatsMgr & instance()
Statistics Manager accessor method.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
@ DHCP_NOTYPE
Message Type option missing.
const int DBGLVL_TRACE_DETAIL
Trace detailed operations.
boost::posix_time::time_duration Duration
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
boost::shared_ptr< MonitoredDuration > MonitoredDurationPtr
boost::shared_ptr< Alarm > AlarmPtr
Defines a pointer to an Alarm instance.
isc::log::Logger perfmon_logger("perfmon-hooks")
std::string ptimeToText(boost::posix_time::ptime t, size_t fsecs_precision=MAX_FSECS_PRECISION)
Converts ptime structure to text.
Defines the logger used by the top-level component of kea-lfc.
const isc::log::MessageID PERFMON_ALARM_CLEARED
const isc::log::MessageID PERFMON_ALARM_TRIGGERED
const isc::log::MessageID PERFMON_DHCP4_PKT_EVENTS
const isc::log::MessageID PERFMON_DHCP6_PKT_EVENTS