Kea  1.9.9-git
stat_cmds.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-2021 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 #include <config.h>
8 #include <config/command_mgr.h>
9 #include <config/cmds_impl.h>
10 #include <cc/command_interpreter.h>
11 #include <cc/data.h>
12 #include <dhcpsrv/cfgmgr.h>
13 #include <dhcpsrv/lease_mgr.h>
15 #include <dhcpsrv/subnet_id.h>
16 #include <hooks/hooks.h>
17 #include <exceptions/exceptions.h>
18 #include <stat_cmds.h>
19 #include <stat_cmds_log.h>
20 #include <stats/stats_mgr.h>
21 #include <util/boost_time_utils.h>
23 
24 #include <boost/date_time/posix_time/posix_time.hpp>
25 #include <string>
26 
27 using namespace isc::dhcp;
28 using namespace isc::data;
29 using namespace isc::config;
30 using namespace isc::asiolink;
31 using namespace isc::hooks;
32 using namespace isc::stats;
33 using namespace isc::util;
34 using namespace std;
35 
36 namespace isc {
37 namespace stat_cmds {
38 
42 class NotFound: public isc::Exception {
43 public:
44  NotFound (const char* file, size_t line, const char* what) :
45  isc::Exception(file, line, what) { };
46 };
47 
49 class LeaseStatCmdsImpl : private CmdsImpl {
50 public:
51 
53  class Parameters {
54  public:
58 
61 
65 
67  std::string toText() {
68  std::stringstream os;
69  switch (select_mode_) {
71  os << "[all subnets]";
72  break;
74  os << "[subnet-id=" << first_subnet_id_ << "]";
75  break;
77  os << "[subnets " << first_subnet_id_
78  << " through " << last_subnet_id_ << "]";
79  break;
80  }
81 
82  return (os.str());
83  }
84  };
85 
86 public:
87 
99  int
100  statLease4GetHandler(CalloutHandle& handle);
101 
113  int
114  statLease6GetHandler(CalloutHandle& handle);
115 
125  Parameters getParameters(const ConstElementPtr& cmd_args);
126 
144  uint64_t makeResultSet4(const ElementPtr& result, const Parameters& params);
145 
162  uint64_t makeResultSet6(const ElementPtr& result, const Parameters& params);
163 
183  ElementPtr createResultSet(const ElementPtr& wrapper,
184  const std::vector<std::string>& column_labels);
185 
193  void addValueRow4(ElementPtr value_rows, const SubnetID &subnet_id,
194  int64_t assigned, int64_t declined);
195 
204  void addValueRow6(ElementPtr value_rows, const SubnetID &subnet_id,
205  int64_t assigned, int64_t declined, int64_t assigned_pds);
206 
213  int64_t getSubnetStat(const SubnetID& subnet_id, const std::string& name);
214 };
215 
216 int
217 LeaseStatCmdsImpl::statLease4GetHandler(CalloutHandle& handle) {
218  ElementPtr result = Element::createMap();
219  Parameters params;
220  ConstElementPtr response;
221 
222  // Extract the command and then the parameters
223  try {
224  extractCommand(handle);
225  params = getParameters(cmd_args_);
226  } catch (const std::exception& ex) {
228  .arg(ex.what());
229  setErrorResponse(handle, ex.what());
230  return (1);
231  }
232 
233  try {
234  // Now build the result set
235  uint64_t rows = makeResultSet4(result, params);
237  .arg(params.toText())
238  .arg(rows);
239  std::stringstream os;
240  os << "stat-lease4-get" << params.toText() << ": " << rows << " rows found";
241  response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
242  } catch (const NotFound& ex) {
243  // Criteria was valid but included no known subnets,
244  // so we return a not found response.
246  .arg(params.toText())
247  .arg(ex.what());
248  std::stringstream os;
249  os << "stat-lease4-get" << params.toText() << ": no matching data, " << ex.what();
250  response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
251  } catch (const std::exception& ex) {
253  .arg(params.toText())
254  .arg(ex.what());
255  setErrorResponse(handle, ex.what());
256  return (1);
257  }
258 
259  setResponse(handle, response);
260  return (0);
261 }
262 
263 int
264 LeaseStatCmdsImpl::statLease6GetHandler(CalloutHandle& handle) {
265  ElementPtr result = Element::createMap();
266  Parameters params;
267  ConstElementPtr response;
268 
269  // Extract the command and then the parameters
270  try {
271  extractCommand(handle);
272  params = getParameters(cmd_args_);
273  } catch (const std::exception& ex) {
275  .arg(ex.what());
276  setErrorResponse(handle, ex.what());
277  return (1);
278  }
279 
280  try {
281  // Now build the result set
282  uint64_t rows = makeResultSet6(result, params);
284  .arg(params.toText())
285  .arg(rows);
286  std::stringstream os;
287  os << "stat-lease6-get" << params.toText() << ": " << rows << " rows found";
288  response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
289  } catch (const NotFound& ex) {
290  // Criteria was valid but included no known subnets,
291  // so we return a not found response.
293  .arg(params.toText())
294  .arg(ex.what());
295  std::stringstream os;
296  os << "stat-lease6-get" << params.toText() << ": no matching data, " << ex.what();
297  response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
298  } catch (const std::exception& ex) {
300  .arg(params.toText())
301  .arg(ex.what());
302  setErrorResponse(handle, ex.what());
303  return (1);
304  }
305 
306  setResponse(handle, response);
307  return (0);
308 }
309 
311 LeaseStatCmdsImpl::getParameters(const ConstElementPtr& cmd_args) {
312  Parameters params;
313 
315  params.first_subnet_id_ = 0;
316  params.last_subnet_id_ = 0;
317  if (!cmd_args ) {
318  // No arguments defaults to ALL_SUBNETS.
319  return (params);
320  }
321 
322  if (cmd_args->getType() != Element::map) {
323  isc_throw(BadValue, "'arguments' parameter is not a map");
324  }
325 
327  if (cmd_args->contains("subnet-id")) {
328 
329  ConstElementPtr value = cmd_args->get("subnet-id");
330  if (value->getType() != Element::integer) {
331  isc_throw(BadValue, "'subnet-id' parameter is not integer");
332  }
333 
334  if (value->intValue() <= 0) {
335  isc_throw(BadValue, "'subnet-id' parameter must be > 0");
336  }
337 
338  params.first_subnet_id_ = value->intValue();
340  }
341 
342  if (cmd_args->contains("subnet-range")) {
344  isc_throw(BadValue, "cannot specify both subnet-id and subnet-range");
345  }
346 
347  ConstElementPtr range = cmd_args->get("subnet-range");
348  if (range->getType() != Element::map) {
349  isc_throw(BadValue, "subnet-range parameter is not a map");
350  }
351 
352  ConstElementPtr value = range->get("first-subnet-id");
353  if (!value || value->getType() != Element::integer) {
354  isc_throw(BadValue, "'first-subnet-id' parameter missing or not an integer");
355  }
356 
357  if (value->intValue() <= 0) {
358  isc_throw(BadValue, "'first-subnet-id' parameter must be > 0");
359  }
360 
361  params.first_subnet_id_ = value->intValue();
362 
363  value = range->get("last-subnet-id");
364  if (!value || value->getType() != Element::integer) {
365  isc_throw(BadValue, "'last-subnet-id' parameter missing or not an integer");
366  }
367 
368  if (value->intValue() <= 0) {
369  isc_throw(BadValue, "'last-subnet-id' parameter must be > 0");
370  }
371 
372  params.last_subnet_id_ = value->intValue();
373 
374  if (params.last_subnet_id_ < params.first_subnet_id_) {
375  isc_throw(BadValue, "'last-subnet-id' must be greater than 'first-subnet-id'");
376  }
377 
379  }
380 
381  return (params);
382 }
383 
384 uint64_t
385 LeaseStatCmdsImpl::makeResultSet4(const ElementPtr& result_wrapper,
386  const Parameters& params) {
387  // First we need to determine the range of configured subnets
388  // which meet the selection criteria. If the range contains
389  // no subnets we punt.
390  const Subnet4Collection* subnets =
391  CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
392  const auto& idx = subnets->get<SubnetSubnetIdIndexTag>();
393 
394  // Init to ALL so we can use auto ;)
395  auto lower = idx.begin();
396  auto upper = idx.end();
397  switch (params.select_mode_) {
399  lower = idx.find(params.first_subnet_id_);
400  // If it's an unknown subnet, punt.
401  if (lower == idx.end()) {
402  isc_throw(NotFound, "subnet-id: "
403  << params.first_subnet_id_ << " does not exist");
404  }
405 
406  upper = idx.upper_bound(params.first_subnet_id_);
407  break;
409  lower = idx.lower_bound(params.first_subnet_id_);
410  upper = idx.upper_bound(params.last_subnet_id_);
411  break;
412  default:
413  break;
414  }
415 
416  // If it's an empty range, punt.
417  if (lower == upper) {
418  isc_throw(NotFound, "selected ID range: "
419  << params.first_subnet_id_ << " through "
420  << params.last_subnet_id_ << " includes no known subnets");
421  }
422 
423  // Now, that we have a valid range, run the Lease query.
424  LeaseStatsQueryPtr query;
425  switch (params.select_mode_) {
428  break;
430  query = LeaseMgrFactory::instance()
432  break;
434  query = LeaseMgrFactory::instance()
436  params.last_subnet_id_);
437  break;
438  }
439 
440  // Create the empty result-set.
441  std::vector<std::string>column_labels = { "subnet-id", "total-addresses",
442  "cumulative-assigned-addresses",
443  "assigned-addresses",
444  "declined-addresses" };
445  ElementPtr value_rows = createResultSet(result_wrapper, column_labels);
446 
447  // Get the first query row
448  LeaseStatsRow query_row;
449  bool query_eof = !(query->getNextRow(query_row));
450 
451  // Now we iterate over the selected range, building rows accordingly.
452  for (auto cur_subnet = lower; cur_subnet != upper; ++cur_subnet) {
453  SubnetID cur_id = (*cur_subnet)->getID();
454 
455  // Add total only rows for subnets that occur before,
456  // in-between, or after the subnets in the query content
457  if ((cur_id < query_row.subnet_id_) ||
458  (cur_id > query_row.subnet_id_) ||
459  (query_eof)) {
460  // Generate a totals only row
461  addValueRow4(value_rows, cur_id, 0, 0);
462  continue;
463  }
464 
465  // Current subnet matches query row, so iterate over its
466  // query rows (one per state) and accumulate them
467  // into a result-set row.
468  int64_t assigned = 0;
469  int64_t declined = 0;
470  bool add_row = false;
471  while (!query_eof && (query_row.subnet_id_ == cur_id)) {
472  if (query_row.lease_state_ == Lease::STATE_DEFAULT) {
473  add_row = true;
474  assigned = query_row.state_count_;
475  } else if (query_row.lease_state_ == Lease::STATE_DECLINED) {
476  add_row = true;
477  declined = query_row.state_count_;
478  }
479 
480  query_eof = !(query->getNextRow(query_row));
481  }
482 
483  // Add the row for the current subnet
484  if (add_row) {
485  addValueRow4(value_rows, cur_id, assigned, declined);
486  }
487  }
488 
489  return (value_rows->size());
490 }
491 
492 uint64_t
493 LeaseStatCmdsImpl::makeResultSet6(const ElementPtr& result_wrapper,
494  const Parameters& params) {
495  // Iterate over the selected range of configured subnets generating
496  // a result-set row for each one. If a subnet has data in the query
497  // content use it, otherwise, it gets a row with totals only. This
498  // way we send back a row for every selected subnet.
499  const Subnet6Collection* subnets =
500  CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
501 
502  // Set the bounds on the selected subnet range
503  const auto& idx = subnets->get<SubnetSubnetIdIndexTag>();
504 
505  // Init to all so we can use auto ;)
506  auto lower = idx.begin();
507  auto upper = idx.end();
508  switch (params.select_mode_) {
510  lower = idx.lower_bound(params.first_subnet_id_);
511  // If it's an unknown subnet, punt.
512  if (lower == idx.end()) {
513  isc_throw(NotFound, "subnet-id: "
514  << params.first_subnet_id_ << " does not exist");
515  }
516 
517  upper = idx.upper_bound(params.first_subnet_id_);
518  break;
520  lower = idx.lower_bound(params.first_subnet_id_);
521  upper = idx.upper_bound(params.last_subnet_id_);
522  break;
523  default:
524  break;
525  }
526 
527  // If it's empty range, punt.
528  if (lower == upper) {
529  isc_throw(NotFound, "selected ID range: "
530  << params.first_subnet_id_ << " through "
531  << params.last_subnet_id_ << " includes no known subnets");
532  }
533 
534  // Create the result-set map.
535  // labels could be class statics?
536  std::vector<std::string>column_labels = { "subnet-id", "total-nas",
537  "cumulative-assigned-nas",
538  "assigned-nas",
539  "declined-nas", "total-pds",
540  "cumulative-assigned-pds",
541  "assigned-pds" };
542  ElementPtr value_rows = createResultSet(result_wrapper, column_labels);
543 
544  // Now we can run the stats query.
545  LeaseStatsQueryPtr query;
546  switch (params.select_mode_) {
549  break;
551  query = LeaseMgrFactory::instance()
553  break;
555  query = LeaseMgrFactory::instance()
557  params.last_subnet_id_);
558  break;
559  }
560 
561  // Get the first query row
562  LeaseStatsRow query_row;
563  bool query_eof = !(query->getNextRow(query_row));
564 
565  for (auto cur_subnet = lower; cur_subnet != upper; ++cur_subnet) {
566  SubnetID cur_id = (*cur_subnet)->getID();
567 
568  // Add total only rows for subnets that occur before,
569  // in-between, or after subnets in the query content
570  if ((cur_id < query_row.subnet_id_) ||
571  (cur_id > query_row.subnet_id_) ||
572  (query_eof)) {
573  // Generate a totals only row
574  addValueRow6(value_rows, cur_id, 0, 0, 0);
575  continue;
576  }
577 
578  // Current subnet matches query row, so iterate over
579  // its query rows and accumulate them into a result-set row.
580  int64_t assigned = 0;
581  int64_t declined = 0;
582  int64_t assigned_pds = 0;
583  bool add_row = false;
584  while (!query_eof && (query_row.subnet_id_ == cur_id)) {
585 
586  if (query_row.lease_state_ == Lease::STATE_DEFAULT) {
587  add_row = true;
588  if (query_row.lease_type_ == Lease::TYPE_NA) {
589  assigned = query_row.state_count_;
590  } else {
591  assigned_pds = query_row.state_count_;
592  }
593  } else if (query_row.lease_state_ == Lease::STATE_DECLINED) {
594  add_row = true;
595  declined = query_row.state_count_;
596  }
597 
598  // Get next query row
599  query_eof = !(query->getNextRow(query_row));
600  }
601 
602  if (add_row) {
603  addValueRow6(value_rows, cur_id, assigned, declined, assigned_pds);
604  }
605  }
606 
607  return (value_rows->size());
608 }
609 
611 LeaseStatCmdsImpl::createResultSet(const ElementPtr &result_wrapper,
612  const std::vector<std::string>& column_labels) {
613  // Create the result-set map and add it to the wrapper.
614  ElementPtr result_set = Element::createMap();
615  result_wrapper->set("result-set", result_set);
616 
617  // Create the timestamp based on time now and add it to the result set.
618  boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
619 
620  ElementPtr timestamp = Element::create(isc::util::ptimeToText(now));
621  result_set->set("timestamp", timestamp);
622 
623  // Create the list of column names and add it to the result set.
624  ElementPtr columns = Element::createList();
625  for (auto label = column_labels.begin(); label != column_labels.end(); ++label) {
626  columns->add(Element::create(*label));
627  }
628  result_set->set("columns", columns);
629 
630  // Create the empty value_rows list, add it and then return it.
631  ElementPtr value_rows = Element::createList();
632  result_set->set("rows", value_rows);
633  return (value_rows);
634 }
635 
636 
637 void
638 LeaseStatCmdsImpl::addValueRow4(ElementPtr value_rows, const SubnetID &subnet_id,
639  int64_t assigned, int64_t declined) {
640  ElementPtr row = Element::createList();
641  row->add(Element::create(static_cast<int64_t>(subnet_id)));
642  row->add(Element::create(getSubnetStat(subnet_id, "total-addresses")));
643  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-addresses")));
644  row->add(Element::create(assigned));
645  row->add(Element::create(declined));
646  value_rows->add(row);
647 }
648 
649 void
650 LeaseStatCmdsImpl::addValueRow6(ElementPtr value_rows, const SubnetID &subnet_id,
651  int64_t assigned, int64_t declined, int64_t assigned_pds) {
652  ElementPtr row = Element::createList();
653  row->add(Element::create(static_cast<int64_t>(subnet_id)));
654  row->add(Element::create(getSubnetStat(subnet_id, "total-nas")));
655  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-nas")));
656  row->add(Element::create(assigned));
657  row->add(Element::create(declined));
658  row->add(Element::create(getSubnetStat(subnet_id, "total-pds")));
659  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-pds")));
660  row->add(Element::create(assigned_pds));
661  value_rows->add(row);
662 }
663 
664 int64_t
665 LeaseStatCmdsImpl::getSubnetStat(const SubnetID& subnet_id, const std::string& name) {
666  ObservationPtr stat = StatsMgr::instance().
667  getObservation(StatsMgr::generateName("subnet", subnet_id, name));
668  if (stat) {
669  return (stat->getInteger().first);
670  }
671 
672  return (0);
673 }
674 
675 // Using a critical section to avoid any changes in parallel.
676 
677 int
678 StatCmds::statLease4GetHandler(CalloutHandle& handle) {
681  return(impl.statLease4GetHandler(handle));
682 }
683 
684 int
685 StatCmds::statLease6GetHandler(CalloutHandle& handle) {
688  return(impl.statLease6GetHandler(handle));
689 }
690 
691 };
692 };
NotFound(const char *file, size_t line, const char *what)
Definition: stat_cmds.cc:44
RAII class creating a critical section.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
Definition: lease_mgr.cc:343
int statLease6GetHandler(CalloutHandle &handle)
Provides the implementation for stat-lease6-get, isc::stat_cmds::StatCmds::statLease6GetHandler.
Definition: stat_cmds.cc:264
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition: lease_mgr.h:207
Tag for the index for searching by subnet identifier.
Definition: subnet.h:802
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
Definition: lease_mgr.cc:348
const isc::log::MessageID STAT_CMDS_LEASE6_GET_FAILED
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
SubnetID last_subnet_id_
Specifies the last subnet for subnet range.
Definition: stat_cmds.cc:60
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
Definition: lease_mgr.cc:194
An abstract API for lease database.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:161
STL namespace.
SubnetID first_subnet_id_
Specifies the subnet-id for a single subnet, or the first subnet for a subnet range.
Definition: stat_cmds.cc:57
std::string toText()
Generate a string version of the contents.
Definition: stat_cmds.cc:67
const isc::log::MessageID STAT_CMDS_LEASE6_GET_NO_SUBNETS
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
Definition: lease_mgr.cc:199
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
const isc::log::MessageID STAT_CMDS_LEASE4_GET_FAILED
Definition: edns.h:19
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID,&Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string,&Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress,&Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::BaseStampedElement::getModificationTime > > >> Subnet4Collection
A collection of Subnet4 objects.
Definition: subnet.h:867
Implements command handling for stat-leaseX-get commands.
Definition: stat_cmds.cc:49
Per-packet callout handle.
std::string ptimeToText(boost::posix_time::ptime t, size_t fsecs_precision=MAX_FSECS_PRECISION)
Converts ptime structure to text.
SelectMode
Defines the types of selection criteria supported.
Definition: lease_mgr.h:131
SubnetID subnet_id_
The subnet ID to which this data applies.
Definition: lease_mgr.h:114
Exception thrown no subnets fall within the selection criteria This exception is thrown when a valid ...
Definition: stat_cmds.cc:42
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
const isc::log::MessageID STAT_CMDS_LEASE6_GET
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
the lease contains non-temporary IPv6 address
Definition: lease.h:51
const isc::log::MessageID STAT_CMDS_LEASE4_GET_NO_SUBNETS
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID,&Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string,&Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::BaseStampedElement::getModificationTime > > >> Subnet6Collection
A collection of Subnet6 objects.
Definition: subnet.h:914
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
Definition: lease_mgr.cc:204
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
Definition: lease_mgr.cc:338
This file contains several functions and constants that are used for handling commands and responses ...
Base class that command handler implementers may use for common tasks.
Definition: cmds_impl.h:21
uint32_t lease_state_
The lease_state to which the count applies.
Definition: lease_mgr.h:118
FlexOptionImplPtr impl
static const uint32_t STATE_DEFAULT
A lease in the default state.
Definition: lease.h:73
const isc::log::MessageID STAT_CMDS_LEASE4_GET_INVALID
int64_t state_count_
state_count The count of leases in the lease state
Definition: lease_mgr.h:120
LeaseStatsQuery::SelectMode select_mode_
Denotes the query selection mode all, subnet, or subnet range.
Definition: stat_cmds.cc:64
static const uint32_t STATE_DECLINED
Declined lease.
Definition: lease.h:76
Contains a single row of lease statistical data.
Definition: lease_mgr.h:61
Lease::Type lease_type_
The lease_type to which the count applies.
Definition: lease_mgr.h:116
static LeaseMgr & instance()
Return current lease manager.
const isc::log::MessageID STAT_CMDS_LEASE4_GET
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
Definition: observation.h:440
const isc::log::MessageID STAT_CMDS_LEASE6_GET_INVALID
int statLease4GetHandler(CalloutHandle &handle)
Provides the implementation for stat-lease4-get, isc::stat_cmds::StatCmds::statLease4GetHandler.
Definition: stat_cmds.cc:217
Wrapper class for stat-leaseX-get command parameters.
Definition: stat_cmds.cc:53
isc::log::Logger stat_cmds_logger("stat-cmds-hooks")
Definition: stat_cmds_log.h:17
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24