17using namespace boost::posix_time;
34 static std::map<std::string, uint16_t> name_type_map = {
56 const auto& found = name_type_map.at(name);
58 }
catch (
const std::out_of_range& ex) {
65 static std::map<std::string, uint16_t> name_type_map = {
106 const auto& found = name_type_map.at(name);
108 }
catch (
const std::out_of_range& ex) {
116 const std::string& param_name,
119 uint16_t msg_type = 0;
125 }
catch (
const std::exception& ex) {
145 auto response_type =
getMessageType(config, family,
"response-type");
147 std::string start_event;
150 start_event = elem->stringValue();
155 std::string stop_event;
156 elem = config->get(
"stop-event");
158 stop_event = elem->stringValue();
163 SubnetID subnet_id = SUBNET_ID_GLOBAL;
164 elem = config->get(
"subnet-id");
166 subnet_id =
static_cast<SubnetID>(elem->intValue());
170 start_event, stop_event, subnet_id)));
180 if (key->getFamily() == AF_INET) {
190 map->set(
"subnet-id",
Element::create(
static_cast<long long>(key->getSubnetId())));
217 elem = config->get(
"enable-alarm");
218 bool enable_alarm = (elem ? elem->boolValue() :
true);
220 elem = config->get(
"high-water-ms");
221 uint64_t high_water_ms = 0;
223 int64_t value = elem->intValue();
226 << value <<
"', must be greater than 0");
229 high_water_ms = value;
234 elem = config->get(
"low-water-ms");
235 uint64_t low_water_ms = 0;
237 int64_t value = elem->intValue();
240 << value <<
"', must be greater than 0");
243 low_water_ms = value;
248 if (low_water_ms >= high_water_ms) {
250 <<
", must be less than 'high-water-ms': " << high_water_ms);
254 milliseconds(high_water_ms), enable_alarm)));
269 enable_monitoring_(false),
270 interval_width_secs_(60),
271 stats_mgr_reporting_(true),
272 alarm_report_secs_(300) {
295 elem = config->get(
"interval-width-secs");
297 int64_t value = elem->intValue();
300 << value <<
"', must be greater than 0");
306 elem = config->get(
"stats-mgr-reporting");
311 elem = config->get(
"alarm-report-secs");
313 int64_t value = elem->intValue();
316 << value <<
"', cannot be less than 0");
322 elem = config->get(
"alarms");
339 for (
auto const& alarm_elem : config->listValue()) {
343 }
catch (
const std::exception& ex) {
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.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
To be removed. Please use ConfigError instead.
const char * getName() const
Returns name of the DHCP message.
const char * getName() const
Returns name of the DHCPv6 message.
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
static AlarmPtr parse(data::ConstElementPtr config, uint16_t family)
Maintains an in-memory store of alarms.
Defines an alarm for a duration.
static uint16_t getMessageType(data::ConstElementPtr config, uint16_t family, const std::string ¶m_name, bool required=true)
Convert a configuration parameter to family-specific message type.
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
static data::ElementPtr toElement(DurationKeyPtr key)
Convert a DurationKey into a map of Elements.
static uint16_t getMessageNameType6(const std::string &name)
Convert string message name to DHCP6 message type.
static DurationKeyPtr parse(data::ConstElementPtr config, uint16_t family)
Convert a map of Elements into a DurationKey.
static uint16_t getMessageNameType4(const std::string &name)
Convert string message name to DHCP message type.
Houses the composite key that uniquely identifies a duration:
Houses the PerfMon configuration parameters for a single scope (e.g.
PerfMonConfig(uint16_t family)
Constructor.
uint32_t interval_width_secs_
Number of seconds a duration accumulates samples until reporting.
void setIntervalWidthSecs(uint32_t value)
Sets the value of interval-width-secs.
uint32_t alarm_report_secs_
Number of seconds between reports of a raised alarm.
bool getEnableMonitoring() const
Fetches the value of enable-monitoring.
void setEnableMonitoring(bool value)
Sets the value of enable-monitoring.
void parseAlarms(data::ConstElementPtr config)
Re-creates the AlarmStore and populates it by parsing a list of alarm elements.
void setStatsMgrReporting(bool value)
Sets the value of stats-mgr-reporting.
AlarmStorePtr getAlarmStore()
Get the alarm store.
uint16_t family_
Protocol family AF_INET or AF_INET6.
bool getStatsMgrReporting() const
Fetches the value of stats-mgr-reporting.
uint16_t getFamily()
Get protocol family.
void parse(data::ConstElementPtr config)
Extracts member values from an Element::map.
AlarmStorePtr alarm_store_
Stores the configured alarms.
std::atomic< bool > stats_mgr_reporting_
If true durations report to StatsMgr at the end of each interval.
uint32_t getAlarmReportSecs() const
Fetches the value of alarm-report-secs.
uint32_t getIntervalWidthSecs() const
Fetches the value of interval-width-secs.
void setAlarmReportSecs(uint32_t value)
Sets the value of alarm-report-secs.
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
std::atomic< bool > enable_monitoring_
If true, performance data is processed/reported.
@ DHCPV6_RECONFIGURE_REPLY
@ DHCPV6_ACTIVELEASEQUERY
@ DHCPV6_INFORMATION_REQUEST
@ DHCPV6_RECONFIGURE_REQUEST
@ DHCPV6_LEASEQUERY_REPLY
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
@ DHCP_NOTYPE
Message Type option missing.
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
boost::shared_ptr< Alarm > AlarmPtr
Defines a pointer to an Alarm instance.
Defines the logger used by the top-level component of kea-lfc.
The classes herein parse PerfMon hook library's 'parameters' element depicted below: