-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The fourth part of the changes is to transfer counters to shared memory.
Added to the cli: - Getting bus statistics. - Getting the values of the main counters (having fixed names).
- Loading branch information
Showing
9 changed files
with
249 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
autotest/units/001_one_port/075_counters_shared_memory/autotest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
steps: | ||
- cli: "telegraf counters" | ||
- cli: "telegraf bus" | ||
- cli: "bus errors" | ||
- cli: "bus requests" |
32 changes: 32 additions & 0 deletions
32
autotest/units/001_one_port/075_counters_shared_memory/controlplane.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"modules": { | ||
"lp0.100": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "100", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "vrf0" | ||
}, | ||
"lp0.200": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "200", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "vrf0" | ||
}, | ||
"vrf0": { | ||
"type": "route", | ||
"interfaces": { | ||
"kni0.100": { | ||
"nextModule": "lp0.100" | ||
}, | ||
"kni0.200": { | ||
"ipv4Prefix": "200.0.0.2/24", | ||
"neighborIPv4Address": "200.0.0.1", | ||
"neighborMacAddress": "00:00:00:11:11:11", | ||
"nextModule": "lp0.200" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#pragma once | ||
|
||
#include "helper.h" | ||
#include "influxdb_format.h" | ||
|
||
namespace bus | ||
{ | ||
|
||
using bus_request_info = std::tuple<std::string, uint64_t, uint64_t>; | ||
|
||
inline std::vector<bus_request_info> get_bus_requests(common::sdp::DataPlaneInSharedMemory& sdp_data) | ||
{ | ||
uint64_t* requests = common::sdp::ShiftBuffer<uint64_t*>(sdp_data.dataplane_data, sdp_data.metadata_bus.start_bus_requests); | ||
uint64_t* durations = common::sdp::ShiftBuffer<uint64_t*>(sdp_data.dataplane_data, sdp_data.metadata_bus.start_bus_durations); | ||
|
||
std::map<common::idp::requestType, std::string> names = { | ||
{common::idp::requestType::updateGlobalBase, "updateGlobalBase"}, | ||
{common::idp::requestType::updateGlobalBaseBalancer, "updateGlobalBaseBalancer"}, | ||
{common::idp::requestType::getGlobalBase, "getGlobalBase"}, | ||
{common::idp::requestType::getWorkerStats, "getWorkerStats"}, | ||
{common::idp::requestType::getSlowWorkerStats, "getSlowWorkerStats"}, | ||
{common::idp::requestType::get_worker_gc_stats, "get_worker_gc_stats"}, | ||
{common::idp::requestType::get_dregress_counters, "get_dregress_counters"}, | ||
{common::idp::requestType::get_ports_stats, "get_ports_stats"}, | ||
{common::idp::requestType::get_ports_stats_extended, "get_ports_stats_extended"}, | ||
{common::idp::requestType::getControlPlanePortStats, "getControlPlanePortStats"}, | ||
{common::idp::requestType::getPortStatsEx, "getPortStatsEx"}, | ||
{common::idp::requestType::getFragmentationStats, "getFragmentationStats"}, | ||
{common::idp::requestType::getFWState, "getFWState"}, | ||
{common::idp::requestType::getFWStateStats, "getFWStateStats"}, | ||
{common::idp::requestType::clearFWState, "clearFWState"}, | ||
{common::idp::requestType::getConfig, "getConfig"}, | ||
{common::idp::requestType::getErrors, "getErrors"}, | ||
{common::idp::requestType::getReport, "getReport"}, | ||
{common::idp::requestType::lpm4LookupAddress, "lpm4LookupAddress"}, | ||
{common::idp::requestType::lpm6LookupAddress, "lpm6LookupAddress"}, | ||
{common::idp::requestType::nat64stateful_state, "nat64stateful_state"}, | ||
{common::idp::requestType::balancer_connection, "balancer_connection"}, | ||
{common::idp::requestType::balancer_service_connections, "balancer_service_connections"}, | ||
{common::idp::requestType::balancer_real_connections, "balancer_real_connections"}, | ||
{common::idp::requestType::limits, "limits"}, | ||
{common::idp::requestType::samples, "samples"}, | ||
{common::idp::requestType::debug_latch_update, "debug_latch_update"}, | ||
{common::idp::requestType::unrdup_vip_to_balancers, "unrdup_vip_to_balancers"}, | ||
{common::idp::requestType::update_vip_vport_proto, "update_vip_vport_proto"}, | ||
{common::idp::requestType::version, "version"}, | ||
{common::idp::requestType::get_shm_info, "get_shm_info"}, | ||
{common::idp::requestType::get_shm_tsc_info, "get_shm_tsc_info"}, | ||
{common::idp::requestType::set_shm_tsc_state, "set_shm_tsc_state"}, | ||
{common::idp::requestType::dump_physical_port, "dump_physical_port"}, | ||
{common::idp::requestType::balancer_state_clear, "balancer_state_clear"}, | ||
{common::idp::requestType::neighbor_show, "neighbor_show"}, | ||
{common::idp::requestType::neighbor_insert, "neighbor_insert"}, | ||
{common::idp::requestType::neighbor_remove, "neighbor_remove"}, | ||
{common::idp::requestType::neighbor_clear, "neighbor_clear"}, | ||
{common::idp::requestType::neighbor_flush, "neighbor_flush"}, | ||
{common::idp::requestType::neighbor_update_interfaces, "neighbor_update_interfaces"}, | ||
{common::idp::requestType::neighbor_stats, "neighbor_stats"}, | ||
{common::idp::requestType::memory_manager_update, "memory_manager_update"}, | ||
{common::idp::requestType::memory_manager_stats, "memory_manager_stats"}}; | ||
|
||
std::vector<bus_request_info> result; | ||
for (uint32_t index = 0; index < (uint32_t)common::idp::requestType::size; ++index) | ||
{ | ||
if ((requests[index] != 0) || (durations[index] != 0)) | ||
{ | ||
const auto& iter = names.find(static_cast<common::idp::requestType>(index)); | ||
result.emplace_back((iter != names.end() ? iter->second : "unknown"), requests[index], durations[index]); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
inline void bus_requests() | ||
{ | ||
common::sdp::DataPlaneInSharedMemory sdp_data; | ||
OpenSharedMemoryDataplaneBuffers(sdp_data, false); | ||
auto requests = get_bus_requests(sdp_data); | ||
|
||
table_t table; | ||
table.insert("request", "count", "duration_ms"); | ||
for (const auto& [request, count, duration] : requests) | ||
{ | ||
if ((count != 0) || (duration != 0)) | ||
{ | ||
table.insert(request, count, duration); | ||
} | ||
} | ||
|
||
table.print(); | ||
} | ||
|
||
inline std::vector<std::pair<std::string, uint64_t>> get_bus_errors(common::sdp::DataPlaneInSharedMemory& sdp_data) | ||
{ | ||
uint64_t* buffer = common::sdp::ShiftBuffer<uint64_t*>(sdp_data.dataplane_data, sdp_data.metadata_bus.start_bus_errors); | ||
|
||
std::map<common::idp::errorType, std::string> names = { | ||
{common::idp::errorType::busRead, "busRead"}, | ||
{common::idp::errorType::busWrite, "busWrite"}, | ||
{common::idp::errorType::busParse, "busParse"}, | ||
}; | ||
|
||
std::vector<std::pair<std::string, uint64_t>> result; | ||
for (uint32_t index = 0; index < (uint32_t)common::idp::errorType::size; ++index) | ||
{ | ||
const auto& iter = names.find(static_cast<common::idp::errorType>(index)); | ||
result.emplace_back((iter != names.end() ? iter->second : "unknown"), buffer[index]); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
inline void bus_errors() | ||
{ | ||
common::sdp::DataPlaneInSharedMemory sdp_data; | ||
OpenSharedMemoryDataplaneBuffers(sdp_data, false); | ||
auto errors = get_bus_errors(sdp_data); | ||
|
||
table_t table; | ||
table.insert("error", "count"); | ||
for (const auto& [error, count] : errors) | ||
{ | ||
table.insert(error, count); | ||
} | ||
|
||
table.print(); | ||
} | ||
|
||
inline void bus_telegraf() | ||
{ | ||
common::sdp::DataPlaneInSharedMemory sdp_data; | ||
OpenSharedMemoryDataplaneBuffers(sdp_data, false); | ||
|
||
auto errors = get_bus_errors(sdp_data); | ||
std::vector<influxdb_format::value_t> infl_errors; | ||
for (const auto& [error, count] : errors) | ||
{ | ||
infl_errors.emplace_back(error.data(), count); | ||
} | ||
influxdb_format::print("bus_errors", {}, infl_errors); | ||
|
||
auto requests = get_bus_requests(sdp_data); | ||
if (!requests.empty()) | ||
{ | ||
std::vector<influxdb_format::value_t> infl_counts; | ||
std::vector<influxdb_format::value_t> infl_durations; | ||
for (const auto& [request, count, duration] : requests) | ||
{ | ||
infl_counts.emplace_back(request.data(), count); | ||
infl_durations.emplace_back(request.data(), duration); | ||
} | ||
influxdb_format::print("bus_counts", {}, infl_counts); | ||
influxdb_format::print("bus_durations", {}, infl_durations); | ||
} | ||
} | ||
|
||
} // namespace bus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters