From 9f5e2434953b865187abecab85cd80a5027f3240 Mon Sep 17 00:00:00 2001 From: Cosmin Ioiart Date: Tue, 20 Mar 2012 09:34:27 +0100 Subject: [PATCH 1/3] Enabled Solaris plugins Enabled Solaris plugins for kstat --- configure.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 0a0a8f8c81..ab8bd91895 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(collectd, m4_esyscmd(./version-gen.sh)) +AC_INIT(collectd, [m4_esyscmd(./version-gen.sh)]) AC_CONFIG_SRCDIR(src/collectd.c) AC_CONFIG_HEADERS(src/config.h) AC_CONFIG_AUX_DIR([libltdl/config]) @@ -1341,7 +1341,7 @@ fi if test "x$ac_system" = "xSolaris" then with_kstat="yes" - with_devinfo="yes" + with_devinfo="yes" else with_kstat="no (Solaris only)" with_devinfo="no (Solaris only)" @@ -4530,9 +4530,11 @@ fi # Solaris if test "x$with_kstat" = "xyes" -then +then + plugin_nfs="yes" plugin_uptime="yes" plugin_zfs_arc="yes" + plugin_protocols="yes" fi if test "x$with_devinfo$with_kstat" = "xyesyes" From 9f52484cf2819796e05467d631b7edd69c971676 Mon Sep 17 00:00:00 2001 From: Cosmin Ioiart Date: Tue, 20 Mar 2012 09:35:13 +0100 Subject: [PATCH 2/3] Fix for configure script generation under Solaris --- version-gen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version-gen.sh b/version-gen.sh index 6147b59955..23c471d4ad 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -10,7 +10,7 @@ fi VERSION="`echo \"$VERSION\" | sed -e 's/-/./g'`" -if test "x`uname -s`" = "xAIX" || test "x`uname -s`" = "xSunOS" ; then +if test "x`uname -s`" = "xAIX" ; then echo "$VERSION\c" else echo -n "$VERSION" From dc627533ff806cb4cb8d5248bbaae7ac4e2ea6f9 Mon Sep 17 00:00:00 2001 From: Cosmin Ioiart Date: Tue, 20 Mar 2012 09:36:33 +0100 Subject: [PATCH 3/3] Added kstat dump to string function kstat_value_to_string returns the value of a kstat in char format. It is useful when we want all the values and don't necessarily know the name of the field (similar to a dump). The stats are returned in 2 char arrays, one for the names of the stats and one for their respective values. --- src/common.c | 34 ++++++++++++++++++++++++++++++++++ src/common.h | 6 ++++++ 2 files changed, 40 insertions(+) diff --git a/src/common.c b/src/common.c index 0069a8b650..929eef34fd 100644 --- a/src/common.c +++ b/src/common.c @@ -668,6 +668,40 @@ long long get_kstat_value (kstat_t *ksp, char *name) return (retval); } + +int get_kstat_value_to_string (kstat_named_t *kn, char *ret_name, char *ret_value) +{ + char tmp_val[16]; + + if (kn == NULL) + return (-1); + sstrncpy (ret_name, kn->name, sizeof (kn->name)); + + switch (kn->data_type) + { + case KSTAT_DATA_CHAR: + sprintf (tmp_val, "%.16s", kn->value.c); + break; + case KSTAT_DATA_INT32: + sprintf (tmp_val, "%" PRId32, kn->value.i32); + break; + case KSTAT_DATA_UINT32: + sprintf (tmp_val, "%" PRIu32, kn->value.ui32); + break; + case KSTAT_DATA_INT64: + sprintf (tmp_val, "%" PRId64, kn->value.i64); + break; + case KSTAT_DATA_UINT64: + sprintf (tmp_val, "%" PRIu64, kn->value.ui64); + break; + default: + sstrncpy (tmp_val, "-1", 2); + break; + } + + sstrncpy (ret_value, tmp_val, sizeof (tmp_val)); + return 0; +} #endif /* HAVE_LIBKSTAT */ #ifndef HAVE_HTONLL diff --git a/src/common.h b/src/common.h index e6b899de5c..ea51178c48 100644 --- a/src/common.h +++ b/src/common.h @@ -234,6 +234,12 @@ int check_create_dir (const char *file_orig); #ifdef HAVE_LIBKSTAT int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name); long long get_kstat_value (kstat_t *ksp, char *name); +/* +* kstat_value_to_string returns the value of a kstat in char format. +* It is useful when we want all the values and don't necessarily know the name +* of the field +*/ +int get_kstat_value_to_string(kstat_named_t *kn, char *ret_name, char *ret_value); #endif #ifndef HAVE_HTONLL