From: Tomek Mrugalski Date: Tue, 16 Jun 2015 11:40:32 +0000 (+0200) Subject: [master] Merge branch 'trac3798' (per subnet stats in DHCPv4) X-Git-Tag: trac3830_base~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bab2030f56bbf390959f9f9238a8acc62d583c70;p=thirdparty%2Fkea.git [master] Merge branch 'trac3798' (per subnet stats in DHCPv4) Conflicts: src/bin/dhcp4/tests/dhcp4_test_utils.cc --- bab2030f56bbf390959f9f9238a8acc62d583c70 diff --cc doc/guide/dhcp4-srv.xml index 01954f6181,bec0732388..e51a65cba7 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@@ -2614,217 -2582,42 +2614,252 @@@ temporarily override a list of interfac +
+ Statistics in DHCPv4 server + + This section describes DHCPv4-specific statistics. For a general + overview and usage of statistics, see . + + + + The DHCPv4 server supports the following statistics: + + + DHCPv4 Statistics + + + + + + + Statistic + Data Type + Description + + + + + + pkt4-received + integer + + Number of packets received. This includes all packets: valid, bogus, corrupted, + rejected etc. This statistic is expected to grow rapidly. + + + + + pkt4-discover-received + integer + + Number of DHCPDISCOVER packets received. This statistic is expected to grow. + Its increase means that clients that just booted started their configuration process + and their initial packets reached your server. + + + + + pkt4-offer-received + integer + + Number of DHCPOFFER packets received. This statistic + is expected to remain zero at all times, as DHCPOFFER packets are sent + by the server and the server is never expected to receive them. Non-zero + value indicates an error. One likely cause would be a misbehaving relay + agent that incorrectly forwards DHCPOFFER messages towards the server, + rather back to the clients. + + + + + pkt4-request-received + integer + + Number of DHCPREQUEST packets received. This statistic + is expected to grow. Its increase means that clients that just booted + received server's response (DHCPOFFER), accepted it and now requesting + an address (DHCPREQUEST). + + + + + pkt4-ack-received + integer + + Number of DHCPACK packets received. This statistic + is expected to remain zero at all times, as DHCPACK packets are sent + by the server and the server is never expected to receive them. Non-zero + value indicates an error. One likely cause would be a misbehaving relay + agent that incorrectly forwards DHCPACK messages towards the server, + rather back to the clients. + + + + + pkt4-nak-received + integer + + Number of DHCPNAK packets received. This statistic + is expected to remain zero at all times, as DHCPNAK packets are sent + by the server and the server is never expected to receive them. Non-zero + value indicates an error. One likely cause would be a misbehaving relay + agent that incorrectly forwards DHCPNAK messages towards the server, + rather back to the clients. + + + + + pkt4-release-received + integer + + Number of DHCPRELEASE packets received. This statistic + is expected to grow. Its increase means that clients that had an address + are shutting down or stop using their addresses. + + + + + pkt4-decline-received + integer + + Number of DHCPDECLINE packets received. This statistic + is expected to remain close to zero. Its increase means that a client + that leased an address, but discovered that the address is currently + used by an unknown device in your network. + + + + + pkt4-inform-received + integer + + Number of DHCPINFORM packets received. This statistic + is expected to grow. Its increase means that there are clients that + either do not need an address or already have an address and are + interested only in getting additional configuration parameters. + + + + + pkt4-unknown-received + integer + + Number of packets received of an unknown type. Non-zero + value of this statistic indicates that the server received a packet + that it wasn't able to recognize: either with unsupported type + or possibly malformed (without message type option). + + + + + pkt4-sent + integer + + Number of DHCPv4 packets sent. This statistic is expected to grow + every time the server transmits a packet. In general, it should + roughly match pkt4-received, as most incoming packets cause + server to respond. There are exceptions (e.g. DHCPRELEASE), so + do not worry, if it is lesser than pkt4-received. + + + + + pkt4-offer-sent + integer + + Number of DHCPOFFER packets sent. This statistic is expected to + grow in most cases after a DHCPDISCOVER is processed. There are + certain uncommon, but valid cases where incoming DHCPDISCOVER is + dropped, but in general this statistic is expected to be close to + pkt4-discover-received. + + + + + pkt4-ack-sent + integer + + Number of DHCPACK packets sent. This statistic is expected to + grow in most cases after a DHCPREQUEST is processed. There are + certain cases where DHCPNAK is sent instead. In general, the sum of + pkt4-ack-sent and pkt4-nak-sent should be close to + pkt4-request-received. + + + + + pkt4-nak-sent + integer + + Number of DHCPNAK packets sent. This statistic is expected to + grow when the server choses to not honor the address requested by a + client. In general, the sum of pkt4-ack-sent and pkt4-nak-sent + should be close to pkt4-request-received. + + + + + pkt4-parse-failed + integer + + Number of incoming packets that could not be parsed. Non-zero value of + this statistic indicates that the server received malformed or truncated packet. + This may indicate problems in your network, faulty clients or server code bug. + + + + + pkt4-receive-drop + integer + + Number of incoming packets that were dropped. + Exact reason for dropping packets is logged, but the most common + reasons may be: an unacceptable packet type, direct responses are + forbidden, or the server-id sent by the client does not match + the server's server-id. + + + + + +
+
+ + + +
+ MERGE ME + + + + subnet[id].total-addresses (integer) - + this statistic shows the total number of addresses available for the + DHCPv4 management. In other words, this is the sum of all addresses in + all configured pools. This statistic changes only during configuration + changes. Note it does not take into account any addresses that may be + reserved due to host reservation. The id is the + subnet-id of a given subnet. This statistic is exposed for each subnet + separately. This statistic is reset during reconfiguration event. + + + + subnet[id].assigned-addresses (integer) - + this statistic shows the number of assigned addresses in a given subnet. + This statistic increases every time a new lease is allocated (as a result + of receiving a DHCPREQUEST message) and is decreased every time a lease is + released (a DHCPRELEASE message is received). When lease expiration + is implemented (planned for Kea 1.0), it will also decrease when a lease + is expired. The id is the subnet-id of a given + subnet. This statistic is exposed for each subnet separately. This + statistic is reset during reconfiguration event. + + + + +
+
Supported DHCP Standards The following standards are currently supported: diff --cc src/bin/dhcp4/Makefile.am index a4bf19e8c0,83e6f6cdec..b7bc4c2056 --- a/src/bin/dhcp4/Makefile.am +++ b/src/bin/dhcp4/Makefile.am @@@ -75,10 -81,8 +75,11 @@@ kea_dhcp4_LDADD += $(top_builddir)/src/ kea_dhcp4_LDADD += $(top_builddir)/src/lib/log/libkea-log.la kea_dhcp4_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la kea_dhcp4_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la + kea_dhcp4_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la kea_dhcp4_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la +kea_dhcp4_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la +kea_dhcp4_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la +kea_dhcp4_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la kea_dhcp4dir = $(pkgdatadir) kea_dhcp4_DATA = dhcp4.spec diff --cc src/bin/dhcp4/dhcp4_srv.cc index ba954efed0,afc2ea094f..6e9ac79543 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@@ -40,11 -40,8 +40,12 @@@ #include #include #include + #include #include +#include +#include +#include +#include #include #include diff --cc src/lib/dhcpsrv/alloc_engine.cc index 4a7f3b8ab5,57e545e121..f52a679924 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@@ -1686,13 -1547,12 +1688,18 @@@ AllocEngine::requestLease4(AllocEngine: // the previous lease needs to be removed from the lease database. if (new_lease && client_lease) { ctx.old_lease_ = Lease4Ptr(new Lease4(*client_lease)); + + LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE, + ALLOC_ENGINE_V4_REQUEST_REMOVE_LEASE) + .arg(ctx.query_->getLabel()) + .arg(client_lease->addr_.toText()); + lease_mgr.deleteLease(client_lease->addr_); + + // Need to decrease statistic for assigned addresses. + StatsMgr::instance().addValue( + StatsMgr::generateName("subnet", ctx.subnet_->getID(), "assigned-addresses"), + static_cast(-1)); } // Return the allocated lease or NULL pointer if allocation was diff --cc src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc index 8602de997f,a205dd11ef..6def4a1f05 --- a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc @@@ -13,9 -13,9 +13,10 @@@ // PERFORMANCE OF THIS SOFTWARE. #include +#include #include #include + #include using namespace std; using namespace isc::hooks;