"ReportByDevice",
"ReportReserved",
"ReportInodes",
- "FreePercentage"
+ "ReportPercentage"
};
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 _Bool report_percentage = 0;
static int df_init (void)
{
return (0);
}
- else if (strcasecmp (key, "FreePercentage") == 0)
+ else if (strcasecmp (key, "ReportPercentage") == 0)
{
if (IS_TRUE (value))
- report_free_percentage = 1;
+ report_percentage = 1;
else
- report_free_percentage = 0;
+ report_percentage = 0;
return (0);
}
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)
blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail);
blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree);
- df_submit_one (disk_name, "df_complex", "free",
+ if (report_percentage)
+ {
+ 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));
+ }
+ }
+ else
+ {
+ df_submit_one (disk_name, "df_complex", "free",
(gauge_t) (blk_free * blocksize));
- df_submit_one (disk_name, "df_complex", "reserved",
+ df_submit_one (disk_name, "df_complex", "reserved",
(gauge_t) (blk_reserved * blocksize));
- df_submit_one (disk_name, "df_complex", "used",
+ 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)
{
statbuf.f_ffree = statbuf.f_favail;
if (statbuf.f_files < statbuf.f_ffree)
statbuf.f_files = statbuf.f_ffree;
-
+
inode_free = (uint64_t) statbuf.f_favail;
inode_reserved = (uint64_t) (statbuf.f_ffree - statbuf.f_favail);
inode_used = (uint64_t) (statbuf.f_files - statbuf.f_ffree);
-
- df_submit_one (disk_name, "df_inodes", "free",
- (gauge_t) inode_free);
- df_submit_one (disk_name, "df_inodes", "reserved",
- (gauge_t) inode_reserved);
- df_submit_one (disk_name, "df_inodes", "used",
- (gauge_t) inode_used);
+
+ if (report_percentage)
+ {
+ 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));
+ }
+ }
+ else
+ {
+ df_submit_one (disk_name, "df_inodes", "free",
+ (gauge_t) inode_free);
+ df_submit_one (disk_name, "df_inodes", "reserved",
+ (gauge_t) inode_reserved);
+ df_submit_one (disk_name, "df_inodes", "used",
+ (gauge_t) inode_used);
+ }
}
}