7#ifndef _MONITORED_DURATION_H
8#define _MONITORED_DURATION_H
15#include <boost/date_time/posix_time/posix_time.hpp>
21typedef boost::posix_time::time_duration
Duration;
31 static Duration duration(boost::posix_time::microseconds(0));
62 start_time_ = start_time;
70 return (occurrences_);
77 return (min_duration_);
84 return (max_duration_);
91 return (total_duration_);
113 uint64_t occurrences_;
144 DurationKey(uint16_t family, uint8_t query_type, uint8_t response_type,
145 const std::string& start_event_label,
const std::string& stop_event_label,
247 std::string
getStatName(
const std::string& value_name)
const;
274 static void validateMessagePair(uint16_t family, uint8_t query_type, uint8_t response_type);
335 const std::string& start_event_label,
const std::string& stop_event_label,
356 return (interval_duration_);
363 return (previous_interval_);
370 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 getMeanDuration() const
Get the mean duration for the interval.
Duration getMaxDuration() const
Get the maximum duration that has occurred in the interval.
DurationDataInterval(const Timestamp &start_time=dhcp::PktEvent::now())
Constructor.
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.
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.
virtual data::ElementPtr toElement() const
Renders the the duration key as an Element.
std::string getStopEventLabel() const
Get the end event label.
bool operator==(const DurationKey &other) const
Equality operator.
uint16_t getFamily()
Get protocol family.
DurationKey(uint16_t family, uint8_t query_type, uint8_t response_type, const std::string &start_event_label, const std::string &stop_event_label, dhcp::SubnetID subnet_id)
Constructor.
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).
virtual data::ElementPtr toElement() const
Renders the the duration as an Element.
data::ElementPtr toValueRow() const
Renders the the duration as an Element::list of values.
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.
MonitoredDuration(uint16_t family, uint8_t query_type, uint8_t response_type, const std::string &start_event_label, const std::string &stop_event_label, dhcp::SubnetID subnet_id, const Duration &interval_duration)
Constructor.
void clear()
Deletes the current and previous intervals.
DurationDataIntervalPtr getPreviousInterval() const
Get the previous interval.
static data::ConstElementPtr valueRowColumns()
Fetches a an Element::list of value row column names.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
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.
Abstract class for configuration Cfg_* classes.