- /* Make sure that f_blocks >= f_bfree >= f_bavail */
- if (statbuf.f_bfree < statbuf.f_bavail)
- statbuf.f_bfree = statbuf.f_bavail;
- if (statbuf.f_blocks < statbuf.f_bfree)
- statbuf.f_blocks = statbuf.f_bfree;
-
- blk_free = (uint64_t) statbuf.f_bavail;
- blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail);
- blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree);
-
- if (values_absolute)
- {
- df_submit_one (disk_name, "df_complex", "free",
- (gauge_t) (blk_free * blocksize));
- df_submit_one (disk_name, "df_complex", "reserved",
- (gauge_t) (blk_reserved * blocksize));
- df_submit_one (disk_name, "df_complex", "used",
- (gauge_t) (blk_used * blocksize));
- }
-
- if (values_percentage)
- {
- if (statbuf.f_blocks > 0)
- {
- df_submit_one (disk_name, "percent_bytes", "free",
- (gauge_t) ((float_t)(blk_free) / statbuf.f_blocks * 100));
- df_submit_one (disk_name, "percent_bytes", "reserved",
- (gauge_t) ((float_t)(blk_reserved) / statbuf.f_blocks * 100));
- df_submit_one (disk_name, "percent_bytes", "used",
- (gauge_t) ((float_t)(blk_used) / statbuf.f_blocks * 100));
- }
- else return (-1);
- }
-
- /* inode handling */
- if (report_inodes && statbuf.f_files != 0 && statbuf.f_ffree != 0)
- {
- uint64_t inode_free;
- uint64_t inode_reserved;
- uint64_t inode_used;
-
- /* Sanity-check for the values in the struct */
- if (statbuf.f_ffree < statbuf.f_favail)
- 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);
-
- if (values_percentage)
- {
- if (statbuf.f_files > 0)
- {
- df_submit_one (disk_name, "percent_inodes", "free",
- (gauge_t) ((float_t)(inode_free) / statbuf.f_files * 100));
- df_submit_one (disk_name, "percent_inodes", "reserved",
- (gauge_t) ((float_t)(inode_reserved) / statbuf.f_files * 100));
- df_submit_one (disk_name, "percent_inodes", "used",
- (gauge_t) ((float_t)(inode_used) / statbuf.f_files * 100));
- }
- else return (-1);
- }
- if (values_absolute)
- {
- 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);
- }
- }
- }
-
- cu_mount_freelist (mnt_list);
-
- return (0);
+ /* Make sure that f_blocks >= f_bfree >= f_bavail */
+ if (statbuf.f_bfree < statbuf.f_bavail)
+ statbuf.f_bfree = statbuf.f_bavail;
+ if (statbuf.f_blocks < statbuf.f_bfree)
+ statbuf.f_blocks = statbuf.f_bfree;
+
+ blk_free = (uint64_t)statbuf.f_bavail;
+ blk_reserved = (uint64_t)(statbuf.f_bfree - statbuf.f_bavail);
+ blk_used = (uint64_t)(statbuf.f_blocks - statbuf.f_bfree);
+
+ if (values_absolute) {
+ df_submit_one(disk_name, "df_complex", "free",
+ (gauge_t)(blk_free * blocksize));
+ df_submit_one(disk_name, "df_complex", "reserved",
+ (gauge_t)(blk_reserved * blocksize));
+ df_submit_one(disk_name, "df_complex", "used",
+ (gauge_t)(blk_used * blocksize));
+ }
+
+ if (values_percentage) {
+ if (statbuf.f_blocks > 0) {
+ df_submit_one(disk_name, "percent_bytes", "free",
+ (gauge_t)((float_t)(blk_free) / statbuf.f_blocks * 100));
+ df_submit_one(
+ disk_name, "percent_bytes", "reserved",
+ (gauge_t)((float_t)(blk_reserved) / statbuf.f_blocks * 100));
+ df_submit_one(disk_name, "percent_bytes", "used",
+ (gauge_t)((float_t)(blk_used) / statbuf.f_blocks * 100));
+ } else
+ return -1;
+ }
+
+ /* inode handling */
+ if (report_inodes && statbuf.f_files != 0 && statbuf.f_ffree != 0) {
+ uint64_t inode_free;
+ uint64_t inode_reserved;
+ uint64_t inode_used;
+
+ /* Sanity-check for the values in the struct */
+ if (statbuf.f_ffree < statbuf.f_favail)
+ 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);
+
+ if (values_percentage) {
+ if (statbuf.f_files > 0) {
+ df_submit_one(
+ disk_name, "percent_inodes", "free",
+ (gauge_t)((float_t)(inode_free) / statbuf.f_files * 100));
+ df_submit_one(
+ disk_name, "percent_inodes", "reserved",
+ (gauge_t)((float_t)(inode_reserved) / statbuf.f_files * 100));
+ df_submit_one(
+ disk_name, "percent_inodes", "used",
+ (gauge_t)((float_t)(inode_used) / statbuf.f_files * 100));
+ } else
+ return -1;
+ }
+ if (values_absolute) {
+ 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);
+ }
+ }
+ }
+
+ cu_mount_freelist(mnt_list);
+
+ return 0;