]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Merge branch 'trac3798' (per subnet stats in DHCPv4)
authorTomek Mrugalski <tomasz@isc.org>
Tue, 16 Jun 2015 11:40:32 +0000 (13:40 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 16 Jun 2015 11:40:32 +0000 (13:40 +0200)
Conflicts:
src/bin/dhcp4/tests/dhcp4_test_utils.cc

1  2 
doc/guide/dhcp4-srv.xml
src/bin/dhcp4/Makefile.am
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/dhcp4_test_utils.cc
src/bin/dhcp4/tests/release_unittest.cc
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc

index 01954f6181b3a52e032673b970f5fde8b405d0ca,bec07323887c6ea6121d47292714d0b6d46b8d62..e51a65cba7702d9e4086d9b3085aeeb63f8fd64f
@@@ -2614,217 -2582,42 +2614,252 @@@ temporarily override a list of interfac
  
      </section>
  
 +    <section id="dhcp4-stats">
 +      <title>Statistics in DHCPv4 server</title>
 +      <note>
 +        <para>This section describes DHCPv4-specific statistics. For a general
 +        overview and usage of statistics, see <xref linkend="stats" />.</para>
 +      </note>
 +
 +      <para>
 +        The DHCPv4 server supports the following statistics:
 +      </para>
 +        <table frame="all" id="dhcp4-statistics">
 +          <title>DHCPv4 Statistics</title>
 +          <tgroup cols='3'>
 +          <colspec colname='statistic' align='center'/>
 +          <colspec colname='type' align='center'/>
 +          <colspec colname='description' align='left'/>
 +          <thead>
 +            <row>
 +              <entry>Statistic</entry>
 +              <entry>Data Type</entry>
 +              <entry>Description</entry>
 +            </row>
 +          </thead>
 +          <tbody>
 +
 +            <row>
 +            <entry>pkt4-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            Number of packets received. This includes all packets: valid, bogus, corrupted,
 +            rejected etc.  This statistic is expected to grow rapidly.
 +            </entry>
 +            </row>
 +            <row>
 +
 +            <entry>pkt4-discover-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-offer-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-request-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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).
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-ack-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-nak-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-release-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-decline-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-inform-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-unknown-received</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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).
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-sent</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-offer-sent</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-ack-sent</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-nak-sent</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-parse-failed</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +            <row>
 +            <entry>pkt4-receive-drop</entry>
 +            <entry>integer</entry>
 +            <entry>
 +            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.
 +            </entry>
 +            </row>
 +
 +        </tbody>
 +        </tgroup>
 +        </table>
 +    </section>
  
+ <!-- proper section structure added in ticket 3794, will merge it
+ appropiately -->
+ <section id="dummy">
+   <title>MERGE ME</title>
+   <para>
+     <itemizedlist>
+       <listitem>
+         <simpara><emphasis>subnet[id].total-addresses</emphasis> (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 <emphasis>id</emphasis> is the
+         subnet-id of a given subnet. This statistic is exposed for each subnet
+       separately. This statistic is reset during reconfiguration event.
+       </simpara>
+       </listitem>
+       <listitem>
+         <simpara><emphasis>subnet[id].assigned-addresses</emphasis> (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 <emphasis>id</emphasis> is the subnet-id of a given
+         subnet. This statistic is exposed for each subnet separately. This
+         statistic is reset during reconfiguration event.
+       </simpara>
+       </listitem>
+     </itemizedlist>
+     </para>
+ </section>
      <section id="dhcp4-std">
        <title>Supported DHCP Standards</title>
        <para>The following standards are currently supported:</para>
index a4bf19e8c0905e5a005940be7050337d4498ef38,83e6f6cdec55037650a643801483244d5d332597..b7bc4c2056475879b4c6e881e9573f92381c1258
@@@ -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
index ba954efed06402ad8f651ddb454494956f26d26d,afc2ea094f9cb900409045525a50ff594b374484..6e9ac795433856a5aab2b7dd76970119a01f117a
  #include <hooks/callout_handle.h>
  #include <hooks/hooks_log.h>
  #include <hooks/hooks_manager.h>
+ #include <stats/stats_mgr.h>
  #include <util/strutil.h>
 +#include <stats/stats_mgr.h>
 +#include <log/logger.h>
 +#include <cryptolink/cryptolink.h>
 +#include <cfgrpt/config_report.h>
  
  #include <asio.hpp>
  #include <boost/bind.hpp>
Simple merge
index 4a7f3b8ab5e2b57b89ab78a50332b53723e72b98,57e545e121e8de85951063475785455abe3d7676..f52a67992411b0bccb59415df833beb7ed5bbc26
@@@ -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<int64_t>(-1));
      }
  
      // Return the allocated lease or NULL pointer if allocation was
index 8602de997fb7c2e5ce466eb37bed23950f3d7b2f,a205dd11ef2983ecbe30f43baa64922b619b2673..6def4a1f057c7178fec55af8938d19bd6ce889c5
  // PERFORMANCE OF THIS SOFTWARE.
  
  #include <config.h>
 +#include <dhcp/pkt4.h>
  #include <dhcpsrv/tests/alloc_engine_utils.h>
  #include <dhcpsrv/tests/test_utils.h>
+ #include <stats/stats_mgr.h>
  
  using namespace std;
  using namespace isc::hooks;