Kea
1.9.9-git
|
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. More... | |
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. More... | |
ElementPtr | createResultSet (const ElementPtr &wrapper, const std::vector< std::string > &column_labels) |
Instantiates a new "empty" result-set Element. More... | |
Parameters | getParameters (const ConstElementPtr &cmd_args) |
Parses command arguments into stat-leaseX-get parameters. More... | |
int64_t | getSubnetStat (const SubnetID &subnet_id, const std::string &name) |
Fetches a single statistic for a subnet from StatsMgr. More... | |
uint64_t | makeResultSet4 (const ElementPtr &result, const Parameters ¶ms) |
Executes the lease4 query and constructs the outbound result set. More... | |
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. More... | |
int | statLease4GetHandler (CalloutHandle &handle) |
Provides the implementation for stat-lease4-get, isc::stat_cmds::StatCmds::statLease4GetHandler. More... | |
int | statLease6GetHandler (CalloutHandle &handle) |
Provides the implementation for stat-lease6-get, isc::stat_cmds::StatCmds::statLease6GetHandler. More... | |
Implements command handling for stat-leaseX-get commands.
Definition at line 49 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 638 of file stat_cmds.cc.
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 650 of file stat_cmds.cc.
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 611 of file stat_cmds.cc.
References isc::util::ptimeToText().
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 311 of file stat_cmds.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::first_subnet_id_, isc_throw, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::last_subnet_id_, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::select_mode_, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, and isc::dhcp::LeaseStatsQuery::SUBNET_RANGE.
int64_t isc::stat_cmds::LeaseStatCmdsImpl::getSubnetStat | ( | const SubnetID & | subnet_id, |
const std::string & | name | ||
) |
Fetches a single statistic for a subnet from StatsMgr.
Uses the given id and name to query the StatsMgr for the desired value.
subnet_id | id of the desired subnet |
name | name of the desired statistic |
Definition at line 665 of file stat_cmds.cc.
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 385 of file stat_cmds.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::first_subnet_id_, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::last_subnet_id_, isc::dhcp::LeaseStatsRow::lease_state_, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::select_mode_, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, isc::dhcp::LeaseMgr::startLeaseStatsQuery4(), isc::dhcp::LeaseMgr::startSubnetLeaseStatsQuery4(), isc::dhcp::LeaseMgr::startSubnetRangeLeaseStatsQuery4(), isc::dhcp::LeaseStatsRow::state_count_, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, isc::dhcp::LeaseStatsRow::subnet_id_, and isc::dhcp::LeaseStatsQuery::SUBNET_RANGE.
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 493 of file stat_cmds.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::first_subnet_id_, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc_throw, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::last_subnet_id_, isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::select_mode_, isc::dhcp::LeaseStatsQuery::SINGLE_SUBNET, isc::dhcp::LeaseMgr::startLeaseStatsQuery6(), isc::dhcp::LeaseMgr::startSubnetLeaseStatsQuery6(), isc::dhcp::LeaseMgr::startSubnetRangeLeaseStatsQuery6(), isc::dhcp::LeaseStatsRow::state_count_, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, isc::dhcp::LeaseStatsRow::subnet_id_, isc::dhcp::LeaseStatsQuery::SUBNET_RANGE, and isc::dhcp::Lease::TYPE_NA.
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 217 of file stat_cmds.cc.
References isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), LOG_ERROR, LOG_INFO, STAT_CMDS_LEASE4_GET, STAT_CMDS_LEASE4_GET_FAILED, STAT_CMDS_LEASE4_GET_INVALID, STAT_CMDS_LEASE4_GET_NO_SUBNETS, isc::stat_cmds::stat_cmds_logger, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::toText(), and isc::Exception::what().
Referenced by isc::stat_cmds::StatCmds::statLease4GetHandler().
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 264 of file stat_cmds.cc.
References isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), LOG_ERROR, LOG_INFO, STAT_CMDS_LEASE6_GET, STAT_CMDS_LEASE6_GET_FAILED, STAT_CMDS_LEASE6_GET_INVALID, STAT_CMDS_LEASE6_GET_NO_SUBNETS, isc::stat_cmds::stat_cmds_logger, isc::stat_cmds::LeaseStatCmdsImpl::Parameters::toText(), and isc::Exception::what().
Referenced by isc::stat_cmds::StatCmds::statLease6GetHandler().