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