lease_file_stats.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #ifndef LEASE_FILE_STATS_H
  7. #define LEASE_FILE_STATS_H
  8. namespace isc {
  9. namespace dhcp {
  10. /// @brief Provides statistics for leases.
  11. ///
  12. /// This class provides a common space for statistics that we wish
  13. /// to keep about leases. Currently this is for use with lease files
  14. /// but it may be expanded in the future.
  15. class LeaseFileStats {
  16. public:
  17. /// @brief Constructor
  18. ///
  19. /// Initializes the stats variables to zeros
  20. LeaseFileStats() {
  21. clearStatistics();
  22. }
  23. /// @brief Destructor
  24. ~LeaseFileStats() {
  25. }
  26. /// @brief Gets the number of attempts to read a lease
  27. uint32_t getReads() const {
  28. return (reads_);
  29. }
  30. /// @brief Gets the number of leases read
  31. uint32_t getReadLeases() const {
  32. return (read_leases_);
  33. }
  34. /// @brief Gets the number of errors when reading leases
  35. uint32_t getReadErrs() const {
  36. return (read_errs_);
  37. }
  38. /// @brief Gets the number of attempts to write a lease
  39. uint32_t getWrites() const {
  40. return (writes_);
  41. }
  42. /// @brief Gets the number of leases written
  43. uint32_t getWriteLeases() const {
  44. return (write_leases_);
  45. }
  46. /// @brief Gets the number of errors when writting leases
  47. uint32_t getWriteErrs() const {
  48. return (write_errs_);
  49. }
  50. /// @brief Clears the statistics
  51. void clearStatistics() {
  52. reads_ = 0;
  53. read_leases_ = 0;
  54. read_errs_ = 0;
  55. writes_ = 0;
  56. write_leases_ = 0;
  57. write_errs_ = 0;
  58. }
  59. protected:
  60. /// @brief Number of attempts to read a lease
  61. uint32_t reads_;
  62. /// @brief Number of leases read
  63. uint32_t read_leases_;
  64. /// @brief Number of errors when reading
  65. uint32_t read_errs_;
  66. /// @brief Number of attempts to write a lease
  67. uint32_t writes_;
  68. /// @brief Number of lease written
  69. uint32_t write_leases_;
  70. /// @brief Number of errors when writing
  71. uint32_t write_errs_;
  72. };
  73. } // namespace isc::dhcp
  74. } // namesapce isc
  75. #endif // LEASE_FILE_STATS_H