View | Details | Raw Unified | Return to bug 202327 | Differences between
and this patch

Collapse All | Expand All

(-)net-mgmt/collectd5/Makefile (-2 / +3 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	collectd
4
PORTNAME=	collectd
5
PORTVERSION=	5.5.0
5
PORTVERSION=	5.5.0
6
PORTREVISION=	1
6
CATEGORIES=	net-mgmt
7
CATEGORIES=	net-mgmt
7
MASTER_SITES=	https://collectd.org/files/ \
8
MASTER_SITES=	https://collectd.org/files/ \
8
		http://collectd.org/files/
9
		http://collectd.org/files/
Lines 59-65 Link Here
59
RRDTOOL_DESC=		Enable rrdtool plugin (also rrdcached plugin)
60
RRDTOOL_DESC=		Enable rrdtool plugin (also rrdcached plugin)
60
SIGROK_DESC=		Enable sigrok plugin
61
SIGROK_DESC=		Enable sigrok plugin
61
SNMP_DESC=		Enable SNMP plugin
62
SNMP_DESC=		Enable SNMP plugin
62
STATGRAB_DESC=		Enable statgrab-based plugins (disk, interface, etc)
63
STATGRAB_DESC=		Enable statgrab-based plugins (interface, etc)
63
STATSD_DESC=		Enable statsd plugin
64
STATSD_DESC=		Enable statsd plugin
64
TOKYOTYRANT_DESC=	Enable tokyotyrant plugin
65
TOKYOTYRANT_DESC=	Enable tokyotyrant plugin
65
VARNISH_DESC=		Enable varnish 4.x cache statistics
66
VARNISH_DESC=		Enable varnish 4.x cache statistics
Lines 114-119 Link Here
114
		--enable-cpu \
115
		--enable-cpu \
115
		--enable-csv \
116
		--enable-csv \
116
		--enable-df \
117
		--enable-df \
118
		--enable-disk \
117
		--enable-dns \
119
		--enable-dns \
118
		--enable-email \
120
		--enable-email \
119
		--enable-exec \
121
		--enable-exec \
Lines 455-461 Link Here
455
LIB_DEPENDS+=	libstatgrab.so:${PORTSDIR}/devel/libstatgrab
457
LIB_DEPENDS+=	libstatgrab.so:${PORTSDIR}/devel/libstatgrab
456
LIBS+=		`pkg-config --libs libstatgrab`
458
LIBS+=		`pkg-config --libs libstatgrab`
457
CONFIGURE_ARGS+=--with-libstatgrab=${LOCALBASE} \
459
CONFIGURE_ARGS+=--with-libstatgrab=${LOCALBASE} \
458
		--enable-disk \
459
		--enable-interface
460
		--enable-interface
460
PLIST_SUB+=	STATGRAB=""
461
PLIST_SUB+=	STATGRAB=""
461
.else
462
.else
(-)net-mgmt/collectd5/files/patch-configure.ac (-1 / +36 lines)
Lines 1-4 Link Here
1
--- configure.ac.orig	2015-02-26 11:49:16 UTC
1
--- configure.ac.orig	2015-05-27 07:51:35 UTC
2
+++ configure.ac
2
+++ configure.ac
3
@@ -120,7 +120,7 @@ then
3
@@ -120,7 +120,7 @@ then
4
 fi
4
 fi
Lines 9-14 Link Here
9
 AC_SUBST(pkgconfigdir)
9
 AC_SUBST(pkgconfigdir)
10
 
10
 
11
 # Check for standards compliance mode
11
 # Check for standards compliance mode
12
@@ -641,7 +641,7 @@ SAVE_CFLAGS="$CFLAGS"
13
 # Emulate behavior of src/Makefile.am
14
 if test "x$GCC" = "xyes"
15
 then
16
-	CFLAGS="$CFLAGS -Wall -Werror"
17
+	CFLAGS="$CFLAGS -Wall "
18
 fi
19
 
20
 AC_CACHE_CHECK([for strtok_r],
21
@@ -770,7 +770,7 @@ AC_CHECK_FUNCS(getutxent, [have_getutxen
22
 if test "x$GCC" = "xyes"
23
 then
24
 	SAVE_CFLAGS="$CFLAGS"
25
-	CFLAGS="$CFLAGS -Wall -Wextra -Werror"
26
+	CFLAGS="$CFLAGS -Wall -Wextra "
27
 fi
28
 
29
 AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
12
@@ -1495,6 +1495,7 @@ if test "x$with_kstat" = "xyes"
30
@@ -1495,6 +1495,7 @@ if test "x$with_kstat" = "xyes"
13
 then
31
 then
14
 	AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
32
 	AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
Lines 26-31 Link Here
26
 fi
44
 fi
27
 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
45
 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
28
 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
46
 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
47
@@ -3346,7 +3349,7 @@ then
48
 	SAVE_LIBS="$LIBS"
49
 	# trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
50
 	# (see issues #41 and #42)
51
-	CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
52
+	CFLAGS="$CFLAGS $PERL_CFLAGS -Wall "
53
 	LIBS="$LIBS $PERL_LIBS"
54
 
55
 	AC_CACHE_CHECK([for broken Perl_load_module()],
29
@@ -3629,7 +3632,7 @@ fi
56
@@ -3629,7 +3632,7 @@ fi
30
 if test "x$with_python" = "xyes"
57
 if test "x$with_python" = "xyes"
31
 then
58
 then
Lines 46-48 Link Here
46
 		with_libvarnish="yes"
73
 		with_libvarnish="yes"
47
 	fi; fi; fi
74
 	fi; fi; fi
48
 ],
75
 ],
76
@@ -5263,6 +5266,7 @@ fi
77
 
78
 if test "x$ac_system" = "xFreeBSD"
79
 then
80
+	plugin_disk="yes"
81
         plugin_zfs_arc="yes"
82
 fi
83
 
(-)net-mgmt/collectd5/files/patch-src__Makefile.am (-8 / +26 lines)
Lines 1-6 Link Here
1
--- src/Makefile.am.orig	2015-05-26 19:38:14 UTC
1
--- src/Makefile.am.orig	2015-05-26 19:38:14 UTC
2
+++ src/Makefile.am
2
+++ src/Makefile.am
3
@@ -14,7 +14,7 @@ AM_CPPFLAGS = -I$(srcdir)/daemon
3
@@ -7,14 +7,14 @@ SUBDIRS += daemon
4
 PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '\<module_register\>'
5
 
6
 if COMPILER_IS_GCC
7
-AM_CFLAGS = -Wall -Werror
8
+AM_CFLAGS = -Wall 
9
 endif
10
 
11
 AM_CPPFLAGS = -I$(srcdir)/daemon
4
 AM_CPPFLAGS += -DPREFIX='"${prefix}"'
12
 AM_CPPFLAGS += -DPREFIX='"${prefix}"'
5
 AM_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"'
13
 AM_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"'
6
 AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"'
14
 AM_CPPFLAGS += -DLOCALSTATEDIR='"${localstatedir}"'
Lines 27-33 Link Here
27
 endif
35
 endif
28
 if BUILD_WITH_LIBDEVINFO
36
 if BUILD_WITH_LIBDEVINFO
29
 disk_la_LIBADD += -ldevinfo
37
 disk_la_LIBADD += -ldevinfo
30
@@ -408,7 +408,7 @@ interface_la_CFLAGS += $(BUILD_WITH_LIBS
38
@@ -321,6 +321,9 @@ endif
39
 if BUILD_WITH_PERFSTAT
40
 disk_la_LIBADD += -lperfstat
41
 endif
42
+if BUILD_FREEBSD
43
+disk_la_LIBADD += -ldevstat -lgeom
44
+endif
45
 endif
46
 
47
 if BUILD_PLUGIN_DNS
48
@@ -408,7 +411,7 @@ interface_la_CFLAGS += $(BUILD_WITH_LIBS
31
 interface_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
49
 interface_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
32
 else
50
 else
33
 if BUILD_WITH_LIBKSTAT
51
 if BUILD_WITH_LIBKSTAT
Lines 36-42 Link Here
36
 endif
54
 endif
37
 if BUILD_WITH_LIBDEVINFO
55
 if BUILD_WITH_LIBDEVINFO
38
 interface_la_LIBADD += -ldevinfo
56
 interface_la_LIBADD += -ldevinfo
39
@@ -591,7 +591,7 @@ memory_la_CFLAGS = $(AM_CFLAGS)
57
@@ -591,7 +594,7 @@ memory_la_CFLAGS = $(AM_CFLAGS)
40
 memory_la_LDFLAGS = $(PLUGIN_LDFLAGS)
58
 memory_la_LDFLAGS = $(PLUGIN_LDFLAGS)
41
 memory_la_LIBADD =
59
 memory_la_LIBADD =
42
 if BUILD_WITH_LIBKSTAT
60
 if BUILD_WITH_LIBKSTAT
Lines 45-51 Link Here
45
 endif
63
 endif
46
 if BUILD_WITH_LIBDEVINFO
64
 if BUILD_WITH_LIBDEVINFO
47
 memory_la_LIBADD += -ldevinfo
65
 memory_la_LIBADD += -ldevinfo
48
@@ -964,7 +964,7 @@ swap_la_CFLAGS = $(AM_CFLAGS)
66
@@ -964,7 +967,7 @@ swap_la_CFLAGS = $(AM_CFLAGS)
49
 swap_la_LDFLAGS = $(PLUGIN_LDFLAGS)
67
 swap_la_LDFLAGS = $(PLUGIN_LDFLAGS)
50
 swap_la_LIBADD =
68
 swap_la_LIBADD =
51
 if BUILD_WITH_LIBKSTAT
69
 if BUILD_WITH_LIBKSTAT
Lines 54-60 Link Here
54
 endif
72
 endif
55
 if BUILD_WITH_LIBDEVINFO
73
 if BUILD_WITH_LIBDEVINFO
56
 swap_la_LIBADD += -ldevinfo
74
 swap_la_LIBADD += -ldevinfo
57
@@ -1010,7 +1010,7 @@ if BUILD_PLUGIN_TAPE
75
@@ -1010,7 +1013,7 @@ if BUILD_PLUGIN_TAPE
58
 pkglib_LTLIBRARIES += tape.la
76
 pkglib_LTLIBRARIES += tape.la
59
 tape_la_SOURCES = tape.c
77
 tape_la_SOURCES = tape.c
60
 tape_la_LDFLAGS = $(PLUGIN_LDFLAGS)
78
 tape_la_LDFLAGS = $(PLUGIN_LDFLAGS)
Lines 63-69 Link Here
63
 endif
81
 endif
64
 
82
 
65
 if BUILD_PLUGIN_TARGET_NOTIFICATION
83
 if BUILD_PLUGIN_TARGET_NOTIFICATION
66
@@ -1116,7 +1116,7 @@ uptime_la_CFLAGS = $(AM_CFLAGS)
84
@@ -1116,7 +1119,7 @@ uptime_la_CFLAGS = $(AM_CFLAGS)
67
 uptime_la_LDFLAGS = $(PLUGIN_LDFLAGS)
85
 uptime_la_LDFLAGS = $(PLUGIN_LDFLAGS)
68
 uptime_la_LIBADD =
86
 uptime_la_LIBADD =
69
 if BUILD_WITH_LIBKSTAT
87
 if BUILD_WITH_LIBKSTAT
Lines 72-78 Link Here
72
 endif
90
 endif
73
 if BUILD_WITH_PERFSTAT
91
 if BUILD_WITH_PERFSTAT
74
 uptime_la_LIBADD += -lperfstat
92
 uptime_la_LIBADD += -lperfstat
75
@@ -1275,7 +1275,7 @@ if BUILD_LINUX
93
@@ -1275,7 +1278,7 @@ if BUILD_LINUX
76
 # zfs_arc requires no library on linux
94
 # zfs_arc requires no library on linux
77
 else
95
 else
78
 # solaris
96
 # solaris
Lines 81-87 Link Here
81
 endif
99
 endif
82
 endif
100
 endif
83
 endif
101
 endif
84
@@ -1364,12 +1364,7 @@ endif
102
@@ -1364,12 +1367,7 @@ endif
85
 
103
 
86
 install-exec-hook:
104
 install-exec-hook:
87
 	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
105
 	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
(-)net-mgmt/collectd5/files/patch-src_disk.c (+385 lines)
Line 0 Link Here
1
--- src/disk.c.orig	2015-03-10 14:14:45 UTC
2
+++ src/disk.c
3
@@ -53,6 +53,10 @@
4
 #if HAVE_IOKIT_IOBSD_H
5
 #  include <IOKit/IOBSD.h>
6
 #endif
7
+#if KERNEL_FREEBSD
8
+#include <devstat.h>
9
+#include <libgeom.h>
10
+#endif
11
 
12
 #if HAVE_LIMITS_H
13
 # include <limits.h>
14
@@ -107,6 +111,9 @@ typedef struct diskstats
15
 
16
 static diskstats_t *disklist;
17
 /* #endif KERNEL_LINUX */
18
+#elif KERNEL_FREEBSD
19
+static struct gmesh geom_tree;
20
+/* #endif KERNEL_FREEBSD */
21
 
22
 #elif HAVE_LIBKSTAT
23
 #define MAX_NUMDISK 1024
24
@@ -222,6 +229,21 @@ static int disk_init (void)
25
 	/* do nothing */
26
 /* #endif KERNEL_LINUX */
27
 
28
+#elif KERNEL_FREEBSD
29
+	int rv;
30
+
31
+	rv = geom_gettree(&geom_tree);
32
+	if (rv != 0) {
33
+		ERROR ("geom_gettree() failed, returned %d", rv);
34
+		return (-1);
35
+	}
36
+	rv = geom_stats_open();
37
+	if (rv != 0) {
38
+		ERROR ("geom_stats_open() failed, returned %d", rv);
39
+		return (-1);
40
+	}
41
+/* #endif KERNEL_FREEBSD */
42
+
43
 #elif HAVE_LIBKSTAT
44
 	kstat_t *ksp_chain;
45
 
46
@@ -395,173 +417,223 @@ static int disk_read (void)
47
 	io_registry_entry_t	disk;
48
 	io_registry_entry_t	disk_child;
49
 	io_iterator_t		disk_list;
50
-	CFDictionaryRef		props_dict;
51
+	CFMutableDictionaryRef	props_dict, child_dict;
52
 	CFDictionaryRef		stats_dict;
53
-	CFDictionaryRef		child_dict;
54
 	CFStringRef		tmp_cf_string_ref;
55
 	kern_return_t		status;
56
 
57
-	signed long long read_ops;
58
-	signed long long read_byt;
59
-	signed long long read_tme;
60
-	signed long long write_ops;
61
-	signed long long write_byt;
62
-	signed long long write_tme;
63
+	signed long long read_ops, read_byt, read_tme;
64
+	signed long long write_ops, write_byt, write_tme;
65
 
66
-	int  disk_major;
67
-	int  disk_minor;
68
+	int  disk_major, disk_minor;
69
 	char disk_name[DATA_MAX_NAME_LEN];
70
-	char disk_name_bsd[DATA_MAX_NAME_LEN];
71
+	char child_disk_name_bsd[DATA_MAX_NAME_LEN], props_disk_name_bsd[DATA_MAX_NAME_LEN];
72
 
73
 	/* Get the list of all disk objects. */
74
-	if (IOServiceGetMatchingServices (io_master_port,
75
-				IOServiceMatching (kIOBlockStorageDriverClass),
76
-				&disk_list) != kIOReturnSuccess)
77
-	{
78
+	if (IOServiceGetMatchingServices (io_master_port, IOServiceMatching (kIOBlockStorageDriverClass), &disk_list) != kIOReturnSuccess) {
79
 		ERROR ("disk plugin: IOServiceGetMatchingServices failed.");
80
 		return (-1);
81
 	}
82
 
83
-	while ((disk = IOIteratorNext (disk_list)) != 0)
84
-	{
85
+	while ((disk = IOIteratorNext (disk_list)) != 0) {
86
 		props_dict = NULL;
87
 		stats_dict = NULL;
88
 		child_dict = NULL;
89
 
90
-		/* `disk_child' must be released */
91
-		if ((status = IORegistryEntryGetChildEntry (disk, kIOServicePlane, &disk_child))
92
-			       	!= kIOReturnSuccess)
93
-		{
94
-			/* This fails for example for DVD/CD drives.. */
95
+		/* get child of disk entry and corresponding property dictionary */
96
+		if ((status = IORegistryEntryGetChildEntry (disk, kIOServicePlane, &disk_child)) != kIOReturnSuccess) {
97
+			/* This fails for example for DVD/CD drives, which we want to ignore anyway */
98
 			DEBUG ("IORegistryEntryGetChildEntry (disk) failed: 0x%08x", status);
99
 			IOObjectRelease (disk);
100
 			continue;
101
 		}
102
-
103
-		/* We create `props_dict' => we need to release it later */
104
-		if (IORegistryEntryCreateCFProperties (disk,
105
-					(CFMutableDictionaryRef *) &props_dict,
106
-					kCFAllocatorDefault,
107
-					kNilOptions)
108
-				!= kIOReturnSuccess)
109
-		{
110
-			ERROR ("disk-plugin: IORegistryEntryCreateCFProperties failed.");
111
+		if (IORegistryEntryCreateCFProperties (disk_child, (CFMutableDictionaryRef *) &child_dict, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess || child_dict == NULL) {
112
+			ERROR ("disk plugin: IORegistryEntryCreateCFProperties (disk_child) failed.");
113
 			IOObjectRelease (disk_child);
114
 			IOObjectRelease (disk);
115
 			continue;
116
 		}
117
 
118
-		if (props_dict == NULL)
119
-		{
120
-			DEBUG ("IORegistryEntryCreateCFProperties (disk) failed.");
121
-			IOObjectRelease (disk_child);
122
-			IOObjectRelease (disk);
123
-			continue;
124
+		/* extract name and major/minor numbers */
125
+		memset (child_disk_name_bsd, 0, sizeof (child_disk_name_bsd));
126
+		tmp_cf_string_ref = (CFStringRef) CFDictionaryGetValue (child_dict, CFSTR(kIOBSDNameKey));
127
+		if (tmp_cf_string_ref) {
128
+			assert (CFGetTypeID (tmp_cf_string_ref) == CFStringGetTypeID ());
129
+			CFStringGetCString (tmp_cf_string_ref, child_disk_name_bsd, sizeof (child_disk_name_bsd), kCFStringEncodingUTF8);
130
 		}
131
+		disk_major = (int) dict_get_value (child_dict, kIOBSDMajorKey);
132
+		disk_minor = (int) dict_get_value (child_dict, kIOBSDMinorKey);
133
+		DEBUG ("disk plugin: child_disk_name_bsd=\"%s\" major=%d minor=%d", child_disk_name_bsd, disk_major, disk_minor);
134
+		CFRelease (child_dict);
135
+		IOObjectRelease (disk_child);
136
 
137
-		/* tmp_cf_string_ref doesn't need to be released. */
138
-		tmp_cf_string_ref = (CFStringRef) CFDictionaryGetValue (props_dict,
139
-				CFSTR(kIOBSDNameKey));
140
-		if (!tmp_cf_string_ref)
141
-		{
142
-			DEBUG ("disk plugin: CFDictionaryGetValue("
143
-					"kIOBSDNameKey) failed.");
144
-			CFRelease (props_dict);
145
-			IOObjectRelease (disk_child);
146
+		/* get property dictionary of the disk entry itself */
147
+		if (IORegistryEntryCreateCFProperties (disk, (CFMutableDictionaryRef *) &props_dict, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess || props_dict == NULL) {
148
+			ERROR ("disk-plugin: IORegistryEntryCreateCFProperties failed.");
149
 			IOObjectRelease (disk);
150
 			continue;
151
 		}
152
-		assert (CFGetTypeID (tmp_cf_string_ref) == CFStringGetTypeID ());
153
 
154
-		memset (disk_name_bsd, 0, sizeof (disk_name_bsd));
155
-		CFStringGetCString (tmp_cf_string_ref,
156
-				disk_name_bsd, sizeof (disk_name_bsd),
157
-				kCFStringEncodingUTF8);
158
-		if (disk_name_bsd[0] == 0)
159
-		{
160
-			ERROR ("disk plugin: CFStringGetCString() failed.");
161
-			CFRelease (props_dict);
162
-			IOObjectRelease (disk_child);
163
-			IOObjectRelease (disk);
164
-			continue;
165
+		/* extract name and stats dictionary */
166
+		memset (props_disk_name_bsd, 0, sizeof (props_disk_name_bsd));
167
+		tmp_cf_string_ref = (CFStringRef) CFDictionaryGetValue (props_dict, CFSTR(kIOBSDNameKey));
168
+		if (tmp_cf_string_ref) {
169
+			assert (CFGetTypeID (tmp_cf_string_ref) == CFStringGetTypeID ());
170
+			CFStringGetCString (tmp_cf_string_ref, props_disk_name_bsd, sizeof (props_disk_name_bsd), kCFStringEncodingUTF8);
171
 		}
172
-		DEBUG ("disk plugin: disk_name_bsd = \"%s\"", disk_name_bsd);
173
-
174
-		stats_dict = (CFDictionaryRef) CFDictionaryGetValue (props_dict,
175
-				CFSTR (kIOBlockStorageDriverStatisticsKey));
176
-
177
-		if (stats_dict == NULL)
178
-		{
179
-			DEBUG ("disk plugin: CFDictionaryGetValue ("
180
-					"%s) failed.",
181
-				       	kIOBlockStorageDriverStatisticsKey);
182
+		stats_dict = (CFDictionaryRef) CFDictionaryGetValue (props_dict, CFSTR (kIOBlockStorageDriverStatisticsKey));
183
+		if (stats_dict == NULL) {
184
+			ERROR ("disk plugin: CFDictionaryGetValue (%s) failed.", kIOBlockStorageDriverStatisticsKey);
185
 			CFRelease (props_dict);
186
-			IOObjectRelease (disk_child);
187
 			IOObjectRelease (disk);
188
 			continue;
189
 		}
190
+		DEBUG ("disk plugin: props_disk_name_bsd=\"%s\"", props_disk_name_bsd);
191
 
192
-		if (IORegistryEntryCreateCFProperties (disk_child,
193
-					(CFMutableDictionaryRef *) &child_dict,
194
-					kCFAllocatorDefault,
195
-					kNilOptions)
196
-				!= kIOReturnSuccess)
197
-		{
198
-			DEBUG ("disk plugin: IORegistryEntryCreateCFProperties ("
199
-					"disk_child) failed.");
200
-			IOObjectRelease (disk_child);
201
-			CFRelease (props_dict);
202
-			IOObjectRelease (disk);
203
-			continue;
204
+		/* choose name */
205
+		if (use_bsd_name) {
206
+			if (child_disk_name_bsd[0] != 0)
207
+				sstrncpy (disk_name, child_disk_name_bsd, sizeof (disk_name));
208
+			else if (props_disk_name_bsd[0] != 0)
209
+				sstrncpy (disk_name, props_disk_name_bsd, sizeof (disk_name));
210
+			else {
211
+				ERROR ("disk plugin: can't find bsd disk name.");
212
+				ssnprintf (disk_name, sizeof (disk_name), "%i-%i", disk_major, disk_minor);
213
+			}
214
 		}
215
+		else
216
+			ssnprintf (disk_name, sizeof (disk_name), "%i-%i", disk_major, disk_minor);
217
 
218
-		/* kIOBSDNameKey */
219
-		disk_major = (int) dict_get_value (child_dict,
220
-			       	kIOBSDMajorKey);
221
-		disk_minor = (int) dict_get_value (child_dict,
222
-			       	kIOBSDMinorKey);
223
-		read_ops  = dict_get_value (stats_dict,
224
-				kIOBlockStorageDriverStatisticsReadsKey);
225
-		read_byt  = dict_get_value (stats_dict,
226
-				kIOBlockStorageDriverStatisticsBytesReadKey);
227
-		read_tme  = dict_get_value (stats_dict,
228
-				kIOBlockStorageDriverStatisticsTotalReadTimeKey);
229
-		write_ops = dict_get_value (stats_dict,
230
-				kIOBlockStorageDriverStatisticsWritesKey);
231
-		write_byt = dict_get_value (stats_dict,
232
-				kIOBlockStorageDriverStatisticsBytesWrittenKey);
233
-		/* This property describes the number of nanoseconds spent
234
-		 * performing writes since the block storage driver was
235
-		 * instantiated. It is one of the statistic entries listed
236
-		 * under the top-level kIOBlockStorageDriverStatisticsKey
237
-		 * property table. It has an OSNumber value. */
238
-		write_tme = dict_get_value (stats_dict,
239
-				kIOBlockStorageDriverStatisticsTotalWriteTimeKey);
240
+		/* extract the stats */
241
+		read_ops  = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsReadsKey);
242
+		read_byt  = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsBytesReadKey);
243
+		read_tme  = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsTotalReadTimeKey);
244
+		write_ops = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsWritesKey);
245
+		write_byt = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsBytesWrittenKey);
246
+		write_tme = dict_get_value (stats_dict, kIOBlockStorageDriverStatisticsTotalWriteTimeKey);
247
+		CFRelease (props_dict);
248
+		IOObjectRelease (disk);
249
 
250
-		if (use_bsd_name)
251
-			sstrncpy (disk_name, disk_name_bsd, sizeof (disk_name));
252
-		else
253
-			ssnprintf (disk_name, sizeof (disk_name), "%i-%i",
254
-					disk_major, disk_minor);
255
+		/* and submit */
256
 		DEBUG ("disk plugin: disk_name = \"%s\"", disk_name);
257
-
258
 		if ((read_byt != -1LL) || (write_byt != -1LL))
259
 			disk_submit (disk_name, "disk_octets", read_byt, write_byt);
260
 		if ((read_ops != -1LL) || (write_ops != -1LL))
261
 			disk_submit (disk_name, "disk_ops", read_ops, write_ops);
262
 		if ((read_tme != -1LL) || (write_tme != -1LL))
263
-			disk_submit (disk_name, "disk_time",
264
-					read_tme / 1000,
265
-					write_tme / 1000);
266
+			disk_submit (disk_name, "disk_time", read_tme / 1000, write_tme / 1000);
267
 
268
-		CFRelease (child_dict);
269
-		IOObjectRelease (disk_child);
270
-		CFRelease (props_dict);
271
-		IOObjectRelease (disk);
272
 	}
273
 	IOObjectRelease (disk_list);
274
 /* #endif HAVE_IOKIT_IOKITLIB_H */
275
 
276
+#elif KERNEL_FREEBSD
277
+	int retry, dirty;
278
+
279
+	void *snap = NULL;
280
+	struct devstat *snap_iter;
281
+
282
+	struct gident *geom_id;
283
+
284
+	const char *disk_name;
285
+	long double read_time, write_time;
286
+
287
+	for (retry = 0, dirty = 1; retry < 5 && dirty == 1; retry++) {
288
+		if (snap != NULL)
289
+			geom_stats_snapshot_free(snap);
290
+
291
+		/* Get a fresh copy of stats snapshot */
292
+		snap = geom_stats_snapshot_get();
293
+		if (snap == NULL) {
294
+			ERROR("disk plugin: geom_stats_snapshot_get() failed.");
295
+			return (-1);
296
+		}
297
+
298
+		/* Check if we have dirty read from this snapshot */
299
+		dirty = 0;
300
+		geom_stats_snapshot_reset(snap);
301
+		while ((snap_iter = geom_stats_snapshot_next(snap)) != NULL) {
302
+			if (snap_iter->id == NULL)
303
+				continue;
304
+			geom_id = geom_lookupid(&geom_tree, snap_iter->id);
305
+
306
+			/* New device? refresh GEOM tree */
307
+			if (geom_id == NULL) {
308
+				geom_deletetree(&geom_tree);
309
+				if (geom_gettree(&geom_tree) != 0) {
310
+					ERROR("disk plugin: geom_gettree() failed");
311
+					geom_stats_snapshot_free(snap);
312
+					return (-1);
313
+				}
314
+				geom_id = geom_lookupid(&geom_tree, snap_iter->id);
315
+			}
316
+			/*
317
+			 * This should be rare: the device come right before we take the
318
+			 * snapshot and went away right after it.  We will handle this
319
+			 * case later, so don't mark dirty but silently ignore it.
320
+			 */
321
+			if (geom_id == NULL)
322
+				continue;
323
+
324
+			/* Only collect PROVIDER data */
325
+			if (geom_id->lg_what != ISPROVIDER)
326
+				continue;
327
+
328
+			/* Only collect data when rank is 1 (physical devices) */
329
+			if (((struct gprovider *)(geom_id->lg_ptr))->lg_geom->lg_rank != 1)
330
+				continue;
331
+
332
+			/* Check if this is a dirty read quit for another try */
333
+			if (snap_iter->sequence0 != snap_iter->sequence1) {
334
+				dirty = 1;
335
+				break;
336
+			}
337
+		}
338
+	}
339
+
340
+	/* Reset iterator */
341
+	geom_stats_snapshot_reset(snap);
342
+	for (;;) {
343
+		snap_iter = geom_stats_snapshot_next(snap);
344
+		if (snap_iter == NULL)
345
+			break;
346
+
347
+		if (snap_iter->id == NULL)
348
+			continue;
349
+		geom_id = geom_lookupid(&geom_tree, snap_iter->id);
350
+		if (geom_id == NULL)
351
+			continue;
352
+		if (geom_id->lg_what != ISPROVIDER)
353
+			continue;
354
+		if (((struct gprovider *)(geom_id->lg_ptr))->lg_geom->lg_rank != 1)
355
+			continue;
356
+		/* Skip dirty reads, if present */
357
+		if (dirty && (snap_iter->sequence0 != snap_iter->sequence1))
358
+			continue;
359
+
360
+		disk_name = ((struct gprovider *)geom_id->lg_ptr)->lg_name;
361
+
362
+		if ((snap_iter->bytes[1] != 0) || (snap_iter->bytes[2] != 0)) {
363
+			disk_submit(disk_name, "disk_octets",
364
+					(derive_t)snap_iter->bytes[1],
365
+					(derive_t)snap_iter->bytes[2]);
366
+		}
367
+
368
+		if ((snap_iter->operations[1] != 0) || (snap_iter->operations[2] != 0)) {
369
+			disk_submit(disk_name, "disk_ops",
370
+					(derive_t)snap_iter->operations[1],
371
+					(derive_t)snap_iter->operations[2]);
372
+		}
373
+
374
+		read_time = devstat_compute_etime(&snap_iter->duration[DEVSTAT_READ], NULL);
375
+		write_time = devstat_compute_etime(&snap_iter->duration[DEVSTAT_WRITE], NULL);
376
+		if ((read_time != 0) || (write_time != 0)) {
377
+			disk_submit (disk_name, "disk_time",
378
+					(derive_t)(read_time*1000), (derive_t)(write_time*1000));
379
+		}
380
+	}
381
+	geom_stats_snapshot_free(snap);
382
+
383
 #elif KERNEL_LINUX
384
 	FILE *fh;
385
 	char buffer[1024];
(-)net-mgmt/collectd5/pkg-plist (-1 / +1 lines)
Lines 26-32 Link Here
26
%%CURL_XML%%lib/collectd/curl_xml.so
26
%%CURL_XML%%lib/collectd/curl_xml.so
27
%%DBI%%lib/collectd/dbi.so
27
%%DBI%%lib/collectd/dbi.so
28
lib/collectd/df.so
28
lib/collectd/df.so
29
%%STATGRAB%%lib/collectd/disk.so
29
lib/collectd/disk.so
30
lib/collectd/dns.so
30
lib/collectd/dns.so
31
lib/collectd/email.so
31
lib/collectd/email.so
32
lib/collectd/exec.so
32
lib/collectd/exec.so

Return to bug 202327