summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2cef48a)
raw | patch | inline | side by side (parent: 2cef48a)
author | Florian Forster <octo@collectd.org> | |
Sat, 1 Jun 2013 07:19:07 +0000 (09:19 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 1 Jun 2013 07:19:07 +0000 (09:19 +0200) |
* Change type to "percent".
* Use "<disk>-bytes" and "<disk>-inodes" as plugin instance. This way we're
able to use "percent" for both.
* Remove one level of indentation.
* Make casting more explicit (e.g. don't divide a float by a size_t).
* Use "<disk>-bytes" and "<disk>-inodes" as plugin instance. This way we're
able to use "percent" for both.
* Remove one level of indentation.
* Make casting more explicit (e.g. don't divide a float by a size_t).
src/df.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/df.c b/src/df.c
index 9033f5a8b32e042aaef49bd03aa0789bd58e5d61..5ff3f59be8cbcb401dd288c17ec4b89777251b43 100644 (file)
--- a/src/df.c
+++ b/src/df.c
blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail);
blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree);
- if (report_percentage)
+ if (report_percentage && (statbuf.f_blocks > 0))
{
- if (statbuf.f_files > 0)
- {
- df_submit_one (disk_name, "df_complex_pct", "free",
- (gauge_t) ((float_t)(blk_free) / statbuf.f_blocks * 100));
- df_submit_one (disk_name, "df_complex_pct", "reserved",
- (gauge_t) ((float_t)(blk_reserved) / statbuf.f_blocks * 100));
- df_submit_one (disk_name, "df_complex_pct", "used",
- (gauge_t) ((float_t)(blk_used) / statbuf.f_blocks * 100));
- }
+ uint64_t blk_total = (uint64_t) statbuf.f_blocks;
+ char plugin_instance[DATA_MAX_NAME_LEN];
+
+ ssnprintf (plugin_instance, sizeof (plugin_instance),
+ "%s-bytes", disk_name);
+
+ df_submit_one (plugin_instance, "percent", "free",
+ 100.0 * ((gauge_t) blk_free) / ((gauge_t) blk_total));
+ df_submit_one (plugin_instance, "percent", "reserved",
+ 100.0 * ((gauge_t) blk_reserved) / ((gauge_t) blk_total));
+ df_submit_one (plugin_instance, "percent", "used",
+ 100.0 * ((gauge_t) blk_used) / ((gauge_t) blk_total));
}
- else
+ else if (!report_percentage)
{
df_submit_one (disk_name, "df_complex", "free",
(gauge_t) (blk_free * blocksize));
inode_reserved = (uint64_t) (statbuf.f_ffree - statbuf.f_favail);
inode_used = (uint64_t) (statbuf.f_files - statbuf.f_ffree);
- if (report_percentage)
+ if (report_percentage && (statbuf.f_files > 0))
{
- if (statbuf.f_files > 0)
- {
- df_submit_one (disk_name, "df_inodes_pct", "free",
- (gauge_t) ((float_t)(inode_free) / statbuf.f_files * 100));
- df_submit_one (disk_name, "df_inodes_pct", "reserved",
- (gauge_t) ((float_t)(inode_reserved) / statbuf.f_files * 100));
- df_submit_one (disk_name, "df_inodes_pct", "used",
- (gauge_t) ((float_t)(inode_used) / statbuf.f_files * 100));
- }
+ uint64_t inode_total = (uint64_t) statbuf.f_files;
+ char plugin_instance[DATA_MAX_NAME_LEN];
+
+ ssnprintf (plugin_instance, sizeof (plugin_instance),
+ "%s-inodes", disk_name);
+
+ df_submit_one (plugin_instance, "percent", "free",
+ 100.0 * ((gauge_t) inode_free) / ((gauge_t) inode_total));
+ df_submit_one (plugin_instance, "percent", "reserved",
+ 100.0 * ((gauge_t) inode_reserved) / ((gauge_t) inode_total));
+ df_submit_one (plugin_instance, "percent", "used",
+ 100.0 * ((gauge_t) inode_used) / ((gauge_t) inode_total));
}
- else
+ else if (!report_percentage)
{
df_submit_one (disk_name, "df_inodes", "free",
(gauge_t) inode_free);
diff --git a/src/types.db b/src/types.db
index 05b0e45555aaa487d31b4a8a8a514ccba0b7cbe4..950f6b0d842dd087b9db3e7b012d280da6ec417b 100644 (file)
--- a/src/types.db
+++ b/src/types.db
derive value:DERIVE:0:U
df_complex value:GAUGE:0:U
df_inodes value:GAUGE:0:U
-df_complex_pct value:GAUGE:0:100.1
-df_inodes_pct value:GAUGE:0:100.1
df used:GAUGE:0:1125899906842623, free:GAUGE:0:1125899906842623
disk_latency read:GAUGE:0:U, write:GAUGE:0:U
disk_merged read:DERIVE:0:U, write:DERIVE:0:U