From d6b8a4efc1c07f3bbf5f01f524986ecb496711a0 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 31 Aug 2012 14:16:58 +0200 Subject: introduce percentages for all values, document them --- src/print_disk_info.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/print_disk_info.c') diff --git a/src/print_disk_info.c b/src/print_disk_info.c index a3124a1..b577d23 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -86,10 +86,25 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail); walk += strlen("avail"); } - - if (BEGINS_WITH(walk+1, "percentage")) { - outwalk += sprintf(outwalk, "%.01f%%", 100.0 - 100.0 * (double)buf.f_bavail / (double)buf.f_blocks); - walk += strlen("percentage"); + + if (BEGINS_WITH(walk+1, "percentage_free")) { + outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)buf.f_bfree / (double)buf.f_blocks); + walk += strlen("percentage_free"); + } + + if (BEGINS_WITH(walk+1, "percentage_used_of_avail")) { + outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)(buf.f_blocks - buf.f_bavail) / (double)buf.f_blocks); + walk += strlen("percentage_used_of_avail"); + } + + if (BEGINS_WITH(walk+1, "percentage_used")) { + outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)(buf.f_blocks - buf.f_bfree) / (double)buf.f_blocks); + walk += strlen("percentage_used"); + } + + if (BEGINS_WITH(walk+1, "percentage_avail")) { + outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)buf.f_bavail / (double)buf.f_blocks); + walk += strlen("percentage_avail"); } } -- cgit v1.2.3