From 8fb0941ecab2ee579d77f444cd1de6f894a0da97 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 9 Oct 2007 21:48:50 +0000 Subject: [PATCH] add file_system_usage.disk_time --- include/sigar.h | 3 ++- include/sigar_private.h | 2 +- src/os/linux/linux_sigar.c | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/sigar.h b/include/sigar.h index df436d9f..00aa508f 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -444,7 +444,8 @@ typedef struct { disk_writes, disk_write_bytes, disk_read_bytes, - disk_queue; + disk_queue, + disk_time; double use_percent; } sigar_file_system_usage_t; diff --git a/include/sigar_private.h b/include/sigar_private.h index 96753451..84498086 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -312,7 +312,7 @@ int sigar_group_name_get(sigar_t *sigar, int gid, char *buf, int buflen); #define SIGAR_DISK_STATS_NOTIMPL(fsusage) \ fsusage->disk_reads = fsusage->disk_writes = \ fsusage->disk_read_bytes = fsusage->disk_write_bytes = \ - fsusage->disk_queue = SIGAR_FIELD_NOTIMPL; + fsusage->disk_queue = fsusage->disk_time = SIGAR_FIELD_NOTIMPL; #if defined(WIN32) || defined(NETWARE) int sigar_get_iftype(const char *name, int *type, int *inst); diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 83869c5b..54f8a237 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1402,6 +1402,8 @@ static int get_iostat_proc_dstat(sigar_t *sigar, fsusage->disk_read_bytes *= 512; fsusage->disk_write_bytes *= 512; + fsusage->disk_time = use; + fclose(fp); return status; } @@ -1459,9 +1461,10 @@ static int get_iostat_procp(sigar_t *sigar, ptr = sigar_skip_token(ptr); /* wmerge */ fsusage->disk_write_bytes = sigar_strtoull(ptr); /* wsect */ fsusage->disk_writes = sigar_strtoull(ptr); /* wio */ - /* wuse, running, use */ - ptr = sigar_skip_multiple_token(ptr, 3); - fsusage->disk_queue = sigar_strtoull(ptr); /* aveq */ + ptr = sigar_skip_token(ptr); /* wuse */ + ptr = sigar_skip_token(ptr); /* running */ + fsusage->disk_time = sigar_strtoull(ptr); /* use */ + fsusage->disk_queue = sigar_strtoull(ptr); /* aveq */ fsusage->disk_queue /= 1000; /* convert sectors to bytes (512 is fixed size in 2.6 kernels) */ @@ -1501,6 +1504,8 @@ int sigar_file_system_usage_get(sigar_t *sigar, fsusage->free_files = buf.f_ffree; fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage); + SIGAR_DISK_STATS_NOTIMPL(fsusage); /* init */ + /* * 2.2 has metrics /proc/stat, but wtf is the device mapping? * 2.4 has /proc/partitions w/ the metrics. @@ -1532,8 +1537,6 @@ int sigar_file_system_usage_get(sigar_t *sigar, break; } - SIGAR_DISK_STATS_NOTIMPL(fsusage); - return SIGAR_OK; }