summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-01-28 09:36:05 -0500
committerDave Barach <dave@barachs.net>2016-01-28 09:36:20 -0500
commitc23f7bc9a1602b069faba8e559e24bb859476276 (patch)
tree0d7d43c9597ccf9eefeb802cafbdc5b6e82e6387
parent2068e983dd699e199f8c920e6b0f94e7847227dc (diff)
vpp metrics upload via gmond plugin
The gmond module (gmod) isn't built by default, pending CentOS packaging work. Change-Id: I78493a60f431cf9924a28d31ba29423a03aa79b3 Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--build-data/packages/gmod.mk9
-rw-r--r--build-root/vagrant/bootstrap.ubuntu1404.sh2
-rw-r--r--gmod/Makefile.am27
-rw-r--r--gmod/configure.ac9
-rw-r--r--gmod/gmod/mod_vpp.c138
-rw-r--r--gmod/gmod/vpp.conf26
6 files changed, 210 insertions, 1 deletions
diff --git a/build-data/packages/gmod.mk b/build-data/packages/gmod.mk
new file mode 100644
index 00000000000..62b31d42be5
--- /dev/null
+++ b/build-data/packages/gmod.mk
@@ -0,0 +1,9 @@
+gmod_configure_depend = vppinfra-install svm-install
+
+gmod_configure_args = # --libdir=$(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/ganglia
+
+gmod_CPPFLAGS = $(call installed_includes_fn, vppinfra svm)
+gmod_CPPFLAGS += -I/usr/include/apr-1.0
+gmod_LDFLAGS = $(call installed_libs_fn, vppinfra svm)
+
+gmod_image_include = echo $(arch_lib_dir)/ganglia/libgmodvpp.so etc
diff --git a/build-root/vagrant/bootstrap.ubuntu1404.sh b/build-root/vagrant/bootstrap.ubuntu1404.sh
index 18023010976..04f341a493f 100644
--- a/build-root/vagrant/bootstrap.ubuntu1404.sh
+++ b/build-root/vagrant/bootstrap.ubuntu1404.sh
@@ -10,7 +10,7 @@ apt-get upgrade -y
sudo update-alternatives --install /bin/sh sh /bin/bash 100
# Install build tools
-apt-get install -y build-essential autoconf automake bison libssl-dev ccache libtool git dkms debhelper emacs
+apt-get install -y build-essential autoconf automake bison libssl-dev ccache libtool git dkms debhelper emacs libganglia1-dev libapr1-dev libconfuse-dev
# Install other stuff
# apt-get install -y qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
diff --git a/gmod/Makefile.am b/gmod/Makefile.am
new file mode 100644
index 00000000000..e57f578862a
--- /dev/null
+++ b/gmod/Makefile.am
@@ -0,0 +1,27 @@
+# Copyright (c) 2015 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.
+
+AUTOMAKE_OPTIONS = foreign subdir-objects
+
+AM_CFLAGS = -Wall
+
+lib_LTLIBRARIES = libgmodvpp.la
+
+libgmodvpp_la_SOURCES = gmod/mod_vpp.c
+
+libgmodvpp_la_LDFLAGS = -module -avoid-version
+
+libgmodvpp_la_LIBADD = -lsvm -lsvmdb -lvppinfra
+
+gconfdir = $(prefix)/etc/conf.d
+gconf_DATA = gmod/vpp.conf
diff --git a/gmod/configure.ac b/gmod/configure.ac
new file mode 100644
index 00000000000..c26ca055be4
--- /dev/null
+++ b/gmod/configure.ac
@@ -0,0 +1,9 @@
+AC_INIT(gmod, 1.0)
+AM_INIT_AUTOMAKE
+
+AC_PROG_LIBTOOL
+AM_PROG_AS
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+AC_OUTPUT([Makefile])
diff --git a/gmod/gmod/mod_vpp.c b/gmod/gmod/mod_vpp.c
new file mode 100644
index 00000000000..951d3528aa0
--- /dev/null
+++ b/gmod/gmod/mod_vpp.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#include <gm_metric.h>
+
+#include <stdlib.h>
+#include <strings.h>
+#include <time.h>
+#include <vppinfra/clib.h>
+#include <vppinfra/vec.h>
+#include <vppinfra/hash.h>
+#include <svmdb.h>
+#include <errno.h>
+
+mmodule vpp_module;
+static svmdb_client_t *svmdb_client;
+
+static int vpp_metric_init (apr_pool_t *p)
+{
+ const char* str_params = vpp_module.module_params;
+ apr_array_header_t *list_params = vpp_module.module_params_list;
+ mmparam *params;
+ char *chroot_path = 0;
+ int i;
+
+ if (str_params) {
+ debug_msg("[mod_vpp]Received string params: %s", str_params);
+ }
+ /* Multiple name/value pair parameters. */
+ if (list_params) {
+ debug_msg("[mod_vpp]Received following params list: ");
+ params = (mmparam*) list_params->elts;
+ for(i=0; i< list_params->nelts; i++) {
+ debug_msg("\tParam: %s = %s", params[i].name, params[i].value);
+ }
+ }
+
+ svmdb_client = svmdb_map_chroot (chroot_path);
+
+
+ /* Initialize the metadata storage for each of the metrics and then
+ * store one or more key/value pairs. The define MGROUPS defines
+ * the key for the grouping attribute. */
+ for (i = 0; vpp_module.metrics_info[i].name != NULL; i++) {
+ MMETRIC_INIT_METADATA(&(vpp_module.metrics_info[i]),p);
+ MMETRIC_ADD_METADATA(&(vpp_module.metrics_info[i]),MGROUP,"VPP");
+ }
+
+ return 0;
+}
+
+static void vpp_metric_cleanup (void)
+{
+ svmdb_unmap (svmdb_client);
+}
+
+static g_val_t vpp_metric_handler (int metric_index)
+{
+ g_val_t val;
+ pid_t *vpp_pidp;
+ f64 *vector_ratep, *vpp_rx_ratep;
+
+ switch (metric_index) {
+ case 0:
+ vector_ratep = svmdb_local_get_vec_variable
+ (svmdb_client, "vlib_vector_rate", sizeof (*vector_ratep));
+ if (vector_ratep) {
+ val.d = *vector_ratep;
+ vec_free (vector_ratep);
+ }
+ else
+ val.d = 0.0;
+ break;
+ case 1:
+ vpp_pidp = svmdb_local_get_vec_variable
+ (svmdb_client,
+ "vpp_pid", sizeof (*vpp_pidp));
+ if (vpp_pidp && *vpp_pidp) {
+ if (kill(*vpp_pidp, 0) == 0 || errno != ESRCH) {
+ val.d = 1.0;
+ } else {
+ val.d = 0.0;
+ }
+ vec_free (vpp_pidp);
+ } else
+ val.d = 0;
+ break;
+
+ case 2:
+ vpp_rx_ratep = svmdb_local_get_vec_variable
+ (svmdb_client, "vnet_input_rate", sizeof (*vector_ratep));
+ if (vpp_rx_ratep) {
+ val.d = *vpp_rx_ratep;
+ vec_free (vpp_rx_ratep);
+ } else
+ val.d = 0.0;
+ break;
+
+ default:
+ val.d = 0.0;
+ }
+
+ return val;
+}
+
+static Ganglia_25metric vpp_metric_info[] =
+{
+ {0, "Vector_Rate", 100, GANGLIA_VALUE_DOUBLE, "Packets/Frame",
+ "both", "%.1f",
+ UDP_HEADER_SIZE+8, "VPP Vector Rate"},
+ {0, "VPP_State", 100, GANGLIA_VALUE_DOUBLE, "Run=1", "both", "%.0f",
+ UDP_HEADER_SIZE+8, "VPP State"},
+ {0, "Input_Rate", 100, GANGLIA_VALUE_DOUBLE, "5 sec RX rate",
+ "both", "%.1f",
+ UDP_HEADER_SIZE+8, "VPP Aggregate RX Rate"},
+ {0, NULL}
+};
+
+mmodule vpp_module =
+{
+ STD_MMODULE_STUFF,
+ vpp_metric_init,
+ vpp_metric_cleanup,
+ vpp_metric_info,
+ vpp_metric_handler,
+};
diff --git a/gmod/gmod/vpp.conf b/gmod/gmod/vpp.conf
new file mode 100644
index 00000000000..6df20ed1dac
--- /dev/null
+++ b/gmod/gmod/vpp.conf
@@ -0,0 +1,26 @@
+modules {
+ module {
+ name = "vpp_module"
+ path = "libgmodvpp.so"
+ }
+}
+
+collection_group {
+ collect_every = 2
+ time_threshold = 10
+ metric {
+ name = "Vector_Rate"
+ value_threshold = 20.0
+ title = "Vector Rate"
+ }
+ metric {
+ name = "VPP_State"
+ value_threshold = 0.5
+ title = "VPP State"
+ }
+ metric {
+ name = "Input_Rate"
+ value_threshold = 10000.0
+ title = "VPP Aggregate RX rate"
+ }
+}