]>
Commit | Line | Data |
---|---|---|
a652d418 MT |
1 | diff --git a/src/collectd.c b/src/collectd.c |
2 | index 6b77d599..f17c19eb 100644 | |
3 | --- a/src/collectd.c | |
4 | +++ b/src/collectd.c | |
5 | @@ -294,7 +294,7 @@ static int do_init (void) | |
6 | #endif | |
7 | ||
8 | #if HAVE_LIBSTATGRAB | |
9 | - if (sg_init ()) | |
10 | + if (sg_init (0)) | |
11 | { | |
12 | ERROR ("sg_init: %s", sg_str_error (sg_get_error ())); | |
13 | return (-1); | |
14 | diff --git a/src/disk.c b/src/disk.c | |
15 | index 4a78f1bd..5f972aa5 100644 | |
16 | --- a/src/disk.c | |
17 | +++ b/src/disk.c | |
18 | @@ -77,34 +77,6 @@ | |
19 | static mach_port_t io_master_port = MACH_PORT_NULL; | |
20 | /* #endif HAVE_IOKIT_IOKITLIB_H */ | |
21 | ||
22 | -#elif KERNEL_LINUX | |
23 | -typedef struct diskstats | |
24 | -{ | |
25 | - char *name; | |
26 | - | |
27 | - /* This overflows in roughly 1361 years */ | |
28 | - unsigned int poll_count; | |
29 | - | |
30 | - counter_t read_sectors; | |
31 | - counter_t write_sectors; | |
32 | - | |
33 | - counter_t read_bytes; | |
34 | - counter_t write_bytes; | |
35 | - | |
36 | - counter_t read_ops; | |
37 | - counter_t write_ops; | |
38 | - counter_t read_time; | |
39 | - counter_t write_time; | |
40 | - | |
41 | - counter_t avg_read_time; | |
42 | - counter_t avg_write_time; | |
43 | - | |
44 | - struct diskstats *next; | |
45 | -} diskstats_t; | |
46 | - | |
47 | -static diskstats_t *disklist; | |
48 | -/* #endif KERNEL_LINUX */ | |
49 | - | |
50 | #elif HAVE_LIBKSTAT | |
51 | #define MAX_NUMDISK 256 | |
52 | extern kstat_ctl_t *kc; | |
53 | @@ -182,10 +154,6 @@ static int disk_init (void) | |
54 | } | |
55 | /* #endif HAVE_IOKIT_IOKITLIB_H */ | |
56 | ||
57 | -#elif KERNEL_LINUX | |
58 | - /* do nothing */ | |
59 | -/* #endif KERNEL_LINUX */ | |
60 | - | |
61 | #elif HAVE_LIBKSTAT | |
62 | kstat_t *ksp_chain; | |
63 | ||
64 | @@ -235,16 +203,6 @@ static void disk_submit (const char *plugin_instance, | |
65 | plugin_dispatch_values (&vl); | |
66 | } /* void disk_submit */ | |
67 | ||
68 | -#if KERNEL_LINUX | |
69 | -static counter_t disk_calc_time_incr (counter_t delta_time, counter_t delta_ops) | |
70 | -{ | |
71 | - double avg_time = ((double) delta_time) / ((double) delta_ops); | |
72 | - double avg_time_incr = ((double) interval_g) * avg_time; | |
73 | - | |
74 | - return ((counter_t) (avg_time_incr + .5)); | |
75 | -} | |
76 | -#endif | |
77 | - | |
78 | #if HAVE_IOKIT_IOKITLIB_H | |
79 | static signed long long dict_get_value (CFDictionaryRef dict, const char *key) | |
80 | { | |
81 | @@ -428,218 +386,6 @@ static int disk_read (void) | |
82 | IOObjectRelease (disk_list); | |
83 | /* #endif HAVE_IOKIT_IOKITLIB_H */ | |
84 | ||
85 | -#elif KERNEL_LINUX | |
86 | - FILE *fh; | |
87 | - char buffer[1024]; | |
88 | - | |
89 | - char *fields[32]; | |
90 | - int numfields; | |
91 | - int fieldshift = 0; | |
92 | - | |
93 | - int minor = 0; | |
94 | - | |
95 | - counter_t read_sectors = 0; | |
96 | - counter_t write_sectors = 0; | |
97 | - | |
98 | - counter_t read_ops = 0; | |
99 | - counter_t read_merged = 0; | |
100 | - counter_t read_time = 0; | |
101 | - counter_t write_ops = 0; | |
102 | - counter_t write_merged = 0; | |
103 | - counter_t write_time = 0; | |
104 | - int is_disk = 0; | |
105 | - | |
106 | - diskstats_t *ds, *pre_ds; | |
107 | - | |
108 | - if ((fh = fopen ("/proc/diskstats", "r")) == NULL) | |
109 | - { | |
110 | - fh = fopen ("/proc/partitions", "r"); | |
111 | - if (fh == NULL) | |
112 | - { | |
113 | - ERROR ("disk plugin: fopen (/proc/{diskstats,partitions}) failed."); | |
114 | - return (-1); | |
115 | - } | |
116 | - | |
117 | - /* Kernel is 2.4.* */ | |
118 | - fieldshift = 1; | |
119 | - } | |
120 | - | |
121 | - while (fgets (buffer, sizeof (buffer), fh) != NULL) | |
122 | - { | |
123 | - char *disk_name; | |
124 | - | |
125 | - numfields = strsplit (buffer, fields, 32); | |
126 | - | |
127 | - if ((numfields != (14 + fieldshift)) && (numfields != 7)) | |
128 | - continue; | |
129 | - | |
130 | - minor = atoll (fields[1]); | |
131 | - | |
132 | - disk_name = fields[2 + fieldshift]; | |
133 | - | |
134 | - for (ds = disklist, pre_ds = disklist; ds != NULL; pre_ds = ds, ds = ds->next) | |
135 | - if (strcmp (disk_name, ds->name) == 0) | |
136 | - break; | |
137 | - | |
138 | - if (ds == NULL) | |
139 | - { | |
140 | - if ((ds = (diskstats_t *) calloc (1, sizeof (diskstats_t))) == NULL) | |
141 | - continue; | |
142 | - | |
143 | - if ((ds->name = strdup (disk_name)) == NULL) | |
144 | - { | |
145 | - free (ds); | |
146 | - continue; | |
147 | - } | |
148 | - | |
149 | - if (pre_ds == NULL) | |
150 | - disklist = ds; | |
151 | - else | |
152 | - pre_ds->next = ds; | |
153 | - } | |
154 | - | |
155 | - is_disk = 0; | |
156 | - if (numfields == 7) | |
157 | - { | |
158 | - /* Kernel 2.6, Partition */ | |
159 | - read_ops = atoll (fields[3]); | |
160 | - read_sectors = atoll (fields[4]); | |
161 | - write_ops = atoll (fields[5]); | |
162 | - write_sectors = atoll (fields[6]); | |
163 | - } | |
164 | - else if (numfields == (14 + fieldshift)) | |
165 | - { | |
166 | - read_ops = atoll (fields[3 + fieldshift]); | |
167 | - write_ops = atoll (fields[7 + fieldshift]); | |
168 | - | |
169 | - read_sectors = atoll (fields[5 + fieldshift]); | |
170 | - write_sectors = atoll (fields[9 + fieldshift]); | |
171 | - | |
172 | - if ((fieldshift == 0) || (minor == 0)) | |
173 | - { | |
174 | - is_disk = 1; | |
175 | - read_merged = atoll (fields[4 + fieldshift]); | |
176 | - read_time = atoll (fields[6 + fieldshift]); | |
177 | - write_merged = atoll (fields[8 + fieldshift]); | |
178 | - write_time = atoll (fields[10+ fieldshift]); | |
179 | - } | |
180 | - } | |
181 | - else | |
182 | - { | |
183 | - DEBUG ("numfields = %i; => unknown file format.", numfields); | |
184 | - continue; | |
185 | - } | |
186 | - | |
187 | - { | |
188 | - counter_t diff_read_sectors; | |
189 | - counter_t diff_write_sectors; | |
190 | - | |
191 | - /* If the counter wraps around, it's only 32 bits.. */ | |
192 | - if (read_sectors < ds->read_sectors) | |
193 | - diff_read_sectors = 1 + read_sectors | |
194 | - + (UINT_MAX - ds->read_sectors); | |
195 | - else | |
196 | - diff_read_sectors = read_sectors - ds->read_sectors; | |
197 | - if (write_sectors < ds->write_sectors) | |
198 | - diff_write_sectors = 1 + write_sectors | |
199 | - + (UINT_MAX - ds->write_sectors); | |
200 | - else | |
201 | - diff_write_sectors = write_sectors - ds->write_sectors; | |
202 | - | |
203 | - ds->read_bytes += 512 * diff_read_sectors; | |
204 | - ds->write_bytes += 512 * diff_write_sectors; | |
205 | - ds->read_sectors = read_sectors; | |
206 | - ds->write_sectors = write_sectors; | |
207 | - } | |
208 | - | |
209 | - /* Calculate the average time an io-op needs to complete */ | |
210 | - if (is_disk) | |
211 | - { | |
212 | - counter_t diff_read_ops; | |
213 | - counter_t diff_write_ops; | |
214 | - counter_t diff_read_time; | |
215 | - counter_t diff_write_time; | |
216 | - | |
217 | - if (read_ops < ds->read_ops) | |
218 | - diff_read_ops = 1 + read_ops | |
219 | - + (UINT_MAX - ds->read_ops); | |
220 | - else | |
221 | - diff_read_ops = read_ops - ds->read_ops; | |
222 | - DEBUG ("disk plugin: disk_name = %s; read_ops = %llu; " | |
223 | - "ds->read_ops = %llu; diff_read_ops = %llu;", | |
224 | - disk_name, | |
225 | - read_ops, ds->read_ops, diff_read_ops); | |
226 | - | |
227 | - if (write_ops < ds->write_ops) | |
228 | - diff_write_ops = 1 + write_ops | |
229 | - + (UINT_MAX - ds->write_ops); | |
230 | - else | |
231 | - diff_write_ops = write_ops - ds->write_ops; | |
232 | - | |
233 | - if (read_time < ds->read_time) | |
234 | - diff_read_time = 1 + read_time | |
235 | - + (UINT_MAX - ds->read_time); | |
236 | - else | |
237 | - diff_read_time = read_time - ds->read_time; | |
238 | - | |
239 | - if (write_time < ds->write_time) | |
240 | - diff_write_time = 1 + write_time | |
241 | - + (UINT_MAX - ds->write_time); | |
242 | - else | |
243 | - diff_write_time = write_time - ds->write_time; | |
244 | - | |
245 | - if (diff_read_ops != 0) | |
246 | - ds->avg_read_time += disk_calc_time_incr ( | |
247 | - diff_read_time, diff_read_ops); | |
248 | - if (diff_write_ops != 0) | |
249 | - ds->avg_write_time += disk_calc_time_incr ( | |
250 | - diff_write_time, diff_write_ops); | |
251 | - | |
252 | - ds->read_ops = read_ops; | |
253 | - ds->read_time = read_time; | |
254 | - ds->write_ops = write_ops; | |
255 | - ds->write_time = write_time; | |
256 | - } /* if (is_disk) */ | |
257 | - | |
258 | - /* Don't write to the RRDs if we've just started.. */ | |
259 | - ds->poll_count++; | |
260 | - if (ds->poll_count <= 2) | |
261 | - { | |
262 | - DEBUG ("disk plugin: (ds->poll_count = %i) <= " | |
263 | - "(min_poll_count = 2); => Not writing.", | |
264 | - ds->poll_count); | |
265 | - continue; | |
266 | - } | |
267 | - | |
268 | - if ((read_ops == 0) && (write_ops == 0)) | |
269 | - { | |
270 | - DEBUG ("disk plugin: ((read_ops == 0) && " | |
271 | - "(write_ops == 0)); => Not writing."); | |
272 | - continue; | |
273 | - } | |
274 | - | |
275 | - if ((ds->read_bytes != 0) || (ds->write_bytes != 0)) | |
276 | - disk_submit (disk_name, "disk_octets", | |
277 | - ds->read_bytes, ds->write_bytes); | |
278 | - | |
279 | - if ((ds->read_ops != 0) || (ds->write_ops != 0)) | |
280 | - disk_submit (disk_name, "disk_ops", | |
281 | - read_ops, write_ops); | |
282 | - | |
283 | - if ((ds->avg_read_time != 0) || (ds->avg_write_time != 0)) | |
284 | - disk_submit (disk_name, "disk_time", | |
285 | - ds->avg_read_time, ds->avg_write_time); | |
286 | - | |
287 | - if (is_disk) | |
288 | - { | |
289 | - disk_submit (disk_name, "disk_merged", | |
290 | - read_merged, write_merged); | |
291 | - } /* if (is_disk) */ | |
292 | - } /* while (fgets (buffer, sizeof (buffer), fh) != NULL) */ | |
293 | - | |
294 | - fclose (fh); | |
295 | -/* #endif defined(KERNEL_LINUX) */ | |
296 | - | |
297 | #elif HAVE_LIBKSTAT | |
298 | # if HAVE_KSTAT_IO_T_WRITES && HAVE_KSTAT_IO_T_NWRITES && HAVE_KSTAT_IO_T_WTIME | |
299 | # define KIO_ROCTETS reads |