Kea: perfmon_mgr.h Source File

| Kea 3.0.3-git

perfmon_mgr.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// Functions accessed by the hooks framework use C linkage to avoid the name
8// mangling that accompanies use of the C++ compiler as well as to avoid
9// issues related to namespaces.
10
11#ifndef PERFMON_MGR_H
12#define PERFMON_MGR_H
13
14#include <perfmon_config.h>
15#include <config/command_mgr.h>
16#include <config/cmds_impl.h>
17#include <monitored_duration_store.h>
18#include <asiolink/io_service.h>
19#include <asiolink/interval_timer.h>
20#include <dhcpsrv/subnet.h>
21
22namespace isc {
23namespace perfmon {
24
29 class PerfMonMgr : public PerfMonConfig, private config::CmdsImpl {
30public:
34 explicit PerfMonMgr(uint16_t family);
35
37 virtual ~PerfMonMgr() = default;
38
42 void configure(const isc::data::ConstElementPtr& params);
43
47 virtual void init();
48
65 void processPktEventStack(isc::dhcp::PktPtr query,
66 isc::dhcp::PktPtr response,
67 const isc::dhcp::ConstSubnetPtr subnet);
68
81 void addDurationSample(DurationKeyPtr key, const Duration& sample);
82
91 Duration reportToStatsMgr(MonitoredDurationPtr duration);
92
101 void reportAlarm(AlarmPtr alarm, const Duration& mean);
102
107 void reportTimerExpired();
108
116 void setNextReportExpiration();
117
152 int perfmonControlHandler(hooks::CalloutHandle& handle);
153
233 int perfmonGetAllDurationsHandler(hooks::CalloutHandle& handle);
234
238 data::ElementPtr formatDurationDataAsElements(MonitoredDurationCollectionPtr durations) const;
239
261 data::ElementPtr formatDurationDataAsResultSet(MonitoredDurationCollectionPtr durations) const;
262
266 Duration getIntervalDuration() {
267 return (interval_duration_);
268 }
269
273 Duration getAlarmReportInterval() {
274 return (alarm_report_interval_);
275 }
276
280 MonitoredDurationStorePtr getDurationStore() {
281 return (duration_store_);
282 }
283
284protected:
286 Duration interval_duration_;
287
291 Duration alarm_report_interval_;
292
294 MonitoredDurationStorePtr duration_store_;
295
301 // dhcp::NetworkStatePtr network_state_;
302
304 asiolink::IOServicePtr io_service_;
305
307 asiolink::IntervalTimerPtr report_timer_;
308
310 const boost::scoped_ptr<std::mutex> mutex_;
311};
312
314 typedef boost::shared_ptr<PerfMonMgr> PerfMonMgrPtr;
315
316} // end of namespace perfmon
317} // end of namespace isc
318
319#endif
isc::config::CmdsImpl
Base class that command handler implementers may use for common tasks.
Definition cmds_impl.h:21
isc::hooks::CalloutHandle
Per-packet callout handle.
Definition callout_handle.h:78
isc::perfmon::PerfMonConfig::PerfMonConfig
PerfMonConfig(uint16_t family)
Constructor.
Definition perfmon_config.cc:267
isc::perfmon::PerfMonMgr::reportTimerExpired
void reportTimerExpired()
Handler invoked when the report timer expires.
Definition perfmon_mgr.cc:217
isc::perfmon::PerfMonMgr::interval_duration_
Duration interval_duration_
Length of time a MonitoredDuration accumulates samples until reporting.
Definition perfmon_mgr.h:286
isc::perfmon::PerfMonMgr::perfmonGetAllDurationsHandler
int perfmonGetAllDurationsHandler(hooks::CalloutHandle &handle)
perfmon-get-all-durations handler
Definition perfmon_mgr.cc:280
isc::perfmon::PerfMonMgr::mutex_
const boost::scoped_ptr< std::mutex > mutex_
The mutex used to protect internal state.
Definition perfmon_mgr.h:310
isc::perfmon::PerfMonMgr::setNextReportExpiration
void setNextReportExpiration()
Updates the report timer.
Definition perfmon_mgr.cc:222
isc::perfmon::PerfMonMgr::addDurationSample
void addDurationSample(DurationKeyPtr key, const Duration &sample)
Adds a duration sample to a MonitoredDuration.
Definition perfmon_mgr.cc:150
isc::perfmon::PerfMonMgr::~PerfMonMgr
virtual ~PerfMonMgr()=default
Destructor.
isc::perfmon::PerfMonMgr::formatDurationDataAsElements
data::ElementPtr formatDurationDataAsElements(MonitoredDurationCollectionPtr durations) const
Renders a list of MonitoredDurations as a map of individual Elements.
Definition perfmon_mgr.cc:337
isc::perfmon::PerfMonMgr::report_timer_
asiolink::IntervalTimerPtr report_timer_
Timer which tracks the next duration due to report.
Definition perfmon_mgr.h:307
isc::perfmon::PerfMonMgr::getIntervalDuration
Duration getIntervalDuration()
Get the interval duration.
Definition perfmon_mgr.h:266
isc::perfmon::PerfMonMgr::processPktEventStack
void processPktEventStack(isc::dhcp::PktPtr query, isc::dhcp::PktPtr response, const isc::dhcp::ConstSubnetPtr subnet)
Processes the event stack of a query packet.
Definition perfmon_mgr.cc:71
isc::perfmon::PerfMonMgr::perfmonControlHandler
int perfmonControlHandler(hooks::CalloutHandle &handle)
perfmon-control command handler
Definition perfmon_mgr.cc:227
isc::perfmon::PerfMonMgr::PerfMonMgr
PerfMonMgr(uint16_t family)
Constructor.
Definition perfmon_mgr.cc:31
isc::perfmon::PerfMonMgr::reportToStatsMgr
Duration reportToStatsMgr(MonitoredDurationPtr duration)
Emits an entry to StatsMgr for a given duration.
Definition perfmon_mgr.cc:168
isc::perfmon::PerfMonMgr::configure
void configure(const isc::data::ConstElementPtr &params)
Parses the hook library 'parameters' element.
Definition perfmon_mgr.cc:47
isc::perfmon::PerfMonMgr::duration_store_
MonitoredDurationStorePtr duration_store_
In-memory store of MonitoredDurations.
Definition perfmon_mgr.h:294
isc::perfmon::PerfMonMgr::io_service_
asiolink::IOServicePtr io_service_
Tracks whether or not the server is processing DHCP packets.
Definition perfmon_mgr.h:304
isc::perfmon::PerfMonMgr::formatDurationDataAsResultSet
data::ElementPtr formatDurationDataAsResultSet(MonitoredDurationCollectionPtr durations) const
Renders a list of MonitoredDurations as a result set.
Definition perfmon_mgr.cc:351
isc::perfmon::PerfMonMgr::alarm_report_interval_
Duration alarm_report_interval_
Length of time between raised Alarm reports.
Definition perfmon_mgr.h:291
isc::perfmon::PerfMonMgr::getAlarmReportInterval
Duration getAlarmReportInterval()
Get the alarm report interval.
Definition perfmon_mgr.h:273
isc::perfmon::PerfMonMgr::init
virtual void init()
Sets convenience values and (re)creates the duration store.
Definition perfmon_mgr.cc:37
isc::perfmon::PerfMonMgr::reportAlarm
void reportAlarm(AlarmPtr alarm, const Duration &mean)
Emits a report for a given alarm.
Definition perfmon_mgr.cc:190
isc::perfmon::PerfMonMgr::getDurationStore
MonitoredDurationStorePtr getDurationStore()
Get the duration store.
Definition perfmon_mgr.h:280
cmds_impl.h
command_mgr.h
interval_timer.h
io_service.h
monitored_duration_store.h
isc::asiolink::IntervalTimerPtr
boost::shared_ptr< isc::asiolink::IntervalTimer > IntervalTimerPtr
Definition interval_timer.h:138
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:998
isc::dhcp::ConstSubnetPtr
boost::shared_ptr< const Subnet > ConstSubnetPtr
A generic pointer to either const Subnet4 or const Subnet6 object.
Definition subnet.h:452
isc::perfmon
Definition alarm.cc:19
isc::perfmon::Duration
boost::posix_time::time_duration Duration
Definition monitored_duration.h:21
isc::perfmon::MonitoredDurationCollectionPtr
boost::shared_ptr< MonitoredDurationCollection > MonitoredDurationCollectionPtr
Type for a pointer to a collection of MonitoredDurationPtrs.
Definition monitored_duration_store.h:93
isc::perfmon::DurationKeyPtr
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
Definition monitored_duration.h:321
isc::perfmon::MonitoredDurationStorePtr
boost::shared_ptr< MonitoredDurationStore > MonitoredDurationStorePtr
Definition monitored_duration_store.h:217
isc::perfmon::MonitoredDurationPtr
boost::shared_ptr< MonitoredDuration > MonitoredDurationPtr
Definition monitored_duration.h:503
isc::perfmon::AlarmPtr
boost::shared_ptr< Alarm > AlarmPtr
Defines a pointer to an Alarm instance.
Definition alarm.h:168
isc::perfmon::PerfMonMgrPtr
boost::shared_ptr< PerfMonMgr > PerfMonMgrPtr
Defines a shared pointer to a PerfMonMgr.
Definition perfmon_mgr.h:314
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
perfmon_config.h
The classes herein parse PerfMon hook library's 'parameters' element depicted below:
subnet.h