 |
Kea
1.5.0
|
Go to the documentation of this file.
15 #include <boost/foreach.hpp>
16 #include <boost/algorithm/string.hpp>
34 LeasePageSize::LeasePageSize(
const size_t page_size)
35 : page_size_(page_size) {
41 if (
page_size_ > std::numeric_limits<uint32_t>::max()) {
43 << std::numeric_limits<uint32_t>::max());
49 uint32_t iaid,
SubnetID subnet_id)
const {
54 <<
static_cast<int>(type) <<
", duid "
55 << duid.
toText() <<
", iaid " << iaid
56 <<
" and subnet-id " << subnet_id);
61 return (*col.begin());
66 using namespace stats;
68 StatsMgr& stats_mgr = StatsMgr::instance();
78 stats_mgr.setValue(
"declined-addresses", zero);
79 stats_mgr.setValue(
"reclaimed-declined-addresses", zero);
80 stats_mgr.setValue(
"reclaimed-leases", zero);
87 for (Subnet4Collection::const_iterator subnet = subnets->begin();
88 subnet != subnets->end(); ++subnet) {
89 SubnetID subnet_id = (*subnet)->getID();
90 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
91 "assigned-addresses"),
94 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
95 "declined-addresses"),
98 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
99 "reclaimed-declined-addresses"),
102 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
110 while (query->getNextRow(row)) {
113 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
114 "assigned-addresses"),
118 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
119 "declined-addresses"),
123 stats_mgr.addValue(
"declined-addresses", row.
state_count_);
129 : first_subnet_id_(0), last_subnet_id_(0), select_mode_(ALL_SUBNETS) {
133 : first_subnet_id_(subnet_id), last_subnet_id_(0),
134 select_mode_(SINGLE_SUBNET) {
143 : first_subnet_id_(first_subnet_id), last_subnet_id_(last_subnet_id),
144 select_mode_(SUBNET_RANGE) {
156 "LeaseStatsQuery: last_subnet_id_must be > first_subnet_id_");
183 using namespace stats;
185 StatsMgr& stats_mgr = StatsMgr::instance();
198 stats_mgr.setValue(
"declined-addresses", zero);
199 stats_mgr.setValue(
"reclaimed-declined-addresses", zero);
200 stats_mgr.setValue(
"reclaimed-leases", zero);
207 for (Subnet6Collection::const_iterator subnet = subnets->begin();
208 subnet != subnets->end(); ++subnet) {
209 SubnetID subnet_id = (*subnet)->getID();
210 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
214 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
215 "declined-addresses"),
218 stats_mgr.setValue(StatsMgr::
219 generateName(
"subnet", subnet_id,
220 "reclaimed-declined-addresses"),
223 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
227 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
235 while (query->getNextRow(row)) {
240 stats_mgr.setValue(StatsMgr::
246 stats_mgr.setValue(StatsMgr::
248 "declined-addresses"),
252 stats_mgr.addValue(
"declined-addresses", row.
state_count_);
259 stats_mgr.setValue(StatsMgr::
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.
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
static CfgMgr & instance()
returns a single instance of Configuration Manager
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
static const uint32_t STATE_DEFAULT
A lease in the default state.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
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.
static const uint32_t STATE_DECLINED
Declined lease.
Type
Type of lease or pool.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
LeaseStatsQuery()
Default constructor The query created will return statistics for all subnets.
An abstract API for lease database.
Defines the logger used by the top-level component of kea-dhcp-ddns.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
const size_t page_size_
Holds page size.
uint32_t lease_state_
The lease_state to which the count applies.
Multiple lease records found where one expected.
void recountLeaseStats6()
Recalculates per-subnet and global stats for IPv6 leases.
SubnetID subnet_id_
The subnet ID to which this data applies.
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.
virtual Lease6Collection getLeases6() const =0
Returns all IPv6 leases.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row of data.
Lease::Type lease_type_
The lease_type to which the count applies.
void recountLeaseStats4()
Recalculates per-subnet and global stats for IPv4 leases.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Holds DUID (DHCPv6 Unique Identifier)
A generic exception that is thrown when a function is not implemented.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Contains a single row of lease statistical data.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
@ TYPE_NA
the lease contains non-temporary IPv6 address
int64_t state_count_
state_count The count of leases in the lease state
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
Returns existing IPv6 lease for a given IPv6 address.
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.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.