Skip to content

Commit

Permalink
Merge pull request #336 from s41m0n/dynmon/fix_metrics
Browse files Browse the repository at this point in the history
fix Dynmon empty-on-read percpu
  • Loading branch information
frisso authored Sep 24, 2020
2 parents 9d9115c + f5acbff commit 8bd4c5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
20 changes: 9 additions & 11 deletions src/services/pcn-dynmon/src/Dynmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ std::shared_ptr<Metrics> Dynmon::getMetrics() {

{
std::lock_guard<std::mutex> lock_in(m_ingressPathMutex);
std::lock_guard<std::mutex> lock_eg(m_egressPathMutex);
triggerReadEgress();
triggerReadIngress();
auto ingressMetricConfigs =
m_dpConfig->getIngressPathConfig()->getMetricConfigsList();
Expand All @@ -212,10 +214,7 @@ std::shared_ptr<Metrics> Dynmon::getMetrics() {
logger()->warn("Unable to read {0} map", it->getMapName());
}
}
}
{
std::lock_guard<std::mutex> lock_eg(m_egressPathMutex);
triggerReadEgress();

auto egressMetricConfigs =
m_dpConfig->getEgressPathConfig()->getMetricConfigsList();

Expand Down Expand Up @@ -338,9 +337,14 @@ std::string Dynmon::getOpenMetrics() {
std::vector<std::string> metrics;
auto ingressMetricConfigs =
m_dpConfig->getIngressPathConfig()->getMetricConfigsList();
auto egressMetricConfigs =
m_dpConfig->getEgressPathConfig()->getMetricConfigsList();

std::lock_guard<std::mutex> lock_in(m_ingressPathMutex);
std::lock_guard<std::mutex> lock_eg(m_egressPathMutex);
triggerReadIngress();
triggerReadEgress();


// Extracting all metrics from the egress path
for (auto &it : ingressMetricConfigs) {
Expand All @@ -357,14 +361,8 @@ std::string Dynmon::getOpenMetrics() {
}
}
in_metrics = Utils::join(metrics, "\n");
}
{
std::vector<std::string> metrics;
auto egressMetricConfigs =
m_dpConfig->getEgressPathConfig()->getMetricConfigsList();

std::lock_guard<std::mutex> lock_eg(m_egressPathMutex);
triggerReadEgress();
metrics.clear();

// Extracting all metrics from the egress path
for (auto &it : egressMetricConfigs) {
Expand Down
9 changes: 7 additions & 2 deletions src/services/pcn-dynmon/src/extractor/MapExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,13 @@ json MapExtractor::extractFromPerCPUMap(const TableDesc &desc, RawTable table,
last_key = entry.getKey();
table.get(entry.getKey(), entry.getValue());
entries.push_back(std::make_shared<MapEntry>(entry));
if(extractionOptions->getEmptyOnRead())
table.set(last_key, reset_value.getValue());
if(extractionOptions->getEmptyOnRead()) {
if(desc.type == BPF_MAP_TYPE_PERCPU_ARRAY) {
table.set(last_key, reset_value.getValue());
} else {
table.remove(last_key);
}
}
} else
break;
}
Expand Down

0 comments on commit 8bd4c5c

Please sign in to comment.