Skip to content

protocols Solaris compilation fixes #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: ci/protocols
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions configure.in
Original file line number Diff line number Diff line change
@@ -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])
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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"
Expand Down
34 changes: 34 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down