adding percentage format string for disk info module

explicit cast to double, changed format string to percentage
This commit is contained in:
gereon 2012-08-30 19:32:33 +02:00 committed by Michael Stapelberg
parent fa4e9cdfb3
commit 50ad0334f6

View File

@ -86,6 +86,11 @@ 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");
}
}
*outwalk = '\0';