From: Florian Forster Date: Wed, 27 Dec 2023 08:35:45 +0000 (+0100) Subject: df plugin: Populate the `unit` field. X-Git-Tag: 6.0.0-rc0~8^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a728b73db18a4c08e318174445f572976a42eee;p=thirdparty%2Fcollectd.git df plugin: Populate the `unit` field. This also changes the report of usage to a ratio, as recommended by OpenTelemetry. Previously we reported a percentage. --- diff --git a/src/df.c b/src/df.c index a4a7af7a4..2f368071f 100644 --- a/src/df.c +++ b/src/df.c @@ -145,18 +145,22 @@ static int df_read(void) { #endif metric_family_t fam_usage = { .name = "system.filesystem.usage", + .unit = "By", .type = METRIC_TYPE_GAUGE, }; metric_family_t fam_utilization = { .name = "system.filesystem.utilization", + .unit = "1", .type = METRIC_TYPE_GAUGE, }; metric_family_t fam_inode_usage = { .name = "system.filesystem.inodes.usage", + .unit = "{inode}", .type = METRIC_TYPE_GAUGE, }; metric_family_t fam_inode_utilization = { .name = "system.filesystem.inodes.utilization", + .unit = "1", .type = METRIC_TYPE_GAUGE, }; @@ -243,7 +247,7 @@ static int df_read(void) { if (values_percentage) { assert(statbuf.f_blocks != 0); // checked above - gauge_t f = 100.0 / (gauge_t)statbuf.f_blocks; + gauge_t f = 1.0 / (gauge_t)statbuf.f_blocks; metric_family_append(&fam_utilization, "state", "used", (value_t){.gauge = blk_used * f}, &m); @@ -269,7 +273,7 @@ static int df_read(void) { if (values_percentage) { if (statbuf.f_files > 0) { - gauge_t f = 100.0 / (gauge_t)statbuf.f_files; + gauge_t f = 1.0 / (gauge_t)statbuf.f_files; metric_family_append(&fam_inode_utilization, "state", "used", (value_t){.gauge = inode_used * f}, &m);