aboutsummaryrefslogtreecommitdiffstats
path: root/telemetry/vpp-collectd/vpp
diff options
context:
space:
mode:
authorOlivier Roques <oroques+fdio@cisco.com>2020-11-19 09:36:59 +0000
committerMauro Sardara <msardara@cisco.com>2021-01-19 13:11:04 +0000
commit12085f96264835de7fb2fb607e57edcef603346c (patch)
tree51887fe8e2660a9cc6591f66aa8747a4c139a271 /telemetry/vpp-collectd/vpp
parent3723df3455e88e8534041d1a29b12e8d4a72bb98 (diff)
[HICN-657] Remove common.h dependency in collectd plugins
In Ubuntu 20.04, the file common.h is not shipped with collectd packages anymore. This patch removes that dependency from the collectd plugins. Change-Id: I234389ee9cbfd1f1820efdb34d532a7b11618206 Signed-off-by: Olivier Roques <oroques+fdio@cisco.com>
Diffstat (limited to 'telemetry/vpp-collectd/vpp')
-rw-r--r--telemetry/vpp-collectd/vpp/CMakeLists.txt22
-rw-r--r--telemetry/vpp-collectd/vpp/vpp.c33
2 files changed, 25 insertions, 30 deletions
diff --git a/telemetry/vpp-collectd/vpp/CMakeLists.txt b/telemetry/vpp-collectd/vpp/CMakeLists.txt
index 36248b17a..464ab42d8 100644
--- a/telemetry/vpp-collectd/vpp/CMakeLists.txt
+++ b/telemetry/vpp-collectd/vpp/CMakeLists.txt
@@ -14,22 +14,20 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# Dependencies
-
-list(APPEND SOURCE_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c
-)
-
find_package(Vpp REQUIRED)
find_package(Collectd REQUIRED)
-list (APPEND INCLUDE_DIRS
- ${COLLECTD_INCLUDE_DIRS}
- ${VPP_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR})
+list(APPEND SOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/vpp.c)
+
+list(APPEND INCLUDE_DIRS
+ ${COLLECTD_INCLUDE_DIRS}
+ ${VPP_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_SOURCE_DIR})
-list (APPEND LIBRARIES
- ${VPP_LIBRARY_VPPAPICLIENT}
- ${VPP_LIBRARY_INFRA})
+list(APPEND LIBRARIES
+ ${VPP_LIBRARY_VPPAPICLIENT}
+ ${VPP_LIBRARY_INFRA})
build_library(vpp
SHARED
diff --git a/telemetry/vpp-collectd/vpp/vpp.c b/telemetry/vpp-collectd/vpp/vpp.c
index ba838a050..8bf5182a8 100644
--- a/telemetry/vpp-collectd/vpp/vpp.c
+++ b/telemetry/vpp-collectd/vpp/vpp.c
@@ -13,25 +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>
#define counter_t vpp_counter_t
@@ -39,6 +23,15 @@
#include <vppinfra/vec.h>
#undef counter_t
+#define STATIC_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
+#define IS_TRUE(s) \
+ ((strcasecmp("true", (s)) == 0) || (strcasecmp("yes", (s)) == 0) || \
+ (strcasecmp("on", (s)) == 0))
+#define IS_FALSE(s) \
+ ((strcasecmp("false", (s)) == 0) || (strcasecmp("no", (s)) == 0) || \
+ (strcasecmp("off", (s)) == 0))
+
/************** OPTIONS ***********************************/
static const char *config_keys[2] = {
"Verbose",
@@ -164,6 +157,11 @@ static data_set_t if_tx_broadcast_ds = {
/**********************************************************/
/********** UTILITY FUNCTIONS *****************************/
/**********************************************************/
+char *sstrncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n);
+ dest[n - 1] = '\0';
+ return dest;
+}
/*
* Utility function used by the read callback to populate a
@@ -327,8 +325,7 @@ static int vpp_read(void) {
}
value_t values[1] = {
- (value_t){.derive = res[i].simple_counter_vec[k][j]}
- };
+ (value_t){.derive = res[i].simple_counter_vec[k][j]}};
err = submit(interfaces[j], data_set.type, values, 1, &timestamp);