Skip to content

Commit 5d86419

Browse files
tmarkwalderfxdupont
authored andcommitted
[#3328] Addressed review comments
Revampe UTs Replaced ave and average with mean throughout
1 parent da80461 commit 5d86419

13 files changed

+201
-170
lines changed

doc/sphinx/arm/hooks-perfmon.rst

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,29 @@ statistic employs the following naming convention:
170170
{subnet-id[x]}.perfmon.<query type>-<response type>.<start event>-<end event>.<value-name>
171171

172172
There is both a global and a subnet-specific value for each. Currently, the only
173-
value reported for a given duration key is ``averages-usecs``; this statistic is the average time
173+
value reported for a given duration key is ``mean-usecs``; this statistic is the mean time
174174
between the duration's event pair over the most recently completed interval. In other
175175
words, if during a given interval there were seven occurrences (i.e. updates) totaling
176-
3500us, the ``average-usecs`` reported would be 500us. Continuing with the example above, the
176+
3500us, the ``mean-usecs`` reported would be 500us. Continuing with the example above, the
177177
statistics reported are named as follows for the subnet-level values:
178178

179179
::
180180

181-
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.socket_received-buffer_read.average-usecs
182-
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read-mt_queue.average-usecs
183-
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued-process_started.average-usecs
184-
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.process_started-process_completed.average-usecs
185-
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.composite-total_response.average-usecs
181+
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.socket_received-buffer_read.mean-usecs
182+
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read-mt_queue.mean-usecs
183+
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued-process_started.mean-usecs
184+
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.process_started-process_completed.mean-usecs
185+
subnet[100].perfmon.DHCPDISCOVER.DHCPOFFER.composite-total_response.mean-usecs
186186

187187
and as shown for global values:
188188

189189
::
190190

191-
perfmon.DHCPDISCOVER.DHCPOFFER.socket_received-buffer_read.average-usecs
192-
perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read-mt_queue.average-usecs
193-
perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued-process_started.average-usecs
194-
perfmon.DHCPDISCOVER.DHCPOFFER.process_started-process_completed.average-usecs
195-
perfmon.DHCPDISCOVER.DHCPOFFER.composite-total_response.average-usecs
191+
perfmon.DHCPDISCOVER.DHCPOFFER.socket_received-buffer_read.mean-usecs
192+
perfmon.DHCPDISCOVER.DHCPOFFER.buffer_read-mt_queue.mean-usecs
193+
perfmon.DHCPDISCOVER.DHCPOFFER.mt_queued-process_started.mean-usecs
194+
perfmon.DHCPDISCOVER.DHCPOFFER.process_started-process_completed.mean-usecs
195+
perfmon.DHCPDISCOVER.DHCPOFFER.composite-total_response.mean-usecs
196196

197197
The results are reported to StatsMgr, an internal Kea component that reports data as statistics
198198
that can be retrieved using statistics commands. They can be fetched using the commands
@@ -202,25 +202,25 @@ Alarms
202202
~~~~~~
203203

204204
Alarms may be defined to watch specific durations. Each alarm defines a high-water mark,
205-
``high-water-ms``, and a low-water mark, ``low-water-ms``. If the reported average value
205+
``high-water-ms``, and a low-water mark, ``low-water-ms``. If the reported mean value
206206
for the duration exceeds the high-water mark a WARN level alarm log is emitted, at which
207207
point the alarm is considered "triggered." Once triggered, the WARN level log is
208208
repeated at the alarm report interval specified by ``alarm-report-secs``, as long as the reported
209-
average for the duration remains above the low-water mark. Once the average falls below the
209+
mean for the duration remains above the low-water mark. Once the mean falls below the
210210
low-water mark the alarm is cleared and an INFO level log is emitted.
211211

212212
The alarm-triggered WARN log looks similar to the following:
213213

214214
::
215215

216-
2024-03-20 10:22:14.030 WARN [kea-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_TRIGGERED Alarm for DHCPDISCOVER.DHCPOFFER.composite-total_response.0 has been triggered since 2024-03-20 10:18:20.070000, reported average duration 00:00:00.700000 exceeds high-water-ms: 500
216+
2024-03-20 10:22:14.030 WARN [kea-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_TRIGGERED Alarm for DHCPDISCOVER.DHCPOFFER.composite-total_response.0 has been triggered since 2024-03-20 10:18:20.070000, reported mean duration 00:00:00.700000 exceeds high-water-ms: 500
217217

218218

219219
The alarm-cleared INFO log looks like this:
220220

221221
::
222222

223-
2024-03-20 10:30:14.030 INFO [kea-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_CLEARED Alarm for DHCPDISCOVER.DHCPOFFER.composite-total_response.0 has been cleared, reported average duration 00:00:00.010000 is now below low-water-ms: 25
223+
2024-03-20 10:30:14.030 INFO [kea-dhcp6.leases/47195.139913679886272] PERFMON_ALARM_CLEARED Alarm for DHCPDISCOVER.DHCPOFFER.composite-total_response.0 has been cleared, reported mean duration 00:00:00.010000 is now below low-water-ms: 25
224224

225225
API Commands
226226
~~~~~~~~~~~~
@@ -301,7 +301,7 @@ of durations will be returned as a list of individual elements as shown below:
301301
"occurrences": 501,
302302
"start-time": "2024-06-12 17:52:06.814884",
303303
"total-duration-usecs": 23951,
304-
"ave-duration-usecs": 47
304+
"mean-duration-usecs": 47
305305
},
306306
...
307307
],
@@ -328,10 +328,11 @@ a format similar to an SQL result set as follows:
328328
"end-event",
329329
"subnet-id",
330330
"interval-start",
331-
"occurences",
331+
"occurrence",
332332
"min-duration-usecs",
333333
"max-duration-usecs",
334-
"total-duration-usecsave-duration-usecs"
334+
"total-duration-usecs",
335+
"mean-duration-usecs"
335336
],
336337
"rows": [ [
337338
"DHCPDISCOVER",

src/hooks/dhcp/perfmon/alarm.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class Alarm : public DurationKey {
3434
/// @param start_event_label label of the start event
3535
/// @param stop_event_label label of the end event
3636
/// @param subnet_id SubnetID of the selected subnet
37-
/// @param low_water threshold below which the average duration must fall to clear the alarm
38-
/// @param high_water threshold above which the average duration must rise to trigger the alarm
37+
/// @param low_water threshold below which the mean duration must fall to clear the alarm
38+
/// @param high_water threshold above which the mean duration must rise to trigger the alarm
3939
/// @param enabled true sets state to CLEAR, otherwise DISABLED, defaults to true
4040
Alarm(uint16_t family, uint8_t query_type, uint8_t response_type,
4141
const std::string& start_event_label, const std::string& stop_event_label,
@@ -45,8 +45,8 @@ class Alarm : public DurationKey {
4545
/// @brief Constructor
4646
///
4747
/// @param key composite key that identifies the alarm
48-
/// @param low_water threshold below which the average duration must fall to clear the alarm
49-
/// @param high_water threshold above which the average duration must rise to trigger the alarm
48+
/// @param low_water threshold below which the mean duration must fall to clear the alarm
49+
/// @param high_water threshold above which the mean duration must rise to trigger the alarm
5050
/// @param enabled true sets state to CLEAR, otherwise DISABLED, defaults to true
5151
Alarm(const DurationKey& key, const Duration& low_water, const Duration& high_water, bool enabled = true);
5252

@@ -148,10 +148,10 @@ class Alarm : public DurationKey {
148148
bool checkSample(const Duration& sample, const Duration& report_interval);
149149

150150
private:
151-
/// @brief Threshold below which the average duration must fall to clear the alarm.
151+
/// @brief Threshold below which the mean duration must fall to clear the alarm.
152152
Duration low_water_;
153153

154-
/// @brief Threshold above which the average duration must rise to trigger the alarm.
154+
/// @brief Threshold above which the mean duration must rise to trigger the alarm.
155155
Duration high_water_;
156156

157157
/// @brief Current alarm state.

src/hooks/dhcp/perfmon/alarm_store.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class AlarmStore {
105105
/// @brief Creates a new alarm and adds it to the store
106106
///
107107
/// @param key key value of the alarm to create.
108-
/// @param low_water threshold below which the average duration must fall to clear the alarm
109-
/// @param high_water threshold above which the average duration must rise to trigger the alarm.
108+
/// @param low_water threshold below which the mean duration must fall to clear the alarm
109+
/// @param high_water threshold above which the mean duration must rise to trigger the alarm.
110110
/// @param enabled true sets state to CLEAR, otherwise DISABLED, defaults to true.
111111
///
112112
/// @return pointer to the newly created alarm.

src/hooks/dhcp/perfmon/monitored_duration.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ DurationDataInterval::addDuration(const Duration& duration) {
4444
}
4545

4646
Duration
47-
DurationDataInterval::getAverageDuration() const {
47+
DurationDataInterval::getMeanDuration() const {
4848
if (!occurrences_) {
4949
return (ZERO_DURATION());
5050
}
@@ -333,14 +333,14 @@ MonitoredDuration::toElement() const {
333333
element->set("min-duration-usecs", Element::create(previous_interval_->getMinDuration().total_microseconds()));
334334
element->set("max-duration-usecs", Element::create(previous_interval_->getMaxDuration().total_microseconds()));
335335
element->set("total-duration-usecs", Element::create(previous_interval_->getTotalDuration().total_microseconds()));
336-
element->set("ave-duration-usecs", Element::create(previous_interval_->getAverageDuration().total_microseconds()));
336+
element->set("mean-duration-usecs", Element::create(previous_interval_->getMeanDuration().total_microseconds()));
337337
} else {
338338
element->set("start-time", Element::create("<none>"));
339339
element->set("occurrences", Element::create(0));
340340
element->set("min-duration-usecs", Element::create(0));
341341
element->set("max-duration-usecs", Element::create(0));
342342
element->set("total-duration-usecs", Element::create(0));
343-
element->set("ave-duration-usecs", Element::create(0));
343+
element->set("mean-duration-usecs", Element::create(0));
344344
}
345345

346346
return (element);
@@ -359,7 +359,7 @@ MonitoredDuration::valueRowColumns() {
359359
"min-duration-usecs",
360360
"max-duration-usecs",
361361
"total-duration-usecs"
362-
"ave-duration-usecs"
362+
"mean-duration-usecs"
363363
};
364364

365365
static ElementPtr cols;
@@ -393,7 +393,7 @@ MonitoredDuration::toValueRow() const {
393393
row->add(Element::create(previous_interval_->getMinDuration().total_microseconds()));
394394
row->add(Element::create(previous_interval_->getMaxDuration().total_microseconds()));
395395
row->add(Element::create(previous_interval_->getTotalDuration().total_microseconds()));
396-
row->add(Element::create(previous_interval_->getAverageDuration().total_microseconds()));
396+
row->add(Element::create(previous_interval_->getMeanDuration().total_microseconds()));
397397
} else {
398398
row->add(Element::create("<none>"));
399399
row->add(Element::create(0));

src/hooks/dhcp/perfmon/monitored_duration.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define _MONITORED_DURATION_H
99

1010
#include <cc/data.h>
11+
#include <cc/cfg_to_element.h>
1112
#include <dhcp/pkt.h>
1213
#include <dhcpsrv/subnet_id.h>
1314

@@ -90,10 +91,10 @@ class DurationDataInterval {
9091
return (total_duration_);
9192
}
9293

93-
/// @brief Get the average duration for the interval.
94+
/// @brief Get the mean duration for the interval.
9495
///
95-
/// @return Duration containing the average.
96-
Duration getAverageDuration() const;
96+
/// @return Duration containing the mean.
97+
Duration getMeanDuration() const;
9798

9899
/// @brief Equality operator.
99100
///
@@ -130,7 +131,7 @@ typedef boost::shared_ptr<DurationDataInterval> DurationDataIntervalPtr;
130131
/// -# Start Event
131132
/// -# Stop Event
132133
/// -# Subnet ID can be GLOBAL_SUBNET_ID for aggregate durations
133-
class DurationKey {
134+
class DurationKey : public data::CfgToElement {
134135
public:
135136
/// @brief Constructor
136137
///
@@ -227,7 +228,7 @@ class DurationKey {
227228

228229
/// @brief Get the StatsMgr formatted compatible name.
229230
///
230-
/// @param value_name name of the specific value (e.g. "average-usecs", "min-duration-usecs").
231+
/// @param value_name name of the specific value (e.g. "mean-usecs", "min-duration-usecs").
231232
/// The format of the string:
232233
///
233234
/// @code
@@ -236,9 +237,9 @@ class DurationKey {
236237
///
237238
/// Examples:
238239
///
239-
/// perfmon.discover-offer.socket_received-buffer_read.average-usecs
240+
/// perfmon.discover-offer.socket_received-buffer_read.mean-usecs
240241
///
241-
/// subnet[9].perfmon.discover-offer.socket_received-buffer_read.average-usecs
242+
/// subnet[9].perfmon.discover-offer.socket_received-buffer_read.mean-usecs
242243
///
243244
/// @endcode
244245
///
@@ -415,8 +416,8 @@ class MonitoredDuration : public DurationKey {
415416
/// "min-duration-usecs": 5300,
416417
/// "max-duration-usecs": 9000,
417418
/// "total-duration-usecs": 786500,
418-
/// "ave-duration-usecs": 7490
419-
/// }
419+
/// "mean-duration-usecs": 7490
420+
/// }
420421
/// @endcode
421422
///
422423
/// If there is no previous interval, it will appears as follows:
@@ -435,8 +436,8 @@ class MonitoredDuration : public DurationKey {
435436
/// "min-duration-usecs": 0,
436437
/// "max-duration-usecs": 0,
437438
/// "total-duration-usecs": 0,
438-
/// "ave-duration-usecs": 0
439-
/// }
439+
/// "mean-duration-usecs": 0
440+
/// }
440441
/// @endcode
441442
///
442443
/// @return Element::map containing the duration key values.
@@ -459,7 +460,7 @@ class MonitoredDuration : public DurationKey {
459460
/// -# "min-duration-usecs"
460461
/// -# "max-duration-usecs"
461462
/// -# "total-duration-usecs"
462-
/// -# "ave-duration-usecs"
463+
/// -# "mean-duration-usecs"
463464
///
464465
/// @return Element::map containing the duration key values.
465466
static data::ConstElementPtr valueRowColumns();
@@ -483,7 +484,7 @@ class MonitoredDuration : public DurationKey {
483484
/// -# min-duration-usecs Element::int
484485
/// -# max-duration-usecs Element::int
485486
/// -# total-duration-usecs Element::int
486-
/// -# ave-duration-usecs Element::int
487+
/// -# mean-duration-usecs Element::int
487488
///
488489
/// @return Element::map containing the duration key values.
489490
data::ElementPtr toValueRow() const;

src/hooks/dhcp/perfmon/perfmon_messages.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ extern const isc::log::MessageID PERFMON_INIT_OK = "PERFMON_INIT_OK";
2424
namespace {
2525

2626
const char* values[] = {
27-
"PERFMON_ALARM_CLEARED", "Alarm for %1 has been cleared, reported average duration %2 is now below low-water-ms: %3",
28-
"PERFMON_ALARM_TRIGGERED", "Alarm for %1 has been triggered since %2, reported average duration %3 exceeds high-water-ms: %4",
27+
"PERFMON_ALARM_CLEARED", "Alarm for %1 has been cleared, reported mean duration %2 is now below low-water-ms: %3",
28+
"PERFMON_ALARM_TRIGGERED", "Alarm for %1 has been triggered since %2, reported mean duration %3 exceeds high-water-ms: %4",
2929
"PERFMON_CMDS_CONTROL_ERROR", "perfmon-control command processing failed: %1",
3030
"PERFMON_CMDS_CONTROL_OK", "perfmon-control command success: active monitoring: %1, stats-mgr-reporting: %2",
3131
"PERFMON_CMDS_GET_ALL_DURATIONS_ERROR", "perfmon-get-all-durations command processing failed: %1",

src/hooks/dhcp/perfmon/perfmon_messages.mes

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
22

3-
% PERFMON_ALARM_CLEARED Alarm for %1 has been cleared, reported average duration %2 is now below low-water-ms: %3
4-
This info message is emitted when the reported average duration for
3+
% PERFMON_ALARM_CLEARED Alarm for %1 has been cleared, reported mean duration %2 is now below low-water-ms: %3
4+
This info message is emitted when the reported mean duration for
55
an alarm that has been triggered has fallen below the value of its
66
low-water-ms parameter. The arguments detail the alarm's key and
7-
the most recently reported average.
7+
the most recently reported mean.
88

9-
% PERFMON_ALARM_TRIGGERED Alarm for %1 has been triggered since %2, reported average duration %3 exceeds high-water-ms: %4
10-
This warning message is emitted when the reported average duration for
9+
% PERFMON_ALARM_TRIGGERED Alarm for %1 has been triggered since %2, reported mean duration %3 exceeds high-water-ms: %4
10+
This warning message is emitted when the reported mean duration for
1111
an alarm exceeds its high-water-ms value. As long as the reported
1212
averges remain above the low-water-ms value, the alarm will remain
1313
triggered and this message will be repeated every alarm-report-secs.
1414
Arguments detail the alarm's key, the time the alarm was first
15-
triggered, the most recent reported average, and the high-water-ms
15+
triggered, the most recent reported mean, and the high-water-ms
1616
value.
1717

1818
% PERFMON_DEINIT_FAILED unloading PerfMon hooks library failed: %1

0 commit comments

Comments
 (0)