ElementPtr
DurationKey::toElement() const {
ElementPtr element = Element::createMap();
- element->set("subnet-id", Element::create(static_cast<long long>(subnet_id_)));
element->set("query-type", Element::create(getMessageTypeLabel(family_, query_type_)));
element->set("response-type", Element::create(getMessageTypeLabel(family_, response_type_)));
element->set("start-event", Element::create(start_event_label_));
element->set("stop-event", Element::create(stop_event_label_));
+ element->set("subnet-id", Element::create(static_cast<long long>(subnet_id_)));
return (element);
}
element->set("min-duration-usecs", Element::create(previous_interval_->getMinDuration().total_microseconds()));
element->set("max-duration-usecs", Element::create(previous_interval_->getMaxDuration().total_microseconds()));
element->set("total-duration-usecs", Element::create(previous_interval_->getTotalDuration().total_microseconds()));
+ element->set("ave-duration-usecs", Element::create(previous_interval_->getAverageDuration().total_microseconds()));
} else {
element->set("start-time", Element::create("<none>"));
element->set("occurrences", Element::create(0));
element->set("min-duration-usecs", Element::create(0));
element->set("max-duration-usecs", Element::create(0));
element->set("total-duration-usecs", Element::create(0));
+ element->set("ave-duration-usecs", Element::create(0));
}
return (element);
}
+ConstElementPtr
+MonitoredDuration::valueRowColumns() {
+ static std::list<std::string> column_labels{
+ "query-type",
+ "response-type",
+ "start-event",
+ "end-event",
+ "subnet-id",
+ "interval-start",
+ "occurences",
+ "min-duration-usecs",
+ "max-duration-usecs",
+ "total-duration-usecs"
+ "ave-duration-usecs"
+ };
+
+ static ElementPtr cols;
+ if (!cols) {
+ // Create the list of column names and add it to the result set.
+ cols = Element::createList();
+ for (auto const& label : column_labels) {
+ cols->add(Element::create(label));
+ }
+ }
+
+ return(cols);
+}
+
+ElementPtr
+MonitoredDuration::toValueRow() const {
+ // Create the value row.
+ ElementPtr row = Element::createList();
+
+ // Add key values.
+ row->add(Element::create(getMessageTypeLabel(family_, query_type_)));
+ row->add(Element::create(getMessageTypeLabel(family_, response_type_)));
+ row->add(Element::create(start_event_label_));
+ row->add(Element::create(stop_event_label_));
+ row->add(Element::create(static_cast<long long>(subnet_id_)));
+
+ // Add interval data values.
+ if (previous_interval_) {
+ row->add(Element::create(ptimeToText(previous_interval_->getStartTime())));
+ row->add(Element::create(static_cast<long long>(previous_interval_->getOccurrences())));
+ row->add(Element::create(previous_interval_->getMinDuration().total_microseconds()));
+ row->add(Element::create(previous_interval_->getMaxDuration().total_microseconds()));
+ row->add(Element::create(previous_interval_->getTotalDuration().total_microseconds()));
+ row->add(Element::create(previous_interval_->getAverageDuration().total_microseconds()));
+ } else {
+ row->add(Element::create("<none>"));
+ row->add(Element::create(0));
+ row->add(Element::create(0));
+ row->add(Element::create(0));
+ row->add(Element::create(0));
+ row->add(Element::create(0));
+ }
+
+ return (row);
+}
+
} // end of namespace perfmon
} // end of namespace isc
/// "occurrences": 105,
/// "min-duration-usecs": 5300,
/// "max-duration-usecs": 9000,
- /// "total-duration-usecs": 786500
+ /// "total-duration-usecs": 786500,
+ /// "ave-duration-usecs": 7490
/// }
/// @endcode
///
/// "occurrences": 0,
/// "min-duration-usecs": 0,
/// "max-duration-usecs": 0,
- /// "total-duration-usecs": 0
+ /// "total-duration-usecs": 0,
+ /// "ave-duration-usecs": 0
/// }
/// @endcode
///
/// @return Element::map containing the duration key values.
virtual data::ElementPtr toElement() const;
+ /// @brief Fetches a an Element::list of value row column names
+ ///
+ /// The list element includes the name of each column in a value row, in
+ /// the order the values are stored in a value row.
+ ///
+ /// The values in the list in order are:
+ ///
+ /// -# "query-type"
+ /// -# "response-type"
+ /// -# "start-event"
+ /// -# "stop-event"
+ /// -# "subnet-id"
+ /// -# "start-time"
+ /// -# "occurrences"
+ /// -# "min-duration-usecs"
+ /// -# "max-duration-usecs"
+ /// -# "total-duration-usecs"
+ /// -# "ave-duration-usecs"
+ ///
+ /// @return Element::map containing the duration key values.
+ static data::ConstElementPtr valueRowColumns();
+
+ /// @brief Renders the the duration as an Element::list of values.
+ ///
+ /// The list element includes a value for each member of DurationKey
+ /// and the previous interval. If there is no previous interval value of
+ /// of "<none>" will be added for start-time and values of 0 for the
+ /// remaining data values.
+ ///
+ /// The values in the list will be in the following order and type:
+ ///
+ /// -# query-type Element::string
+ /// -# response-type Element::string
+ /// -# start-event Element::string
+ /// -# stop-event Element::string
+ /// -# subnet-id Element::int
+ /// -# start-time Element::string ex: "2024-01-18 10:11:19.498739" or "<none>",
+ /// -# occurrences Element::int
+ /// -# min-duration-usecs Element::int
+ /// -# max-duration-usecs Element::int
+ /// -# total-duration-usecs Element::int
+ /// -# ave-duration-usecs Element::int
+ ///
+ /// @return Element::map containing the duration key values.
+ data::ElementPtr toValueRow() const;
+
private:
/// @brief Length of the time of a single data interval.
Duration interval_duration_;
}
ElementPtr
-PerfMonMgr::formatDurationDataAsResultSet(MonitoredDurationCollectionPtr /*durations */) const{
- isc_throw (NotImplemented, "Not Implemented - " << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__);
-#if 0
+PerfMonMgr::formatDurationDataAsResultSet(MonitoredDurationCollectionPtr durations) const{
// Create the result-set map and add it to the wrapper.
ElementPtr result_set = Element::createMap();
- result_wrapper->set("result-set", result_set);
// Create the list of column names and add it to the result set.
- ElementPtr columns = Element::createList();
- for (auto const& label : column_labels) {
- columns->add(Element::create(label));
- }
- result_set->set("columns", columns);
+ result_set->set("columns", MonitoredDuration::valueRowColumns());
- // Create the empty value_rows list, add it and then return it.
- ElementPtr value_rows = Element::createList();
- result_set->set("rows", value_rows);
- if (durations.empty()) {
- return;
- }
+ // Create the rows list and add it to the result set.
+ ElementPtr rows = Element::createList();
+ result_set->set("rows", rows);
- return (value_rows);
- for (auto const& d : *durations) {
- const auto& reported_interval = d->getPreviousInterval();
- if (reported_interval) {
- std::string label = d->getLabel();
+ for (auto const& d : *durations) {
+ // Create the value row.
+ ElementPtr row = d->toValueRow();
+ rows->add(row);
+ }
- }
-#endif
+ return (result_set);
}
-
-
-
} // end of namespace perfmon
} // end of namespace isc