22 |
|
#include "config.h" |
23 |
|
#endif |
24 |
|
|
25 |
+ |
#include <stdio.h> |
26 |
|
#include <stdlib.h> |
27 |
|
#include <string.h> |
28 |
|
#include "statgrab.h" |
29 |
|
|
30 |
|
#ifdef SOLARIS |
30 |
– |
#include <stdio.h> |
31 |
|
#include <sys/mnttab.h> |
32 |
|
#include <sys/statvfs.h> |
33 |
|
#include <kstat.h> |
35 |
|
#endif |
36 |
|
|
37 |
|
#ifdef LINUX |
38 |
– |
#include <stdio.h> |
38 |
|
#include <sys/vfs.h> |
39 |
|
#include <mntent.h> |
40 |
|
#include "tools.h" |
45 |
|
#include <sys/param.h> |
46 |
|
#include <sys/ucred.h> |
47 |
|
#include <sys/mount.h> |
48 |
+ |
#include <sys/dkstat.h> |
49 |
+ |
#include <devstat.h> |
50 |
|
#define VALID_FS_TYPES {"ufs", "mfs"} |
51 |
|
#endif |
52 |
|
#define START_VAL 1 |
312 |
|
int major, minor; |
313 |
|
char dev_letter; |
314 |
|
#endif |
315 |
+ |
#ifdef FREEBSD |
316 |
+ |
struct statinfo stats; |
317 |
+ |
int counter; |
318 |
+ |
struct device_selection *dev_sel = NULL; |
319 |
+ |
int n_selected, n_selections; |
320 |
+ |
long sel_gen; |
321 |
+ |
struct devstat *dev_ptr; |
322 |
+ |
#endif |
323 |
|
num_diskio=0; |
324 |
|
|
325 |
+ |
#ifdef FREEBSD |
326 |
+ |
stats.dinfo=malloc(sizeof(struct devinfo)); |
327 |
+ |
if(stats.dinfo==NULL) return NULL; |
328 |
+ |
if ((getdevs(&stats)) < 0) return NULL; |
329 |
+ |
/* Not aware of a get all devices, so i said 999. If we ever |
330 |
+ |
* find a machine with more than 999 disks, then i'll change |
331 |
+ |
* this number :) |
332 |
+ |
*/ |
333 |
+ |
if (selectdevs(&dev_sel, &n_selected, &n_selections, &sel_gen, stats.dinfo->generation, stats.dinfo->devices, stats.dinfo->numdevs, NULL, 0, NULL, 0, DS_SELECT_ONLY, 999, 1) < 0) return NULL; |
334 |
+ |
|
335 |
+ |
for(counter=0;counter<stats.dinfo->numdevs;counter++){ |
336 |
+ |
dev_ptr=&stats.dinfo->devices[dev_sel[counter].position]; |
337 |
+ |
|
338 |
+ |
/* Throw away devices that have done nothing, ever.. Eg "odd" |
339 |
+ |
* devices.. like mem, proc.. and also doesn't report floppy |
340 |
+ |
* drives etc unless they are doing stuff :) |
341 |
+ |
*/ |
342 |
+ |
if((dev_ptr->bytes_read==0) && (dev_ptr->bytes_written==0)) continue; |
343 |
+ |
if((diskio_stats=diskio_stat_malloc(num_diskio+1, &sizeof_diskio_stats, diskio_stats))==NULL){ |
344 |
+ |
return NULL; |
345 |
+ |
} |
346 |
+ |
diskio_stats_ptr=diskio_stats+num_diskio; |
347 |
+ |
|
348 |
+ |
diskio_stats_ptr->read_bytes=dev_ptr->bytes_read; |
349 |
+ |
diskio_stats_ptr->write_bytes=dev_ptr->bytes_written; |
350 |
+ |
if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name); |
351 |
+ |
asprintf((&diskio_stats_ptr->disk_name), "%s%d", dev_ptr->device_name, dev_ptr->unit_number); |
352 |
+ |
diskio_stats_ptr->systime=time(NULL); |
353 |
+ |
|
354 |
+ |
num_diskio++; |
355 |
+ |
} |
356 |
+ |
free(dev_sel); |
357 |
+ |
free(stats.dinfo); |
358 |
+ |
|
359 |
+ |
#endif |
360 |
|
#ifdef SOLARIS |
361 |
|
if ((kc = kstat_open()) == NULL) { |
362 |
|
return NULL; |