| Kea 3.0.2-git

perfmon_config.h
Go to the documentation of this file.
1// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef PERFMON_CONFIG_H
8#define PERFMON_CONFIG_H
9
10#include <cc/data.h>
11#include <cc/simple_parser.h>
12#include <alarm_store.h>
13#include <monitored_duration.h>
14
15#include <atomic>
16
17 namespace isc {
18 namespace perfmon {
19
49
57 class DurationKeyParser {
58 public:
60 static const data::SimpleKeywords CONFIG_KEYWORDS;
61
63 explicit DurationKeyParser() = default;
64
66 ~DurationKeyParser() = default;
67
79 static uint16_t getMessageType(data::ConstElementPtr config,
80 uint16_t family,
81 const std::string& param_name,
82 bool required = true);
83
90 static uint16_t getMessageNameType4(const std::string& name);
91
98 static uint16_t getMessageNameType6(const std::string& name);
99
104 static DurationKeyPtr parse(data::ConstElementPtr config, uint16_t family);
105
111 static data::ElementPtr toElement(DurationKeyPtr key);
112};
113
115 class AlarmParser {
116 public:
118 static const data::SimpleKeywords CONFIG_KEYWORDS;
119
121 explicit AlarmParser();
122
124 ~AlarmParser() = default;
125
130 static AlarmPtr parse(data::ConstElementPtr config, uint16_t family);
131};
132
135 class PerfMonConfig {
136 public:
138 static const data::SimpleKeywords CONFIG_KEYWORDS;
139
141 static const data::SimpleDefaults SIMPLE_DEFAULTS;
142
144 explicit PerfMonConfig(uint16_t family);
145
147 virtual ~PerfMonConfig() = default;
148
154 void parse(data::ConstElementPtr config);
155
163 void parseAlarms(data::ConstElementPtr config);
164
168 bool getEnableMonitoring() const {
169 return (enable_monitoring_);
170 }
171
175 void setEnableMonitoring(bool value) {
176 enable_monitoring_ = value;
177 }
178
182 uint32_t getIntervalWidthSecs() const {
183 return (interval_width_secs_);
184 }
185
189 void setIntervalWidthSecs(uint32_t value) {
190 interval_width_secs_ = value;
191 }
192
196 bool getStatsMgrReporting() const {
197 return (stats_mgr_reporting_);
198 };
199
203 void setStatsMgrReporting(bool value) {
204 stats_mgr_reporting_ = value;
205 }
206
210 uint32_t getAlarmReportSecs() const {
211 return (alarm_report_secs_);
212 }
213
217 void setAlarmReportSecs(uint32_t value) {
218 alarm_report_secs_ = value;
219 }
220
224 uint16_t getFamily() {
225 return (family_);
226 }
227
231 AlarmStorePtr getAlarmStore() {
232 return (alarm_store_);
233 }
234
235 protected:
237 uint16_t family_;
238
243 std::atomic<bool> enable_monitoring_;
244
247 uint32_t interval_width_secs_;
248
251 std::atomic<bool> stats_mgr_reporting_;
252
255 uint32_t alarm_report_secs_;
256
258 AlarmStorePtr alarm_store_;
259};
260
262 typedef boost::shared_ptr<PerfMonConfig> PerfMonConfigPtr;
263
264} // end of namespace perfmon
265} // end of namespace isc
266
267#endif
alarm_store.h
isc::perfmon::AlarmParser::CONFIG_KEYWORDS
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
Definition perfmon_config.h:118
isc::perfmon::AlarmParser::~AlarmParser
~AlarmParser()=default
Destructor.
isc::perfmon::AlarmParser::AlarmParser
AlarmParser()
Constructor.
isc::perfmon::AlarmParser::parse
static AlarmPtr parse(data::ConstElementPtr config, uint16_t family)
Definition perfmon_config.cc:204
isc::perfmon::DurationKeyParser::getMessageType
static uint16_t getMessageType(data::ConstElementPtr config, uint16_t family, const std::string &param_name, bool required=true)
Convert a configuration parameter to family-specific message type.
Definition perfmon_config.cc:114
isc::perfmon::DurationKeyParser::~DurationKeyParser
~DurationKeyParser()=default
Destructor.
isc::perfmon::DurationKeyParser::DurationKeyParser
DurationKeyParser()=default
Constructor.
isc::perfmon::DurationKeyParser::CONFIG_KEYWORDS
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
Definition perfmon_config.h:60
isc::perfmon::DurationKeyParser::toElement
static data::ElementPtr toElement(DurationKeyPtr key)
Convert a DurationKey into a map of Elements.
Definition perfmon_config.cc:174
isc::perfmon::DurationKeyParser::getMessageNameType6
static uint16_t getMessageNameType6(const std::string &name)
Convert string message name to DHCP6 message type.
Definition perfmon_config.cc:64
isc::perfmon::DurationKeyParser::parse
static DurationKeyPtr parse(data::ConstElementPtr config, uint16_t family)
Convert a map of Elements into a DurationKey.
Definition perfmon_config.cc:138
isc::perfmon::DurationKeyParser::getMessageNameType4
static uint16_t getMessageNameType4(const std::string &name)
Convert string message name to DHCP message type.
Definition perfmon_config.cc:33
isc::perfmon::PerfMonConfig::PerfMonConfig
PerfMonConfig(uint16_t family)
Constructor.
Definition perfmon_config.cc:267
isc::perfmon::PerfMonConfig::interval_width_secs_
uint32_t interval_width_secs_
Number of seconds a duration accumulates samples until reporting.
Definition perfmon_config.h:247
isc::perfmon::PerfMonConfig::~PerfMonConfig
virtual ~PerfMonConfig()=default
Destructor.
isc::perfmon::PerfMonConfig::setIntervalWidthSecs
void setIntervalWidthSecs(uint32_t value)
Sets the value of interval-width-secs.
Definition perfmon_config.h:189
isc::perfmon::PerfMonConfig::alarm_report_secs_
uint32_t alarm_report_secs_
Number of seconds between reports of a raised alarm.
Definition perfmon_config.h:255
isc::perfmon::PerfMonConfig::getEnableMonitoring
bool getEnableMonitoring() const
Fetches the value of enable-monitoring.
Definition perfmon_config.h:168
isc::perfmon::PerfMonConfig::setEnableMonitoring
void setEnableMonitoring(bool value)
Sets the value of enable-monitoring.
Definition perfmon_config.h:175
isc::perfmon::PerfMonConfig::parseAlarms
void parseAlarms(data::ConstElementPtr config)
Re-creates the AlarmStore and populates it by parsing a list of alarm elements.
Definition perfmon_config.cc:337
isc::perfmon::PerfMonConfig::setStatsMgrReporting
void setStatsMgrReporting(bool value)
Sets the value of stats-mgr-reporting.
Definition perfmon_config.h:203
isc::perfmon::PerfMonConfig::getAlarmStore
AlarmStorePtr getAlarmStore()
Get the alarm store.
Definition perfmon_config.h:231
isc::perfmon::PerfMonConfig::family_
uint16_t family_
Protocol family AF_INET or AF_INET6.
Definition perfmon_config.h:237
isc::perfmon::PerfMonConfig::getStatsMgrReporting
bool getStatsMgrReporting() const
Fetches the value of stats-mgr-reporting.
Definition perfmon_config.h:196
isc::perfmon::PerfMonConfig::getFamily
uint16_t getFamily()
Get protocol family.
Definition perfmon_config.h:224
isc::perfmon::PerfMonConfig::parse
void parse(data::ConstElementPtr config)
Extracts member values from an Element::map.
Definition perfmon_config.cc:281
isc::perfmon::PerfMonConfig::SIMPLE_DEFAULTS
static const data::SimpleDefaults SIMPLE_DEFAULTS
List of valid parameter defaults.
Definition perfmon_config.h:141
isc::perfmon::PerfMonConfig::alarm_store_
AlarmStorePtr alarm_store_
Stores the configured alarms.
Definition perfmon_config.h:258
isc::perfmon::PerfMonConfig::stats_mgr_reporting_
std::atomic< bool > stats_mgr_reporting_
If true durations report to StatsMgr at the end of each interval.
Definition perfmon_config.h:251
isc::perfmon::PerfMonConfig::getAlarmReportSecs
uint32_t getAlarmReportSecs() const
Fetches the value of alarm-report-secs.
Definition perfmon_config.h:210
isc::perfmon::PerfMonConfig::getIntervalWidthSecs
uint32_t getIntervalWidthSecs() const
Fetches the value of interval-width-secs.
Definition perfmon_config.h:182
isc::perfmon::PerfMonConfig::setAlarmReportSecs
void setAlarmReportSecs(uint32_t value)
Sets the value of alarm-report-secs.
Definition perfmon_config.h:217
isc::perfmon::PerfMonConfig::CONFIG_KEYWORDS
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid parameters and expected types.
Definition perfmon_config.h:138
isc::perfmon::PerfMonConfig::enable_monitoring_
std::atomic< bool > enable_monitoring_
If true, performance data is processed/reported.
Definition perfmon_config.h:243
data.h
simple_parser.h
monitored_duration.h
isc::config
Definition command_interpreter.cc:23
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::data::SimpleDefaults
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
Definition lib/cc/simple_parser.h:39
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::data::SimpleKeywords
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
Definition lib/cc/simple_parser.h:36
isc::perfmon
Definition alarm.cc:19
isc::perfmon::DurationKeyPtr
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
Definition monitored_duration.h:321
isc::perfmon::AlarmStorePtr
boost::shared_ptr< AlarmStore > AlarmStorePtr
Definition alarm_store.h:181
isc::perfmon::PerfMonConfigPtr
boost::shared_ptr< PerfMonConfig > PerfMonConfigPtr
Defines a shared pointer to a PerfMonConfig.
Definition perfmon_config.h:262
isc::perfmon::AlarmPtr
boost::shared_ptr< Alarm > AlarmPtr
Defines a pointer to an Alarm instance.
Definition alarm.h:168
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148