Kea 2.7.5
|
Implements command handling for stat-leaseX-get commands. More...
Classes | |
class | Parameters |
Wrapper class for stat-leaseX-get command parameters. More... | |
Public Member Functions | |
void | addValueRow4 (ElementPtr value_rows, const SubnetID &subnet_id, int64_t assigned, int64_t declined) |
Adds a row of Lease4 stat values to a list of value rows. | |
void | addValueRow6 (ElementPtr value_rows, const SubnetID &subnet_id, int64_t assigned, int64_t declined, int64_t assigned_pds) |
Adds a row of Lease6 stat values to a list of value rows. | |
ElementPtr | createResultSet (const ElementPtr &wrapper, const std::vector< std::string > &column_labels) |
Instantiates a new "empty" result-set Element. | |
int128_t | getBigSubnetStat (const SubnetID &subnet_id, const std::string &name) |
Fetches a single bigint statistic for a subnet from StatsMgr. | |
Parameters | getParameters (const ConstElementPtr &cmd_args) |
Parses command arguments into stat-leaseX-get parameters. | |
int64_t | getSubnetStat (const SubnetID &subnet_id, const std::string &name) |
Fetches a single integer statistic for a subnet from StatsMgr. | |
uint64_t | makeResultSet4 (const ElementPtr &result, const Parameters ¶ms) |
Executes the lease4 query and constructs the outbound result set. | |
uint64_t | makeResultSet6 (const ElementPtr &result, const Parameters ¶ms) |
Executes the lease4 query and constructs the outbound result set This method uses the command parameters to identify the range of configured subnets. | |
int | statLease4GetHandler (CalloutHandle &handle) |
Provides the implementation for stat-lease4-get, isc::stat_cmds::StatCmds::statLease4GetHandler. | |
int | statLease6GetHandler (CalloutHandle &handle) |
Provides the implementation for stat-lease6-get, isc::stat_cmds::StatCmds::statLease6GetHandler. | |
Implements command handling for stat-leaseX-get commands.
Definition at line 50 of file stat_cmds.cc.
void isc::stat_cmds::LeaseStatCmdsImpl::addValueRow4 | ( | ElementPtr | value_rows, |
const SubnetID & | subnet_id, | ||
int64_t | assigned, | ||
int64_t | declined ) |
Adds a row of Lease4 stat values to a list of value rows.
[out] | value_rows | list of rows to which to add |
[out] | subnet_id | id of the subnet of the new row. This value is also used for fetching the total addresses in the subnet |
assigned | number of assigned addresses in the subnet | |
declined | number of declined addresses in the subnet |
Definition at line 692 of file stat_cmds.cc.
References isc::data::Element::create(), isc::data::Element::createList(), and getSubnetStat().
Referenced by makeResultSet4().
void isc::stat_cmds::LeaseStatCmdsImpl::addValueRow6 | ( | ElementPtr | value_rows, |
const SubnetID & | subnet_id, | ||
int64_t | assigned, | ||
int64_t | declined, | ||
int64_t | assigned_pds ) |
Adds a row of Lease6 stat values to a list of value rows.
[out] | value_rows | list of rows to which to add |
[out] | subnet_id | id of the subnet of the new row. This value is also used for fetching the total NAs and PDs in the subnet |
assigned | number of assigned NAs in the subnet | |
declined | number of declined NAs in the subnet | |
assigned_pds | number of assigned PDs the subnet |
Definition at line 704 of file stat_cmds.cc.
References isc::data::Element::create(), isc::data::Element::createList(), getBigSubnetStat(), and getSubnetStat().
Referenced by makeResultSet6().
ElementPtr isc::stat_cmds::LeaseStatCmdsImpl::createResultSet | ( | const ElementPtr & | wrapper, |
const std::vector< std::string > & | column_labels ) |
Instantiates a new "empty" result-set Element.
Constructs a ElementPtr tree of an empty result set for holding rows of the given column labels. In JSON it appears as follows:
"result-set": { "timestamp": "2018-03-22 09:43:30.815371", "columns": ["<label-1>, <label-2>, ... ], "rows": [] }
And then adds it to the given wrapper element.
wrapper | Element to which the newly constructed result-set will be added. |
column_labels | list of the column labels in the order the values for each column will appear in the result-set rows |
Definition at line 665 of file stat_cmds.cc.
References isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), and isc::util::ptimeToText().
Referenced by makeResultSet4(), and makeResultSet6().
int128_t isc::stat_cmds::LeaseStatCmdsImpl::getBigSubnetStat | ( | const SubnetID & | subnet_id, |
const std::string & | name ) |
Fetches a single bigint statistic for a subnet from StatsMgr.
Uses the given id and name to query the StatsMgr for the desired value.
subnet_id | the subnet ID for the desired statistic |
name | the name of the desired statistic |
Definition at line 730 of file stat_cmds.cc.
References isc::stats::StatsMgr::generateName(), and isc::stats::StatsMgr::instance().
Referenced by addValueRow6().
LeaseStatCmdsImpl::Parameters isc::stat_cmds::LeaseStatCmdsImpl::getParameters | ( | const ConstElementPtr & | cmd_args | ) |
Parses command arguments into stat-leaseX-get parameters.
cmd_args | Element form of command arguments to parse |
BadValue | if any of the following rules are broken: |
Definition at line 322 of file stat_cmds.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::data::Element::integer, isc_throw, isc::data::Element::map, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::select_mode_, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, and isc::dhcp::LeaseStatsQuery::SUBNET_RANGE.
Referenced by statLease4GetHandler(), and statLease6GetHandler().
int64_t isc::stat_cmds::LeaseStatCmdsImpl::getSubnetStat | ( | const SubnetID & | subnet_id, |
const std::string & | name ) |
Fetches a single integer statistic for a subnet from StatsMgr.
Uses the given id and name to query the StatsMgr for the desired value.
subnet_id | the subnet ID for the desired statistic |
name | the name of the desired statistic |
Definition at line 719 of file stat_cmds.cc.
References isc::stats::StatsMgr::generateName(), and isc::stats::StatsMgr::instance().
Referenced by addValueRow4(), and addValueRow6().
uint64_t isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4 | ( | const ElementPtr & | result, |
const Parameters & | params ) |
Executes the lease4 query and constructs the outbound result set.
This method uses the command parameters to identify the range of configured subnets. If the range contains no known subnets then a NotFound exception is thrown. Having determined the range to be valid, it then executes the appropriate Lease4 stats query via the LeaseMgr.
Lastly, it iterates over the qualifying subnets adding a row of statistics for each one to the result-set. Each row combines the totals from StatsMgr with the type and state counts from the query results. For subnets with no query data (i.e. no leases), their rows have non-zero values for totals only.
result | Element to which the constructed result-set will be added. |
params | Parsed stat-lease4-cmd parameters |
NotFound | if the selection criteria eliminates all known subnets |
Definition at line 396 of file stat_cmds.cc.
References addValueRow4(), isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, createResultSet(), isc::log::DBGLVL_TRACE_BASIC, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, LOG_DEBUG, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, STAT_CMDS_LEASE4_ORPHANED_STATS, isc::stat_cmds::stat_cmds_logger, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, and isc::dhcp::LeaseStatsQuery::SUBNET_RANGE.
Referenced by statLease4GetHandler().
uint64_t isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6 | ( | const ElementPtr & | result, |
const Parameters & | params ) |
Executes the lease4 query and constructs the outbound result set This method uses the command parameters to identify the range of configured subnets.
If the range contains no known subnets then a NotFound exception is thrown. Having determined the range to be valid, it then executes the appropriate Lease6 stats query via the LeaseMgr.
Lastly, it iterates over the qualifying subnets adding a row of statistics for each one to the result-set. Each row combines the totals from StatsMgr with the type and state counts from the query results. For subnets with no query data (i.e. no leases), their rows have non-zero values for totals only.
result | Element to which the constructed result-set will be added. |
params | Parsed stat-lease6-cmd parameters |
NotFound | if the selection criteria eliminates all known subnets |
Definition at line 527 of file stat_cmds.cc.
References addValueRow6(), isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, createResultSet(), isc::log::DBGLVL_TRACE_BASIC, isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, LOG_DEBUG, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, STAT_CMDS_LEASE6_ORPHANED_STATS, isc::stat_cmds::stat_cmds_logger, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, isc::dhcp::LeaseStatsQuery::SUBNET_RANGE, and isc::dhcp::Lease::TYPE_NA.
Referenced by statLease6GetHandler().
int isc::stat_cmds::LeaseStatCmdsImpl::statLease4GetHandler | ( | CalloutHandle & | handle | ) |
Provides the implementation for stat-lease4-get, isc::stat_cmds::StatCmds::statLease4GetHandler.
It parses the command arguments, and then invokes makeResult4() to fulfil the lease4 statistics fetch. It then constructs the outbound response based on those results. If a NotFound exception is caught, a CONTROL_RESULT_EMTPY response is generated.
handle | Callout context - which is expected to contain the command JSON text in the "command" argument |
Definition at line 228 of file stat_cmds.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), getParameters(), LOG_ERROR, LOG_INFO, makeResultSet4(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), STAT_CMDS_LEASE4_GET, STAT_CMDS_LEASE4_GET_FAILED, STAT_CMDS_LEASE4_GET_INVALID, STAT_CMDS_LEASE4_GET_NO_SUBNETS, and isc::stat_cmds::stat_cmds_logger.
int isc::stat_cmds::LeaseStatCmdsImpl::statLease6GetHandler | ( | CalloutHandle & | handle | ) |
Provides the implementation for stat-lease6-get, isc::stat_cmds::StatCmds::statLease6GetHandler.
It parses the command arguments, and then invokes makeResult6() to fulfil the lease6 statistics fetch. It then constructs the outbound response based on those results. If a NotFound exception is caught, a CONTROL_RESULT_EMTPY response is generated.
handle | Callout context - which is expected to contain the command JSON text in the "command" argument |
Definition at line 275 of file stat_cmds.cc.
References isc::config::CmdsImpl::cmd_args_, isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::data::Element::createMap(), isc::config::CmdsImpl::extractCommand(), getParameters(), LOG_ERROR, LOG_INFO, makeResultSet6(), isc::config::CmdsImpl::setErrorResponse(), isc::config::CmdsImpl::setResponse(), STAT_CMDS_LEASE6_GET, STAT_CMDS_LEASE6_GET_FAILED, STAT_CMDS_LEASE6_GET_INVALID, STAT_CMDS_LEASE6_GET_NO_SUBNETS, and isc::stat_cmds::stat_cmds_logger.