View | Details | Raw Unified | Return to bug 176107
Collapse All | Expand All

(-)collectd.new/Makefile (-2 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	collectd
4
PORTNAME=	collectd
5
PORTVERSION=	4.10.8
5
PORTVERSION=	4.10.8
6
PORTREVISION=	1
6
PORTREVISION=	2
7
CATEGORIES=	net-mgmt
7
CATEGORIES=	net-mgmt
8
MASTER_SITES=	http://collectd.org/files/
8
MASTER_SITES=	http://collectd.org/files/
9
9
Lines 128-134 Link Here
128
		--disable-vmem \
128
		--disable-vmem \
129
		--disable-vserver \
129
		--disable-vserver \
130
		--disable-wireless \
130
		--disable-wireless \
131
		--disable-zfs_arc \
132
		--without-perl-bindings \
131
		--without-perl-bindings \
133
		--without-librabbitmq \
132
		--without-librabbitmq \
134
		--disable-varnish \
133
		--disable-varnish \
(-)collectd.new/files/patch-configure.in (-6 / +38 lines)
Lines 1-6 Link Here
1
--- configure.in.orig	2011-10-14 12:49:49.000000000 -0800
1
--- configure.in.orig	2012-11-11 11:43:05.000000000 +0100
2
+++ configure.in	2012-03-20 08:09:25.000000000 -0800
2
+++ configure.in	2012-12-30 23:49:30.000000000 +0100
3
@@ -98,7 +98,7 @@
3
@@ -67,6 +67,9 @@
4
 	*openbsd*)
5
 	ac_system="OpenBSD"
6
 	;;
7
+	*freebsd*)
8
+	ac_system="FreeBSD"
9
+	;;
10
 	*aix*)
11
 	AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
12
 	ac_system="AIX"
13
@@ -98,7 +101,7 @@
4
 fi
14
 fi
5
 
15
 
6
 # Where to install .pc files.
16
 # Where to install .pc files.
Lines 9-15 Link Here
9
 AC_SUBST(pkgconfigdir)
19
 AC_SUBST(pkgconfigdir)
10
 
20
 
11
 # Check for standards compliance mode
21
 # Check for standards compliance mode
12
@@ -1745,9 +1745,6 @@
22
@@ -1200,6 +1203,8 @@
23
 then
24
 	AC_DEFINE(HAVE_LIBKSTAT, 1,
25
 		  [Define to 1 if you have the 'kstat' library (-lkstat)])
26
+	BUILD_WITH_LIBKSTAT_LIBS="-lkstat"
27
+	AC_SUBST(BUILD_WITH_LIBKSTAT_LIBS)
28
 fi
29
 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
30
 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
31
@@ -1562,9 +1567,6 @@
13
 		[with_libgcrypt="yes"],
32
 		[with_libgcrypt="yes"],
14
 		[with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
33
 		[with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
15
 
34
 
Lines 19-25 Link Here
19
 fi
38
 fi
20
 
39
 
21
 CPPFLAGS="$SAVE_CPPFLAGS"
40
 CPPFLAGS="$SAVE_CPPFLAGS"
22
@@ -3165,7 +3162,7 @@
41
@@ -3059,7 +3061,7 @@
23
 if test "x$with_python" = "xyes"
42
 if test "x$with_python" = "xyes"
24
 then
43
 then
25
 	AC_MSG_CHECKING([for Python LIBS])
44
 	AC_MSG_CHECKING([for Python LIBS])
Lines 28-34 Link Here
28
 	python_config_status=$?
47
 	python_config_status=$?
29
 
48
 
30
 	if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
49
 	if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
31
@@ -3180,7 +3177,7 @@
50
@@ -3074,7 +3076,7 @@
32
 if test "x$with_python" = "xyes"
51
 if test "x$with_python" = "xyes"
33
 then
52
 then
34
 	LDFLAGS="-L$python_library_path $LDFLAGS"
53
 	LDFLAGS="-L$python_library_path $LDFLAGS"
Lines 37-39 Link Here
37
 
56
 
38
 	AC_CHECK_FUNC(PyObject_CallFunction,
57
 	AC_CHECK_FUNC(PyObject_CallFunction,
39
 		      [with_python="yes"],
58
 		      [with_python="yes"],
59
@@ -4171,6 +4173,12 @@
60
 	plugin_zfs_arc="yes"
61
 fi
62
 
63
+# FreeBSD
64
+if test "x$ac_system" = "xFreeBSD"
65
+then
66
+       plugin_zfs_arc="yes"
67
+fi
68
+
69
 if test "x$with_devinfo$with_kstat" = "xyesyes"
70
 then
71
 	plugin_cpu="yes"
(-)collectd.new/files/patch-src__Makefile.am (-1 / +10 lines)
Lines 1-5 Link Here
1
--- src/Makefile.am.orig	2012-11-11 11:43:05.000000000 +0100
1
--- src/Makefile.am.orig	2012-11-11 11:43:05.000000000 +0100
2
+++ src/Makefile.am	2012-12-21 16:19:37.000000000 +0100
2
+++ src/Makefile.am	2012-12-30 23:34:44.000000000 +0100
3
@@ -7,7 +7,7 @@
3
@@ -7,7 +7,7 @@
4
 endif
4
 endif
5
 
5
 
Lines 9-14 Link Here
9
 endif
9
 endif
10
 
10
 
11
 AM_CPPFLAGS = -DPREFIX='"${prefix}"'
11
 AM_CPPFLAGS = -DPREFIX='"${prefix}"'
12
@@ -1198,7 +1198,7 @@
13
 zfs_arc_la_SOURCES = zfs_arc.c
14
 zfs_arc_la_CFLAGS = $(AM_CFLAGS)
15
 zfs_arc_la_LDFLAGS = -module -avoid-version
16
-zfs_arc_la_LIBADD = -lkstat
17
+zfs_arc_la_LIBADD = $(BUILD_WITH_LIBKSTAT_LIBS)
18
 collectd_LDADD += "-dlopen" zfs_arc.la
19
 collectd_DEPENDENCIES += zfs_arc.la
20
 endif
12
@@ -1257,12 +1257,7 @@
21
@@ -1257,12 +1257,7 @@
13
 
22
 
14
 install-exec-hook:
23
 install-exec-hook:
(-)collectd.new/files/patch-src__network.c (+12 lines)
Line 0 Link Here
1
--- src/network.c.orig	2011-07-14 15:41:32.000000000 +0200
2
+++ src/network.c	2011-07-14 15:41:37.000000000 +0200
3
@@ -58,7 +58,9 @@
4
 #endif
5
 
6
 #if HAVE_LIBGCRYPT
7
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
8
 # include <gcrypt.h>
9
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
10
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
11
 #endif
12
 
(-)collectd.new/files/patch-src__zfs_arc.c (+161 lines)
Line 0 Link Here
1
--- src/zfs_arc.c.orig	2012-11-11 11:43:05.000000000 +0100
2
+++ src/zfs_arc.c	2012-12-31 00:59:33.000000000 +0100
3
@@ -23,11 +23,58 @@
4
 #include "common.h"
5
 #include "plugin.h"
6
 
7
+#if !defined(HAVE_LIBKSTAT) && defined(HAVE_SYSCTLBYNAME)
8
+#include <sys/sysctl.h>
9
+#endif
10
+
11
 /*
12
  * Global variables
13
  */
14
 
15
-extern kstat_ctl_t *kc;
16
+#if defined(HAVE_LIBKSTAT)
17
+ extern kstat_ctl_t *kc;
18
+#endif
19
+
20
+/*
21
+ * Context
22
+ */
23
+struct za_context {
24
+#if defined(HAVE_LIBKSTAT)
25
+    kstat_t *ksp;
26
+#endif
27
+};
28
+
29
+static int za_init_context(struct za_context *ctx)
30
+{
31
+#if defined(HAVE_LIBKSTAT)
32
+	get_kstat (&ctx->ksp, "zfs", 0, "arcstats");
33
+	if (ctx->ksp == NULL)
34
+	{
35
+		ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat.");
36
+		return (-1);
37
+	}
38
+#endif
39
+	return 0;
40
+}
41
+
42
+static long long za_get_value(struct za_context *ctx, const char* name)
43
+{
44
+#if defined(HAVE_LIBKSTAT)
45
+	return get_kstat_value(ctx->ksp, name);
46
+#elif defined(HAVE_SYSCTLBYNAME)
47
+	// kstat values are available on FreeBSD through sysctl
48
+	char fullname[512];
49
+	long long result = 0;
50
+	size_t size = sizeof(result);
51
+	ssnprintf(fullname, sizeof(fullname), "kstat.zfs.misc.arcstats.%s", name);
52
+	if (sysctlbyname(fullname, &result, &size, NULL, 0) != 0 || size != sizeof(result))
53
+	{
54
+		ERROR ("zfs_arc plugin: Cannot find stats using sysctl");
55
+		result = 0;
56
+	}
57
+	return result;
58
+#endif
59
+}
60
 
61
 static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len)
62
 {
63
@@ -90,42 +137,40 @@
64
 
65
 static int za_read (void)
66
 {
67
-	gauge_t   arcsize, targetsize, minlimit, maxlimit, hits, misses, l2_size, l2_hits, l2_misses;
68
-	counter_t demand_data_hits, demand_metadata_hits, prefetch_data_hits, prefetch_metadata_hits;
69
-	counter_t demand_data_misses, demand_metadata_misses, prefetch_data_misses, prefetch_metadata_misses;
70
-	counter_t l2_read_bytes, l2_write_bytes;
71
-	kstat_t	 *ksp	= NULL;
72
+	long long   arcsize, targetsize, minlimit, maxlimit, hits, misses, l2_size, l2_hits, l2_misses;
73
+	long long demand_data_hits, demand_metadata_hits, prefetch_data_hits, prefetch_metadata_hits;
74
+	long long demand_data_misses, demand_metadata_misses, prefetch_data_misses, prefetch_metadata_misses;
75
+	long long l2_read_bytes, l2_write_bytes;
76
+	struct za_context ctx;
77
 
78
-	get_kstat (&ksp, "zfs", 0, "arcstats");
79
-	if (ksp == NULL)
80
+	if (za_init_context (&ctx) < 0)
81
 	{
82
-		ERROR ("zfs_arc plugin: Cannot find zfs:0:arcstats kstat.");
83
 		return (-1);
84
 	}
85
 
86
-	arcsize    = get_kstat_value(ksp, "size");
87
-	targetsize = get_kstat_value(ksp, "c");
88
-	minlimit   = get_kstat_value(ksp, "c_min");
89
-	maxlimit   = get_kstat_value(ksp, "c_max");
90
-
91
-	demand_data_hits       = get_kstat_value(ksp, "demand_data_hits");
92
-	demand_metadata_hits   = get_kstat_value(ksp, "demand_metadata_hits");
93
-	prefetch_data_hits     = get_kstat_value(ksp, "prefetch_data_hits");
94
-	prefetch_metadata_hits = get_kstat_value(ksp, "prefetch_metadata_hits");
95
-
96
-	demand_data_misses       = get_kstat_value(ksp, "demand_data_misses");
97
-	demand_metadata_misses   = get_kstat_value(ksp, "demand_metadata_misses");
98
-	prefetch_data_misses     = get_kstat_value(ksp, "prefetch_data_misses");
99
-	prefetch_metadata_misses = get_kstat_value(ksp, "prefetch_metadata_misses");
100
-
101
-	hits   = get_kstat_value(ksp, "hits");
102
-	misses = get_kstat_value(ksp, "misses");
103
-
104
-	l2_size        = get_kstat_value(ksp, "l2_size");
105
-	l2_read_bytes  = get_kstat_value(ksp, "l2_read_bytes");
106
-	l2_write_bytes = get_kstat_value(ksp, "l2_write_bytes");
107
-	l2_hits        = get_kstat_value(ksp, "l2_hits");
108
-	l2_misses      = get_kstat_value(ksp, "l2_misses");
109
+	arcsize    = za_get_value(&ctx, "size");
110
+	targetsize = za_get_value(&ctx, "c");
111
+	minlimit   = za_get_value(&ctx, "c_min");
112
+	maxlimit   = za_get_value(&ctx, "c_max");
113
+
114
+	demand_data_hits       = za_get_value(&ctx, "demand_data_hits");
115
+	demand_metadata_hits   = za_get_value(&ctx, "demand_metadata_hits");
116
+	prefetch_data_hits     = za_get_value(&ctx, "prefetch_data_hits");
117
+	prefetch_metadata_hits = za_get_value(&ctx, "prefetch_metadata_hits");
118
+
119
+	demand_data_misses       = za_get_value(&ctx, "demand_data_misses");
120
+	demand_metadata_misses   = za_get_value(&ctx, "demand_metadata_misses");
121
+	prefetch_data_misses     = za_get_value(&ctx, "prefetch_data_misses");
122
+	prefetch_metadata_misses = za_get_value(&ctx, "prefetch_metadata_misses");
123
+
124
+	hits   = za_get_value(&ctx, "hits");
125
+	misses = za_get_value(&ctx, "misses");
126
+
127
+	l2_size        = za_get_value(&ctx, "l2_size");
128
+	l2_read_bytes  = za_get_value(&ctx, "l2_read_bytes");
129
+	l2_write_bytes = za_get_value(&ctx, "l2_write_bytes");
130
+	l2_hits        = za_get_value(&ctx, "l2_hits");
131
+	l2_misses      = za_get_value(&ctx, "l2_misses");
132
 
133
 
134
 	za_submit_size (arcsize, targetsize, minlimit, maxlimit);
135
@@ -146,12 +191,23 @@
136
 
137
 static int za_init (void) /* {{{ */
138
 {
139
-	/* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */
140
-	if (kc == NULL)
141
+#if defined(HAVE_LIBKSTAT)
142
+ 	/* kstats chain already opened by update_kstat (using *kc), verify everything went fine. */
143
+ 	if (kc == NULL)
144
+ 	{
145
+ 		ERROR ("zfs_arc plugin: kstat chain control structure not available.");
146
+ 		return (-1);
147
+ 	}
148
+#elif defined(HAVE_SYSCTLBYNAME)
149
+	/* make sure ARC is available (arc_size is not null) */
150
+	unsigned long long arc_size;
151
+	size_t size = sizeof(arc_size);
152
+	if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arc_size, &size, NULL, 0) != 0 || arc_size == 0)
153
 	{
154
-		ERROR ("zfs_arc plugin: kstat chain control structure not available.");
155
+		ERROR ("zfs_arc plugin: could not get ARC size using sysctl, is ARC enabled?");
156
 		return (-1);
157
 	}
158
+#endif
159
 
160
 	return (0);
161
 } /* }}} int za_init */
(-)collectd.new/pkg-plist (+2 lines)
Lines 107-112 Link Here
107
%%WRITE_HTTP%%lib/collectd/write_http.so
107
%%WRITE_HTTP%%lib/collectd/write_http.so
108
%%XMMS%%lib/collectd/xmms.la
108
%%XMMS%%lib/collectd/xmms.la
109
%%XMMS%%lib/collectd/xmms.so
109
%%XMMS%%lib/collectd/xmms.so
110
lib/collectd/zfs_arc.la
111
lib/collectd/zfs_arc.so
110
include/collectd/client.h
112
include/collectd/client.h
111
include/collectd/lcc_features.h
113
include/collectd/lcc_features.h
112
libdata/pkgconfig/libcollectdclient.pc
114
libdata/pkgconfig/libcollectdclient.pc

Return to bug 176107