Kea  2.3.7
stat_cmds.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-2022 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 isc::log;
35 using namespace std;
36 
37 namespace isc {
38 namespace stat_cmds {
39 
43 class NotFound: public isc::Exception {
44 public:
45  NotFound (const char* file, size_t line, const char* what) :
46  isc::Exception(file, line, what) { };
47 };
48 
50 class LeaseStatCmdsImpl : private CmdsImpl {
51 public:
52 
54  class Parameters {
55  public:
59 
62 
66 
68  std::string toText() {
69  std::stringstream os;
70  switch (select_mode_) {
72  os << "[all subnets]";
73  break;
75  os << "[subnet-id=" << first_subnet_id_ << "]";
76  break;
78  os << "[subnets " << first_subnet_id_
79  << " through " << last_subnet_id_ << "]";
80  break;
81  }
82 
83  return (os.str());
84  }
85  };
86 
87 public:
88 
100  int
101  statLease4GetHandler(CalloutHandle& handle);
102 
114  int
115  statLease6GetHandler(CalloutHandle& handle);
116 
126  Parameters getParameters(const ConstElementPtr& cmd_args);
127 
145  uint64_t makeResultSet4(const ElementPtr& result, const Parameters& params);
146 
163  uint64_t makeResultSet6(const ElementPtr& result, const Parameters& params);
164 
184  ElementPtr createResultSet(const ElementPtr& wrapper,
185  const std::vector<std::string>& column_labels);
186 
194  void addValueRow4(ElementPtr value_rows, const SubnetID &subnet_id,
195  int64_t assigned, int64_t declined);
196 
205  void addValueRow6(ElementPtr value_rows, const SubnetID &subnet_id,
206  int64_t assigned, int64_t declined, int64_t assigned_pds);
207 
214  int64_t getSubnetStat(const SubnetID& subnet_id, const std::string& name);
215 };
216 
217 int
218 LeaseStatCmdsImpl::statLease4GetHandler(CalloutHandle& handle) {
219  ElementPtr result = Element::createMap();
220  Parameters params;
221  ConstElementPtr response;
222 
223  // Extract the command and then the parameters
224  try {
225  extractCommand(handle);
226  params = getParameters(cmd_args_);
227  } catch (const std::exception& ex) {
229  .arg(ex.what());
230  setErrorResponse(handle, ex.what());
231  return (1);
232  }
233 
234  try {
235  // Now build the result set
236  uint64_t rows = makeResultSet4(result, params);
238  .arg(params.toText())
239  .arg(rows);
240  std::stringstream os;
241  os << "stat-lease4-get" << params.toText() << ": " << rows << " rows found";
242  response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
243  } catch (const NotFound& ex) {
244  // Criteria was valid but included no known subnets,
245  // so we return a not found response.
247  .arg(params.toText())
248  .arg(ex.what());
249  std::stringstream os;
250  os << "stat-lease4-get" << params.toText() << ": no matching data, " << ex.what();
251  response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
252  } catch (const std::exception& ex) {
254  .arg(params.toText())
255  .arg(ex.what());
256  setErrorResponse(handle, ex.what());
257  return (1);
258  }
259 
260  setResponse(handle, response);
261  return (0);
262 }
263 
264 int
265 LeaseStatCmdsImpl::statLease6GetHandler(CalloutHandle& handle) {
266  ElementPtr result = Element::createMap();
267  Parameters params;
268  ConstElementPtr response;
269 
270  // Extract the command and then the parameters
271  try {
272  extractCommand(handle);
273  params = getParameters(cmd_args_);
274  } catch (const std::exception& ex) {
276  .arg(ex.what());
277  setErrorResponse(handle, ex.what());
278  return (1);
279  }
280 
281  try {
282  // Now build the result set
283  uint64_t rows = makeResultSet6(result, params);
285  .arg(params.toText())
286  .arg(rows);
287  std::stringstream os;
288  os << "stat-lease6-get" << params.toText() << ": " << rows << " rows found";
289  response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
290  } catch (const NotFound& ex) {
291  // Criteria was valid but included no known subnets,
292  // so we return a not found response.
294  .arg(params.toText())
295  .arg(ex.what());
296  std::stringstream os;
297  os << "stat-lease6-get" << params.toText() << ": no matching data, " << ex.what();
298  response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
299  } catch (const std::exception& ex) {
301  .arg(params.toText())
302  .arg(ex.what());
303  setErrorResponse(handle, ex.what());
304  return (1);
305  }
306 
307  setResponse(handle, response);
308  return (0);
309 }
310 
312 LeaseStatCmdsImpl::getParameters(const ConstElementPtr& cmd_args) {
313  Parameters params;
314 
316  params.first_subnet_id_ = 0;
317  params.last_subnet_id_ = 0;
318  if (!cmd_args ) {
319  // No arguments defaults to ALL_SUBNETS.
320  return (params);
321  }
322 
323  if (cmd_args->getType() != Element::map) {
324  isc_throw(BadValue, "'arguments' parameter is not a map");
325  }
326 
328  if (cmd_args->contains("subnet-id")) {
329 
330  ConstElementPtr value = cmd_args->get("subnet-id");
331  if (value->getType() != Element::integer) {
332  isc_throw(BadValue, "'subnet-id' parameter is not integer");
333  }
334 
335  if (value->intValue() <= 0) {
336  isc_throw(BadValue, "'subnet-id' parameter must be > 0");
337  }
338 
339  params.first_subnet_id_ = value->intValue();
341  }
342 
343  if (cmd_args->contains("subnet-range")) {
345  isc_throw(BadValue, "cannot specify both subnet-id and subnet-range");
346  }
347 
348  ConstElementPtr range = cmd_args->get("subnet-range");
349  if (range->getType() != Element::map) {
350  isc_throw(BadValue, "subnet-range parameter is not a map");
351  }
352 
353  ConstElementPtr value = range->get("first-subnet-id");
354  if (!value || value->getType() != Element::integer) {
355  isc_throw(BadValue, "'first-subnet-id' parameter missing or not an integer");
356  }
357 
358  if (value->intValue() <= 0) {
359  isc_throw(BadValue, "'first-subnet-id' parameter must be > 0");
360  }
361 
362  params.first_subnet_id_ = value->intValue();
363 
364  value = range->get("last-subnet-id");
365  if (!value || value->getType() != Element::integer) {
366  isc_throw(BadValue, "'last-subnet-id' parameter missing or not an integer");
367  }
368 
369  if (value->intValue() <= 0) {
370  isc_throw(BadValue, "'last-subnet-id' parameter must be > 0");
371  }
372 
373  params.last_subnet_id_ = value->intValue();
374 
375  if (params.last_subnet_id_ < params.first_subnet_id_) {
376  isc_throw(BadValue, "'last-subnet-id' must be greater than 'first-subnet-id'");
377  }
378 
380  }
381 
382  return (params);
383 }
384 
385 uint64_t
386 LeaseStatCmdsImpl::makeResultSet4(const ElementPtr& result_wrapper,
387  const Parameters& params) {
388  // First we need to determine the range of configured subnets
389  // which meet the selection criteria. If the range contains
390  // no subnets we punt.
391  // Iterate over the selected range of configured subnets generating
392  // a result-set row for each one. If a subnet has data in the query
393  // content use it, otherwise, it gets a row with totals only. This
394  // way we send back a row for every selected subnet.
395  const Subnet4Collection* subnets =
396  CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
397 
398  // Set the bounds on the selected subnet range
399  const auto& idx = subnets->get<SubnetSubnetIdIndexTag>();
400 
401  // Init to ALL so we can use auto
402  auto lower = idx.begin();
403  auto upper = idx.end();
404  switch (params.select_mode_) {
406  lower = idx.find(params.first_subnet_id_);
407  // If it's an unknown subnet, punt.
408  if (lower == idx.end()) {
409  isc_throw(NotFound, "subnet-id: "
410  << params.first_subnet_id_ << " does not exist");
411  }
412 
413  upper = idx.upper_bound(params.first_subnet_id_);
414  break;
416  lower = idx.lower_bound(params.first_subnet_id_);
417  upper = idx.upper_bound(params.last_subnet_id_);
418  break;
419  default:
420  break;
421  }
422 
423  // If it's an empty range, punt.
424  if (lower == upper) {
425  isc_throw(NotFound, "selected ID range: "
426  << params.first_subnet_id_ << " through "
427  << params.last_subnet_id_ << " includes no known subnets");
428  }
429 
430  // Now we can run the stats query.
431  LeaseStatsQueryPtr query;
432  switch (params.select_mode_) {
435  break;
437  query = LeaseMgrFactory::instance()
439  break;
441  query = LeaseMgrFactory::instance()
443  params.last_subnet_id_);
444  break;
445  }
446 
447  // Create the result-set map.
448  // labels could be class statics?
449  std::vector<std::string>column_labels = { "subnet-id", "total-addresses",
450  "cumulative-assigned-addresses",
451  "assigned-addresses",
452  "declined-addresses" };
453  ElementPtr value_rows = createResultSet(result_wrapper, column_labels);
454 
455  // Get the first query row
456  LeaseStatsRow query_row;
457  bool query_eof = !(query->getNextRow(query_row));
458 
459  // Now we iterate over the selected range, building rows accordingly.
460  bool orphaned_stats = false;
461  for (auto cur_subnet = lower; cur_subnet != upper; ++cur_subnet) {
462  SubnetID cur_id = (*cur_subnet)->getID();
463 
464  // Skip any unexpected result set rows. These occur when
465  // subnets no longer exist but either their leases (memfile)
466  // or their leaseX-stat rows (db lease backends) still do.
467  while ((cur_id > query_row.subnet_id_) && (!query_eof)) {
468  orphaned_stats = true;
469  query_eof = !(query->getNextRow(query_row));
470  }
471 
472  // Add total only rows for subnets that occur before
473  // or after the subnets in the query content. These are
474  // subnets which exist but for which there is not yet any
475  // lease data.
476  if ((cur_id < query_row.subnet_id_) || (query_eof)) {
477  // Generate a totals only row
478  addValueRow4(value_rows, cur_id, 0, 0);
479  continue;
480  }
481 
482  // Current subnet matches query row, so iterate over its
483  // query rows (one per state) and accumulate them
484  // into a result-set row.
485  int64_t assigned = 0;
486  int64_t declined = 0;
487  bool add_row = false;
488  while (!query_eof && (query_row.subnet_id_ == cur_id)) {
489  if (query_row.lease_state_ == Lease::STATE_DEFAULT) {
490  add_row = true;
491  assigned = query_row.state_count_;
492  } else if (query_row.lease_state_ == Lease::STATE_DECLINED) {
493  add_row = true;
494  declined = query_row.state_count_;
495  }
496 
497  // Get next query row
498  query_eof = !(query->getNextRow(query_row));
499  }
500  // Add the row for the current subnet
501  if (add_row) {
502  addValueRow4(value_rows, cur_id, assigned, declined);
503  }
504  }
505 
506  // If there are any orphaned statistics log it.
507  if (!(query_eof) || orphaned_stats) {
509  }
510 
511  return (value_rows->size());
512 }
513 
514 uint64_t
515 LeaseStatCmdsImpl::makeResultSet6(const ElementPtr& result_wrapper,
516  const Parameters& params) {
517  // First we need to determine the range of configured subnets
518  // which meet the selection criteria. If the range contains
519  // no subnets we punt.
520  // Iterate over the selected range of configured subnets generating
521  // a result-set row for each one. If a subnet has data in the query
522  // content use it, otherwise, it gets a row with totals only. This
523  // way we send back a row for every selected subnet.
524  const Subnet6Collection* subnets =
525  CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
526 
527  // Set the bounds on the selected subnet range
528  const auto& idx = subnets->get<SubnetSubnetIdIndexTag>();
529 
530  // Init to ALL so we can use auto
531  auto lower = idx.begin();
532  auto upper = idx.end();
533  switch (params.select_mode_) {
535  lower = idx.find(params.first_subnet_id_);
536  // If it's an unknown subnet, punt.
537  if (lower == idx.end()) {
538  isc_throw(NotFound, "subnet-id: "
539  << params.first_subnet_id_ << " does not exist");
540  }
541 
542  upper = idx.upper_bound(params.first_subnet_id_);
543  break;
545  lower = idx.lower_bound(params.first_subnet_id_);
546  upper = idx.upper_bound(params.last_subnet_id_);
547  break;
548  default:
549  break;
550  }
551 
552  // If it's an empty range, punt.
553  if (lower == upper) {
554  isc_throw(NotFound, "selected ID range: "
555  << params.first_subnet_id_ << " through "
556  << params.last_subnet_id_ << " includes no known subnets");
557  }
558 
559  // Now we can run the stats query.
560  LeaseStatsQueryPtr query;
561  switch (params.select_mode_) {
564  break;
566  query = LeaseMgrFactory::instance()
568  break;
570  query = LeaseMgrFactory::instance()
572  params.last_subnet_id_);
573  break;
574  }
575 
576  // Create the result-set map.
577  // labels could be class statics?
578  std::vector<std::string>column_labels = { "subnet-id", "total-nas",
579  "cumulative-assigned-nas",
580  "assigned-nas",
581  "declined-nas", "total-pds",
582  "cumulative-assigned-pds",
583  "assigned-pds" };
584  ElementPtr value_rows = createResultSet(result_wrapper, column_labels);
585 
586  // Get the first query row
587  LeaseStatsRow query_row;
588  bool query_eof = !(query->getNextRow(query_row));
589 
590  // Now we iterate over the selected range, building rows accordingly.
591  bool orphaned_stats = false;
592  for (auto cur_subnet = lower; cur_subnet != upper; ++cur_subnet) {
593  SubnetID cur_id = (*cur_subnet)->getID();
594 
595  // Skip any unexpected result set rows. These occur when
596  // subnets no longer exist but either their leases (memfile)
597  // or their leaseX-stat rows (db lease backends) still do.
598  while ((cur_id > query_row.subnet_id_) && (!query_eof)) {
599  orphaned_stats = true;
600  query_eof = !(query->getNextRow(query_row));
601  }
602 
603  // Add total only rows for subnets that occur before
604  // or after the subnets in the query content. These are
605  // subnets which exist but for which there is not yet any
606  // lease data.
607  if ((cur_id < query_row.subnet_id_) || (query_eof)) {
608  // Generate a totals only row
609  addValueRow6(value_rows, cur_id, 0, 0, 0);
610  continue;
611  }
612 
613  // Current subnet matches query row, so iterate over its
614  // query rows (one per state) and accumulate them
615  // into a result-set row.
616  int64_t assigned = 0;
617  int64_t declined = 0;
618  int64_t assigned_pds = 0;
619  bool add_row = false;
620  while (!query_eof && (query_row.subnet_id_ == cur_id)) {
621  if (query_row.lease_state_ == Lease::STATE_DEFAULT) {
622  add_row = true;
623  if (query_row.lease_type_ == Lease::TYPE_NA) {
624  assigned = query_row.state_count_;
625  } else {
626  assigned_pds = query_row.state_count_;
627  }
628  } else if (query_row.lease_state_ == Lease::STATE_DECLINED) {
629  add_row = true;
630  declined = query_row.state_count_;
631  }
632 
633  // Get next query row
634  query_eof = !(query->getNextRow(query_row));
635  }
636  // Add the row for the current subnet
637  if (add_row) {
638  addValueRow6(value_rows, cur_id, assigned, declined, assigned_pds);
639  }
640  }
641 
642  // If there are any orphaned statistics log it.
643  if (!(query_eof) || orphaned_stats) {
645  }
646 
647  return (value_rows->size());
648 }
649 
651 LeaseStatCmdsImpl::createResultSet(const ElementPtr &result_wrapper,
652  const std::vector<std::string>& column_labels) {
653  // Create the result-set map and add it to the wrapper.
654  ElementPtr result_set = Element::createMap();
655  result_wrapper->set("result-set", result_set);
656 
657  // Create the timestamp based on time now and add it to the result set.
658  boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
659 
661  result_set->set("timestamp", timestamp);
662 
663  // Create the list of column names and add it to the result set.
664  ElementPtr columns = Element::createList();
665  for (auto label = column_labels.begin(); label != column_labels.end(); ++label) {
666  columns->add(Element::create(*label));
667  }
668  result_set->set("columns", columns);
669 
670  // Create the empty value_rows list, add it and then return it.
671  ElementPtr value_rows = Element::createList();
672  result_set->set("rows", value_rows);
673  return (value_rows);
674 }
675 
676 
677 void
678 LeaseStatCmdsImpl::addValueRow4(ElementPtr value_rows, const SubnetID &subnet_id,
679  int64_t assigned, int64_t declined) {
681  row->add(Element::create(static_cast<int64_t>(subnet_id)));
682  row->add(Element::create(getSubnetStat(subnet_id, "total-addresses")));
683  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-addresses")));
684  row->add(Element::create(assigned));
685  row->add(Element::create(declined));
686  value_rows->add(row);
687 }
688 
689 void
690 LeaseStatCmdsImpl::addValueRow6(ElementPtr value_rows, const SubnetID &subnet_id,
691  int64_t assigned, int64_t declined, int64_t assigned_pds) {
693  row->add(Element::create(static_cast<int64_t>(subnet_id)));
694  row->add(Element::create(getSubnetStat(subnet_id, "total-nas")));
695  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-nas")));
696  row->add(Element::create(assigned));
697  row->add(Element::create(declined));
698  row->add(Element::create(getSubnetStat(subnet_id, "total-pds")));
699  row->add(Element::create(getSubnetStat(subnet_id, "cumulative-assigned-pds")));
700  row->add(Element::create(assigned_pds));
701  value_rows->add(row);
702 }
703 
704 int64_t
705 LeaseStatCmdsImpl::getSubnetStat(const SubnetID& subnet_id, const std::string& name) {
706  ObservationPtr stat = StatsMgr::instance().
707  getObservation(StatsMgr::generateName("subnet", subnet_id, name));
708  if (stat) {
709  return (stat->getInteger().first);
710  }
711 
712  return (0);
713 }
714 
715 // Using a critical section to avoid any changes in parallel.
716 
717 int
718 StatCmds::statLease4GetHandler(CalloutHandle& handle) {
719  try {
721  return (impl.statLease4GetHandler(handle));
722  } catch (const std::exception& ex) {
723 
725  .arg(ex.what());
726  }
727  return (1);
728 }
729 
730 int
731 StatCmds::statLease6GetHandler(CalloutHandle& handle) {
732  try {
734  return (impl.statLease6GetHandler(handle));
735  } catch (const std::exception& ex) {
736 
738  .arg(ex.what());
739  }
740  return (1);
741 }
742 
743 };
744 };
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
Base class that command handler implementers may use for common tasks.
Definition: cmds_impl.h:21
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition: data.cc:241
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition: data.cc:291
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:286
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition: cfgmgr.cc:161
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
Definition: lease_mgr.cc:349
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:210
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:354
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
Definition: lease_mgr.cc:205
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
Definition: lease_mgr.cc:200
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
Definition: lease_mgr.cc:344
SelectMode
Defines the types of selection criteria supported.
Definition: lease_mgr.h:134
Per-packet callout handle.
Wrapper class for stat-leaseX-get command parameters.
Definition: stat_cmds.cc:54
SubnetID first_subnet_id_
Specifies the subnet-id for a single subnet, or the first subnet for a subnet range.
Definition: stat_cmds.cc:58
LeaseStatsQuery::SelectMode select_mode_
Denotes the query selection mode all, subnet, or subnet range.
Definition: stat_cmds.cc:65
std::string toText()
Generate a string version of the contents.
Definition: stat_cmds.cc:68
SubnetID last_subnet_id_
Specifies the last subnet for subnet range.
Definition: stat_cmds.cc:61
Implements command handling for stat-leaseX-get commands.
Definition: stat_cmds.cc:50
Exception thrown no subnets fall within the selection criteria This exception is thrown when a valid ...
Definition: stat_cmds.cc:43
NotFound(const char *file, size_t line, const char *what)
Definition: stat_cmds.cc:45
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
An abstract API for lease database.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition: macros.h:32
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition: macros.h:20
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition: lease_mgr.h:210
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:946
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:875
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition: subnet_id.h:25
FlexOptionImplPtr impl
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Definition: log_dbglevels.h:69
isc::log::Logger stat_cmds_logger("stat-cmds-hooks")
Definition: stat_cmds_log.h:17
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
Definition: observation.h:440
Definition: edns.h:19
std::string ptimeToText(boost::posix_time::ptime t, size_t fsecs_precision=MAX_FSECS_PRECISION)
Converts ptime structure to text.
Defines the logger used by the top-level component of kea-lfc.
const isc::log::MessageID STAT_CMDS_LEASE4_GET_INVALID
const isc::log::MessageID STAT_CMDS_LEASE6_GET_INVALID
const isc::log::MessageID STAT_CMDS_LEASE6_FAILED
const isc::log::MessageID STAT_CMDS_LEASE6_GET
const isc::log::MessageID STAT_CMDS_LEASE4_FAILED
const isc::log::MessageID STAT_CMDS_LEASE6_GET_FAILED
const isc::log::MessageID STAT_CMDS_LEASE4_GET_NO_SUBNETS
const isc::log::MessageID STAT_CMDS_LEASE6_GET_NO_SUBNETS
const isc::log::MessageID STAT_CMDS_LEASE6_ORPHANED_STATS
const isc::log::MessageID STAT_CMDS_LEASE4_GET_FAILED
const isc::log::MessageID STAT_CMDS_LEASE4_ORPHANED_STATS
const isc::log::MessageID STAT_CMDS_LEASE4_GET
Contains a single row of lease statistical data.
Definition: lease_mgr.h:64
int64_t state_count_
state_count The count of leases in the lease state
Definition: lease_mgr.h:123
uint32_t lease_state_
The lease_state to which the count applies.
Definition: lease_mgr.h:121
SubnetID subnet_id_
The subnet ID to which this data applies.
Definition: lease_mgr.h:117
Lease::Type lease_type_
The lease_type to which the count applies.
Definition: lease_mgr.h:119
static const uint32_t STATE_DEFAULT
A lease in the default state.
Definition: lease.h:69
static const uint32_t STATE_DECLINED
Declined lease.
Definition: lease.h:72
@ TYPE_NA
the lease contains non-temporary IPv6 address
Definition: lease.h:47
Tag for the index for searching by subnet identifier.
Definition: subnet.h:786