summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6e74e0)
raw | patch | inline | side by side (parent: a6e74e0)
author | Vedran Bartonicek <vbartoni@gmail.com> | |
Mon, 27 May 2013 19:42:08 +0000 (22:42 +0300) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 31 May 2013 16:13:49 +0000 (18:13 +0200) |
Signed-off-by: Florian Forster <octo@collectd.org>
src/df.c | patch | blob | history |
diff --git a/src/df.c b/src/df.c
index ded374b942e5d08d804dd027292eef2ef9f50fcb..abb6418ae00c8dd13f20219a32c6ab57aca1b2d3 100644 (file)
--- a/src/df.c
+++ b/src/df.c
"IgnoreSelected",
"ReportByDevice",
"ReportReserved",
- "ReportInodes"
+ "ReportInodes",
+ "FreePercentage"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static _Bool by_device = 0;
static _Bool report_inodes = 0;
+static _Bool report_free_percentage = 0;
static int df_init (void)
{
return (0);
}
+ else if (strcasecmp (key, "FreePercentage") == 0)
+ {
+ if (IS_TRUE (value))
+ report_free_percentage = 1;
+ else
+ report_free_percentage = 0;
+
+ return (0);
+ }
return (-1);
}
uint64_t blk_free;
uint64_t blk_reserved;
uint64_t blk_used;
+ float blk_free_percentage;
if (ignorelist_match (il_device,
(mnt_ptr->spec_device != NULL)
df_submit_one (disk_name, "df_complex", "used",
(gauge_t) (blk_used * blocksize));
+
+ if (report_free_percentage)
+ {
+ blk_free_percentage = (float)((statbuf.f_blocks - statbuf.f_bfree) / statbuf.f_blocks * 100);
+ float diff = statbuf.f_blocks - statbuf.f_bfree;
+ float div = diff/statbuf.f_blocks ;
+
+ df_submit_one (disk_name, "df_complex", "free_percentage",
+ (gauge_t) (div * 100));
+ }
/* inode handling */
if (report_inodes)
{