- 论坛徽章:
- 0
|
/*
***************************************************************************
* Write basic stats, read from /proc/stat, /proc/{diskstats,partitions}
* or from sysfs
***************************************************************************
*/
void write_basic_stat(int curr, unsigned long long itv, int flags, int fctr,
struct io_hdr_stats *shi, struct io_stats *ioi,
struct io_stats *ioj)
{
unsigned long long rd_sec, wr_sec;
printf("%-13s", shi->name);
if (HAS_SYSFS(flags) ||
HAS_DISKSTATS(flags) || HAS_PPARTITIONS(flags)) {
/* Print stats coming from /sys or /proc/{diskstats,partitions} */
rd_sec = ioi->rd_sectors - ioj->rd_sectors;
if ((ioi->rd_sectors < ioj->rd_sectors) && (ioj->rd_sectors <= 0xffffffff))
rd_sec &= 0xffffffff;
wr_sec = ioi->wr_sectors - ioj->wr_sectors;
if ((ioi->wr_sectors < ioj->wr_sectors) && (ioj->wr_sectors <= 0xffffffff))
wr_sec &= 0xffffffff;
printf(" %8.2f %12.2f %12.2f %10llu %10llu\n",
S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv),
ll_s_value(ioj->rd_sectors, ioi->rd_sectors, itv) / fctr,
ll_s_value(ioj->wr_sectors, ioi->wr_sectors, itv) / fctr,
(unsigned long long) rd_sec / fctr,
(unsigned long long) wr_sec / fctr);
}
else {
/* Print stats coming from /proc/stat */
printf(" %8.2f %12.2f %12.2f %10lu %10lu\n",
S_VALUE(ioj->dk_drive, ioi->dk_drive, itv),
S_VALUE(ioj->dk_drive_rblk, ioi->dk_drive_rblk, itv) / fctr,
S_VALUE(ioj->dk_drive_wblk, ioi->dk_drive_wblk, itv) / fctr,
(ioi->dk_drive_rblk - ioj->dk_drive_rblk) / fctr,
(ioi->dk_drive_wblk - ioj->dk_drive_wblk) / fctr);
}
}
找到源码了! |
|