lease_file_stats.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef LEASE_FILE_STATS_H
  15. #define LEASE_FILE_STATS_H
  16. namespace isc {
  17. namespace dhcp {
  18. /// @brief Provides statistics for leases.
  19. ///
  20. /// This class provides a common space for statistics that we wish
  21. /// to keep about leases. Currently this is for use with lease files
  22. /// but it may be expanded in the future.
  23. class LeaseFileStats {
  24. public:
  25. /// @brief Constructor
  26. ///
  27. /// Initializes the stats variables to zeros
  28. LeaseFileStats() {
  29. clearStatistics();
  30. }
  31. /// @brief Destructor
  32. ~LeaseFileStats() {
  33. }
  34. /// @brief Gets the number of attempts to read a lease
  35. uint32_t getReads() const {
  36. return (reads_);
  37. }
  38. /// @brief Gets the number of leases read
  39. uint32_t getReadLeases() const {
  40. return (read_leases_);
  41. }
  42. /// @brief Gets the number of errors when reading leases
  43. uint32_t getReadErrs() const {
  44. return (read_errs_);
  45. }
  46. /// @brief Gets the number of attempts to write a lease
  47. uint32_t getWrites() const {
  48. return (writes_);
  49. }
  50. /// @brief Gets the number of leases written
  51. uint32_t getWriteLeases() const {
  52. return (write_leases_);
  53. }
  54. /// @brief Gets the number of errors when writting leases
  55. uint32_t getWriteErrs() const {
  56. return (write_errs_);
  57. }
  58. /// @brief Clears the statistics
  59. void clearStatistics() {
  60. reads_ = 0;
  61. read_leases_ = 0;
  62. read_errs_ = 0;
  63. writes_ = 0;
  64. write_leases_ = 0;
  65. write_errs_ = 0;
  66. }
  67. protected:
  68. /// @brief Number of attempts to read a lease
  69. uint32_t reads_;
  70. /// @brief Number of leases read
  71. uint32_t read_leases_;
  72. /// @brief Number of errors when reading
  73. uint32_t read_errs_;
  74. /// @brief Number of attempts to write a lease
  75. uint32_t writes_;
  76. /// @brief Number of lease written
  77. uint32_t write_leases_;
  78. /// @brief Number of errors when writing
  79. uint32_t write_errs_;
  80. };
  81. } // namespace isc::dhcp
  82. } // namesapce isc
  83. #endif // LEASE_FILE_STATS_H