aboutsummaryrefslogtreecommitdiffstats
path: root/telemetry/vpp-collectd
diff options
context:
space:
mode:
Diffstat (limited to 'telemetry/vpp-collectd')
-rw-r--r--telemetry/vpp-collectd/CMakeLists.txt24
-rw-r--r--telemetry/vpp-collectd/cmake/Modules/Packaging.cmake31
-rw-r--r--telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt94
-rw-r--r--telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c196
-rw-r--r--telemetry/vpp-collectd/vpp/CMakeLists.txt73
-rw-r--r--telemetry/vpp-collectd/vpp/vpp.c123
6 files changed, 186 insertions, 355 deletions
diff --git a/telemetry/vpp-collectd/CMakeLists.txt b/telemetry/vpp-collectd/CMakeLists.txt
index ef09fb980..4ce357f63 100644
--- a/telemetry/vpp-collectd/CMakeLists.txt
+++ b/telemetry/vpp-collectd/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021-2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -11,20 +11,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+##############################################################
+# Dependencies
+##############################################################
+find_package(Vpp ${VPP_DEFAULT_VERSION} REQUIRED)
-set (COLLECTD_PLUGINS hicn-collectd-plugins)
-project(hicn-collectd-plugins)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Modules/")
+##############################################################
+# Compiler Options
+##############################################################
+set(COMPILER_OPTIONS
+ ${DEFAULT_COMPILER_OPTIONS}
+)
-include(BuildMacros)
+##############################################################
+# Subdirectories
+##############################################################
add_subdirectory(vpp)
add_subdirectory(vpp-hicn)
-include(Packaging)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
- include(Packager)
- make_packages()
+ make_packages()
endif()
diff --git a/telemetry/vpp-collectd/cmake/Modules/Packaging.cmake b/telemetry/vpp-collectd/cmake/Modules/Packaging.cmake
deleted file mode 100644
index dc4629a26..000000000
--- a/telemetry/vpp-collectd/cmake/Modules/Packaging.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-######################
-# Packages section
-######################
-
-set(${COLLECTD_PLUGINS}_DESCRIPTION
- "A high-performance Hybrid ICN forwarder as a plugin to VPP."
- CACHE STRING "Description for deb/rpm package."
-)
-
-set(${COLLECTD_PLUGINS}_DEB_DEPENDENCIES
- "collectd, hicn-plugin-dev"
- CACHE STRING "Dependencies for deb/rpm package."
-)
-
-set(${COLLECTD_PLUGINS}_RPM_DEPENDENCIES
- "collectd, hicn-plugin-dev"
- CACHE STRING "Dependencies for deb/rpm package."
-) \ No newline at end of file
diff --git a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
index fc39b9385..85dd51577 100644
--- a/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
+++ b/telemetry/vpp-collectd/vpp-hicn/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021-2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -11,45 +11,63 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
+##############################################################
# Dependencies
-find_package(Collectd REQUIRED)
-find_package(Vpp REQUIRED)
-
-if(${CMAKE_SOURCE_DIR}/vpp-collectd STREQUAL ${PROJECT_SOURCE_DIR})
- message (STATUS "not compiling in the same folder")
- find_package(HicnPlugin REQUIRED)
- find_package(VapiSafe REQUIRED)
-else()
- message (STATUS "compiling in the same folder")
- list(APPEND DEPENDENCIES
- hicn_plugin
- )
-endif()
+##############################################################
+find_package(HicnPlugin ${CURRENT_VERSION} REQUIRED)
+find_package(Libsafevapi ${CURRENT_VERSION} REQUIRED NO_MODULE)
+
+##############################################################
+# Source files
+##############################################################
list(APPEND SOURCE_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/vpp_hicn.c
)
-list (APPEND INCLUDE_DIRS
- ${COLLECTD_INCLUDE_DIRS}
- ${HICNPLUGIN_INCLUDE_DIRS}
- ${SAFE_VAPI_INCLUDE_DIRS}
- ${VPP_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR})
-
-list (APPEND LIBRARIES
- ${VPP_LIBRARY_VAPICLIENT}
- ${SAFE_VAPI_LIBRARIES})
-
-build_library(vpp_hicn
- SHARED
- SOURCES ${SOURCE_FILES}
- LINK_LIBRARIES ${LIBRARIES}
- INCLUDE_DIRS ${INCLUDE_DIRS}
- INSTALL_FULL_PATH_DIR ${CMAKE_INSTALL_PREFIX}/lib/collectd
- COMPONENT "${COLLECTD_PLUGINS}"
- DEPENDS ${DEPENDENCIES}
- EMPTY_PREFIX true
- )
+
+##############################################################
+# Include dirs
+##############################################################
+list(APPEND INCLUDE_DIRS
+ ${COLLECTD_INCLUDE_DIRS}
+ ${THIRD_PARTY_INCLUDE_DIRS}
+ ${HICNPLUGIN_INCLUDE_DIRS}
+ ${Libsafe_vapi_INCLUDE_DIRS}
+ ${VPP_INCLUDE_DIRS}
+)
+
+
+##############################################################
+# Libraries
+##############################################################
+list(APPEND LIBRARIES
+ ${VPP_LIBRARY_VAPICLIENT}
+ hicn::safevapi.shared
+)
+
+
+##############################################################
+# Compiler options
+##############################################################
+list(APPEND COMPILER_OPTIONS
+ ${DEFAULT_COMPILER_OPTIONS}
+ ${COLLECTD_COMPILER_OPTIONS}
+)
+
+
+##############################################################
+# Build library
+##############################################################
+build_library(${VPP_HICN_TELEMETRY}
+ SHARED
+ EMPTY_PREFIX
+ SOURCES ${SOURCE_FILES}
+ LINK_LIBRARIES ${LIBRARIES}
+ INCLUDE_DIRS
+ PRIVATE ${INCLUDE_DIRS}
+ INSTALL_FULL_PATH_DIR ${COLLECTD_PLUGIN_DIR}
+ COMPONENT ${COLLECTD_PLUGINS}
+ DEPENDS ${DEPENDENCIES}
+ COMPILE_OPTIONS ${COMPILER_OPTIONS}
+)
diff --git a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
index 591b8f584..a20bcbcd0 100644
--- a/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
+++ b/telemetry/vpp-collectd/vpp-hicn/vpp_hicn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -13,30 +13,14 @@
* limitations under the License.
*/
-#if !HAVE_CONFIG_H
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef __USE_ISOC99 /* required for NAN */
-#define DISABLE_ISOC99 1
-#define __USE_ISOC99 1
-#endif /* !defined(__USE_ISOC99) */
-
-#if DISABLE_ISOC99
-#undef DISABLE_ISOC99
-#undef __USE_ISOC99
-#endif /* DISABLE_ISOC99 */
-#endif /* ! HAVE_CONFIG */
-
-/* Keep order as it is */
-#include <config.h>
-#include <collectd.h>
-#include <common.h>
-#include <plugin.h>
+#include "../../data_model.h"
+#include "collectd.h"
+#include "plugin.h"
+#include "utils/common/common.h"
#define counter_t vpp_counter_t
+#include <hicn/vapi/vapi_safe.h>
#include <vapi/hicn.api.vapi.h>
-#include <vapi/vapi_safe.h>
#undef counter_t
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
@@ -51,144 +35,9 @@ static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static bool verbose = false;
static char *tag = NULL;
-/************** DATA SOURCES ******************************/
-static data_source_t packets_dsrc[1] = {
- {"packets", DS_TYPE_GAUGE, 0, NAN},
-};
-
-static data_source_t interests_dsrc[1] = {
- {"interests", DS_TYPE_GAUGE, 0, NAN},
-};
-
-static data_source_t data_dsrc[1] = {
- {"data", DS_TYPE_GAUGE, 0, NAN},
-};
-
-static data_source_t combined_dsrc[2] = {
- {"packets", DS_TYPE_DERIVE, 0, NAN},
- {"bytes", DS_TYPE_DERIVE, 0, NAN},
-};
-
-/************** DATA SETS NODE ****************************/
-static data_set_t pkts_processed_ds = {
- "pkts_processed",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t pkts_interest_count_ds = {
- "pkts_interest_count",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t pkts_data_count_ds = {
- "pkts_data_count",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t pkts_from_cache_count_ds = {
- "pkts_from_cache_count",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t pkts_no_pit_count_ds = {
- "pkts_no_pit_count",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t pit_expired_count_ds = {
- "pit_expired_count",
- STATIC_ARRAY_SIZE(interests_dsrc),
- interests_dsrc,
-};
-
-static data_set_t cs_expired_count_ds = {
- "cs_expired_count",
- STATIC_ARRAY_SIZE(data_dsrc),
- data_dsrc,
-};
-
-static data_set_t cs_lru_count_ds = {
- "cs_lru_count",
- STATIC_ARRAY_SIZE(data_dsrc),
- data_dsrc,
-};
-
-static data_set_t pkts_drop_no_buf_ds = {
- "pkts_drop_no_buf",
- STATIC_ARRAY_SIZE(packets_dsrc),
- packets_dsrc,
-};
-
-static data_set_t interests_aggregated_ds = {
- "interests_aggregated",
- STATIC_ARRAY_SIZE(interests_dsrc),
- interests_dsrc,
-};
-
-static data_set_t interests_retx_ds = {
- "interests_retx",
- STATIC_ARRAY_SIZE(interests_dsrc),
- interests_dsrc,
-};
-
-static data_set_t interests_hash_collision_ds = {
- "interests_hash_collision",
- STATIC_ARRAY_SIZE(interests_dsrc),
- interests_dsrc,
-};
-
-static data_set_t pit_entries_count_ds = {
- "pit_entries_count",
- STATIC_ARRAY_SIZE(interests_dsrc),
- interests_dsrc,
-};
-
-static data_set_t cs_entries_count_ds = {
- "cs_entries_count",
- STATIC_ARRAY_SIZE(data_dsrc),
- data_dsrc,
-};
-
-static data_set_t cs_entries_ntw_count_ds = {
- "cs_entries_ntw_count",
- STATIC_ARRAY_SIZE(data_dsrc),
- data_dsrc,
-};
-
-/************** DATA SETS FACE ****************************/
-static data_set_t irx_ds = {
- "irx",
- STATIC_ARRAY_SIZE(combined_dsrc),
- combined_dsrc,
-};
-
-static data_set_t itx_ds = {
- "itx",
- STATIC_ARRAY_SIZE(combined_dsrc),
- combined_dsrc,
-};
-
-static data_set_t drx_ds = {
- "drx",
- STATIC_ARRAY_SIZE(combined_dsrc),
- combined_dsrc,
-};
-
-static data_set_t dtx_ds = {
- "dtx",
- STATIC_ARRAY_SIZE(combined_dsrc),
- combined_dsrc,
-};
-
/**********************************************************/
/********** UTILITY FUNCTIONS *****************************/
/**********************************************************/
-
/*
* Utility function used by the read callback to populate a
* value_list_t and pass it to plugin_dispatch_values.
@@ -207,8 +56,7 @@ static int submit(const char *plugin_instance, const char *type,
sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, type, sizeof(vl.type));
- if (tag != NULL)
- sstrncpy(vl.type_instance, tag, sizeof(vl.type_instance));
+ if (tag != NULL) sstrncpy(vl.type_instance, tag, sizeof(vl.type_instance));
return plugin_dispatch_values(&vl);
}
@@ -216,7 +64,6 @@ static int submit(const char *plugin_instance, const char *type,
/**********************************************************/
/********** CALLBACK FUNCTIONS ****************************/
/**********************************************************/
-
/*
* This function is called for each configuration item.
*/
@@ -242,15 +89,12 @@ static int vpp_hicn_config(const char *key, const char *value) {
/*
* Callback called by the hICN plugin API when node stats are ready.
*/
-static vapi_error_e
-parse_node_stats(vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_node_stats_get_reply *reply) {
- if (reply == NULL || rv != VAPI_OK)
- return rv;
+static vapi_error_e parse_node_stats(
+ vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_node_stats_get_reply *reply) {
+ if (reply == NULL || rv != VAPI_OK) return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
+ if (reply->retval != VAPI_OK) return reply->retval;
char *node_name = "node";
value_t values[1];
@@ -296,15 +140,12 @@ parse_node_stats(vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv,
/*
* Callback called by the hICN plugin API when face stats are ready.
*/
-static vapi_error_e
-parse_face_stats(vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_face_stats_details *reply) {
- if (reply == NULL || rv != VAPI_OK)
- return rv;
+static vapi_error_e parse_face_stats(
+ vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_face_stats_details *reply) {
+ if (reply == NULL || rv != VAPI_OK) return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
+ if (reply->retval != VAPI_OK) return reply->retval;
char face_name[10];
snprintf(face_name, 10, "face%u", reply->faceid);
@@ -333,8 +174,7 @@ parse_face_stats(vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv,
static int vpp_hicn_init(void) {
int ret = vapi_connect_safe(&vapi_ctx, 0);
- if (ret)
- plugin_log(LOG_ERR, "vpp_hicn plugin: vapi_connect_safe failed");
+ if (ret) plugin_log(LOG_ERR, "vpp_hicn plugin: vapi_connect_safe failed");
return ret;
}
diff --git a/telemetry/vpp-collectd/vpp/CMakeLists.txt b/telemetry/vpp-collectd/vpp/CMakeLists.txt
index 36248b17a..e1cf55553 100644
--- a/telemetry/vpp-collectd/vpp/CMakeLists.txt
+++ b/telemetry/vpp-collectd/vpp/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021-2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -11,32 +11,53 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+##############################################################
+# Sources
+##############################################################
+list(APPEND SOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c
+)
-# Dependencies
-list(APPEND SOURCE_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c
+##############################################################
+# Include dirs
+##############################################################
+list(APPEND INCLUDE_DIRS
+ ${COLLECTD_INCLUDE_DIRS}
+ ${THIRD_PARTY_INCLUDE_DIRS}
+ ${VPP_INCLUDE_DIRS}
+)
+
+
+##############################################################
+# Libraries
+##############################################################
+list(APPEND LIBRARIES
+ ${VPP_LIBRARY_VPPAPICLIENT}
+ ${VPP_LIBRARY_INFRA}
)
-find_package(Vpp REQUIRED)
-find_package(Collectd REQUIRED)
-
-list (APPEND INCLUDE_DIRS
- ${COLLECTD_INCLUDE_DIRS}
- ${VPP_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR})
-
-list (APPEND LIBRARIES
- ${VPP_LIBRARY_VPPAPICLIENT}
- ${VPP_LIBRARY_INFRA})
-
-build_library(vpp
- SHARED
- SOURCES ${SOURCE_FILES}
- LINK_LIBRARIES ${LIBRARIES}
- INCLUDE_DIRS ${INCLUDE_DIRS}
- INSTALL_FULL_PATH_DIR ${CMAKE_INSTALL_PREFIX}/lib/collectd
- COMPONENT ${COLLECTD_PLUGINS}
- EMPTY_PREFIX true
- )
+
+##############################################################
+# Compiler options
+##############################################################
+list(APPEND COMPILER_OPTIONS
+ ${DEFAULT_COMPILER_OPTIONS}
+ ${COLLECTD_COMPILER_OPTIONS}
+)
+
+
+##############################################################
+# Build library
+##############################################################
+build_library(${VPP_TELEMETRY}
+ SHARED
+ EMPTY_PREFIX
+ SOURCES ${SOURCE_FILES}
+ LINK_LIBRARIES ${LIBRARIES}
+ INCLUDE_DIRS
+ PRIVATE ${INCLUDE_DIRS}
+ INSTALL_FULL_PATH_DIR ${COLLECTD_PLUGIN_DIR}
+ COMPONENT ${COLLECTD_PLUGINS}
+ COMPILE_OPTIONS ${COMPILER_OPTIONS}
+)
diff --git a/telemetry/vpp-collectd/vpp/vpp.c b/telemetry/vpp-collectd/vpp/vpp.c
index ba838a050..ff70f3503 100644
--- a/telemetry/vpp-collectd/vpp/vpp.c
+++ b/telemetry/vpp-collectd/vpp/vpp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -13,26 +13,9 @@
* limitations under the License.
*/
-#if !HAVE_CONFIG_H
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef __USE_ISOC99 /* required for NAN */
-#define DISABLE_ISOC99 1
-#define __USE_ISOC99 1
-#endif /* !defined(__USE_ISOC99) */
-
-#if DISABLE_ISOC99
-#undef DISABLE_ISOC99
-#undef __USE_ISOC99
-#endif /* DISABLE_ISOC99 */
-#endif /* ! HAVE_CONFIG */
-
-/* Keep order as it is */
-#include <config.h>
-#include <collectd.h>
-#include <common.h>
-#include <plugin.h>
+#include "collectd.h"
+#include "plugin.h"
+#include "utils/common/common.h"
#define counter_t vpp_counter_t
#include <vpp-api/client/stat_client.h>
@@ -164,7 +147,6 @@ static data_set_t if_tx_broadcast_ds = {
/**********************************************************/
/********** UTILITY FUNCTIONS *****************************/
/**********************************************************/
-
/*
* Utility function used by the read callback to populate a
* value_list_t and pass it to plugin_dispatch_values.
@@ -183,8 +165,7 @@ static int submit(const char *plugin_instance, const char *type,
sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, type, sizeof(vl.type));
- if (tag != NULL)
- sstrncpy(vl.type_instance, tag, sizeof(vl.type_instance));
+ if (tag != NULL) sstrncpy(vl.type_instance, tag, sizeof(vl.type_instance));
return plugin_dispatch_values(&vl);
}
@@ -247,7 +228,6 @@ static int get_data_set(const char *stat_name, data_set_t *data_set_ptr) {
/**********************************************************/
/********** CALLBACK FUNCTIONS ****************************/
/**********************************************************/
-
/*
* This function is called for each configuration item.
*/
@@ -280,8 +260,7 @@ static int vpp_init(void) {
u8 *stat_segment_name = (u8 *)STAT_SEGMENT_SOCKET_FILE;
int ret = stat_segment_connect((char *)stat_segment_name);
- if (ret)
- plugin_log(LOG_ERR, "vpp plugin: connecting to segment failed");
+ if (ret) plugin_log(LOG_ERR, "vpp plugin: connecting to segment failed");
return ret;
}
@@ -315,67 +294,65 @@ static int vpp_read(void) {
/* Collect results for each interface and submit them */
for (int i = 0; i < vec_len(res); i++) {
switch (res[i].type) {
- case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
- for (int k = 0; k < vec_len(res[i].simple_counter_vec); k++) {
- for (int j = 0; j < vec_len(res[i].simple_counter_vec[k]); j++) {
- if (!interfaces[j]) {
- continue;
- }
+ case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE:
+ for (int k = 0; k < vec_len(res[i].simple_counter_vec); k++) {
+ for (int j = 0; j < vec_len(res[i].simple_counter_vec[k]); j++) {
+ if (!interfaces[j]) {
+ continue;
+ }
- if (get_data_set(res[i].name, &data_set)) {
- continue;
- }
+ if (get_data_set(res[i].name, &data_set)) {
+ continue;
+ }
- value_t values[1] = {
- (value_t){.derive = res[i].simple_counter_vec[k][j]}
- };
+ value_t values[1] = {
+ (value_t){.derive = res[i].simple_counter_vec[k][j]}};
- err = submit(interfaces[j], data_set.type, values, 1, &timestamp);
+ err = submit(interfaces[j], data_set.type, values, 1, &timestamp);
- if (err)
- goto END;
+ if (err) goto END;
+ }
}
- }
- break;
+ break;
- case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
- for (int k = 0; k < vec_len(res[i].combined_counter_vec); k++) {
- for (int j = 0; j < vec_len(res[i].combined_counter_vec[k]); j++) {
- if (!interfaces[j]) {
- continue;
- }
+ case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED:
+ for (int k = 0; k < vec_len(res[i].combined_counter_vec); k++) {
+ for (int j = 0; j < vec_len(res[i].combined_counter_vec[k]); j++) {
+ if (!interfaces[j]) {
+ continue;
+ }
- if (get_data_set(res[i].name, &data_set)) {
- continue;
- }
+ if (get_data_set(res[i].name, &data_set)) {
+ continue;
+ }
- value_t values[2] = {
- (value_t){.derive = res[i].combined_counter_vec[k][j].packets},
- (value_t){.derive = res[i].combined_counter_vec[k][j].bytes},
- };
+ value_t values[2] = {
+ (value_t){.derive = res[i].combined_counter_vec[k][j].packets},
+ (value_t){.derive = res[i].combined_counter_vec[k][j].bytes},
+ };
- err = submit(interfaces[j], data_set.type, values, 2, &timestamp);
+ err = submit(interfaces[j], data_set.type, values, 2, &timestamp);
- if (err)
- goto END;
+ if (err) goto END;
+ }
}
- }
- break;
+ break;
- case STAT_DIR_TYPE_SCALAR_INDEX:
- plugin_log(LOG_INFO, "vpp plugin: %.2f %s", res[i].scalar_value,
- res[i].name);
- break;
+ case STAT_DIR_TYPE_SCALAR_INDEX:
+ plugin_log(LOG_INFO, "vpp plugin: %.2f %s", res[i].scalar_value,
+ res[i].name);
+ break;
- case STAT_DIR_TYPE_NAME_VECTOR:
- break;
+ case STAT_DIR_TYPE_NAME_VECTOR:
+ break;
- case STAT_DIR_TYPE_ERROR_INDEX:
- break;
+ case STAT_DIR_TYPE_ERROR_INDEX:
+ break;
- default:
- plugin_log(LOG_WARNING, "vpp plugin: unknown stat type %d", res[i].type);
- break;
+ default:
+ plugin_log(LOG_WARNING, "vpp plugin: unknown stat type %d",
+ res[i].type);
+ break;
}
}