342 |
|
if(stats.dinfo==NULL) return NULL; |
343 |
|
stats_init = 1; |
344 |
|
} |
345 |
+ |
#ifdef FREEBSD5 |
346 |
+ |
if ((devstat_getdevs(NULL, &stats)) < 0) return NULL; |
347 |
+ |
/* Not aware of a get all devices, so i said 999. If we ever * find a machine with more than 999 disks, then i'll change * this number :) */ |
348 |
+ |
if (devstat_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; |
349 |
+ |
#else |
350 |
|
if ((getdevs(&stats)) < 0) return NULL; |
351 |
|
/* Not aware of a get all devices, so i said 999. If we ever |
352 |
|
* find a machine with more than 999 disks, then i'll change |
353 |
|
* this number :) |
354 |
|
*/ |
355 |
|
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; |
356 |
+ |
#endif |
357 |
|
|
358 |
|
for(counter=0;counter<stats.dinfo->numdevs;counter++){ |
359 |
|
dev_ptr=&stats.dinfo->devices[dev_sel[counter].position]; |
362 |
|
* devices.. like mem, proc.. and also doesn't report floppy |
363 |
|
* drives etc unless they are doing stuff :) |
364 |
|
*/ |
365 |
+ |
#ifdef FREEBSD5 |
366 |
+ |
if((dev_ptr->bytes[DEVSTAT_READ]==0) && (dev_ptr->bytes[DEVSTAT_WRITE]==0)) continue; |
367 |
+ |
#else |
368 |
|
if((dev_ptr->bytes_read==0) && (dev_ptr->bytes_written==0)) continue; |
369 |
+ |
#endif |
370 |
|
if((diskio_stats=diskio_stat_malloc(num_diskio+1, &sizeof_diskio_stats, diskio_stats))==NULL){ |
371 |
|
return NULL; |
372 |
|
} |
373 |
|
diskio_stats_ptr=diskio_stats+num_diskio; |
374 |
< |
|
374 |
> |
|
375 |
> |
#ifdef FREEBSD5 |
376 |
> |
diskio_stats_ptr->read_bytes=dev_ptr->bytes[DEVSTAT_READ]; |
377 |
> |
diskio_stats_ptr->write_bytes=dev_ptr->bytes[DEVSTAT_WRITE]; |
378 |
> |
#else |
379 |
|
diskio_stats_ptr->read_bytes=dev_ptr->bytes_read; |
380 |
|
diskio_stats_ptr->write_bytes=dev_ptr->bytes_written; |
381 |
+ |
#endif |
382 |
|
if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name); |
383 |
|
asprintf((&diskio_stats_ptr->disk_name), "%s%d", dev_ptr->device_name, dev_ptr->unit_number); |
384 |
|
diskio_stats_ptr->systime=time(NULL); |