7#ifndef _MONITORED_DURATION_H
8#define _MONITORED_DURATION_H
13#include <boost/date_time/posix_time/posix_time.hpp>
19typedef boost::posix_time::time_duration
Duration;
29 static Duration duration(boost::posix_time::microseconds(0));
60 start_time_ = start_time;
68 return (occurrences_);
75 return (min_duration_);
82 return (max_duration_);
89 return (total_duration_);
111 uint64_t occurrences_;
142 DurationKey(uint16_t family, uint8_t query_type, uint8_t response_type,
143 const std::string& start_event_label,
const std::string& stop_event_label,
245 std::string
getStatName(
const std::string& value_name)
const;
255 static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type);
316 const std::string& start_event_label,
const std::string& stop_event_label,
337 return (interval_duration_);
344 return (previous_interval_);
351 return (current_interval_);
static boost::posix_time::ptime now()
Fetch the current UTC system time, microsecond precision.
Embodies a span of time (i.e.
void setStartTime(const Timestamp &start_time)
Set the interval start time.
Duration getMaxDuration() const
Get the maximum duration that has occurred in the interval.
Duration getTotalDuration() const
Get the total duration in the interval.
static const Duration & ZERO_DURATION()
Get a duration of zero.
bool operator==(const DurationDataInterval &other) const
Equality operator.
Duration getAverageDuration() const
Get the average duration for the interval.
const Timestamp & getStartTime() const
Get the start time of the interval.
~DurationDataInterval()=default
Destructor.
uint64_t getOccurrences() const
Get the number of occurrences that have contributed to the interval.
Duration getMinDuration() const
Get the minimum duration that has occurred in the interval.
void addDuration(const Duration &duration)
Add a duration to the interval.
Houses the composite key that uniquely identifies a duration:
bool operator!=(const DurationKey &other) const
Inequality operator.
isc::dhcp::SubnetID subnet_id_
Subnet ID of the subnet selected during query fulfillment.
static std::string getMessageTypeLabel(uint16_t family, uint16_t msg_type)
Get a label for a family-specific message type (e.g.
uint8_t response_type_
Response message type (e.g. DHCPOFFER, DHCP6_ADVERTISE).
bool operator<(const DurationKey &other) const
Less than operator.
std::string getStartEventLabel() const
Get the start event label.
std::string start_event_label_
Label of the start event which begins the duration.
std::string getStopEventLabel() const
Get the end event label.
bool operator==(const DurationKey &other) const
Equality operator.
uint16_t getFamily()
Get protocol family.
uint8_t getResponseType() const
Get the response packet type.
uint16_t family_
Protocol family AF_INET or AF_INET6.
std::string getStatName(const std::string &value_name) const
Get the StatsMgr formatted compatible name.
dhcp::SubnetID getSubnetId() const
Get the subnet id.
static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type)
Validates that a query and response message type pair is sane.
std::string stop_event_label_
Label of the end event which ends the duration.
uint8_t getQueryType() const
Get the query packet type.
void setSubnetId(dhcp::SubnetID subnet_id)
Set the subnet id.
virtual ~DurationKey()=default
Destructor.
std::string getLabel() const
Get a composite label of the member values with text message types.
uint8_t query_type_
Query message type (e.g. DHCPDISCOVER, DHCP6_SOLICIT).
Timestamp getCurrentIntervalStart() const
Get the current interval start time.
virtual ~MonitoredDuration()=default
Destructor.
bool addSample(const Duration &sample)
Add a sample to the duration's current interval.
Duration getIntervalDuration() const
Get the interval duration.
DurationDataIntervalPtr getCurrentInterval() const
Get the current interval.
void expireCurrentInterval()
Concludes the current interval.
void clear()
Deletes the current and previous intervals.
DurationDataIntervalPtr getPreviousInterval() const
Get the previous interval.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::posix_time::time_duration Duration
boost::shared_ptr< DurationKey > DurationKeyPtr
Defines a pointer to a DurationKey instance.
boost::shared_ptr< DurationDataInterval > DurationDataIntervalPtr
Defines a pointer to a DurationDataInterval instance.
boost::posix_time::ptime Timestamp
std::ostream & operator<<(std::ostream &os, const DurationKey &key)
boost::shared_ptr< MonitoredDuration > MonitoredDurationPtr
Defines the logger used by the top-level component of kea-lfc.