- if (values_absolute)
- {
- swap_submit_gauge (NULL, "swap", "used", (gauge_t) (pmemory.pgsp_total - pmemory.pgsp_free) * pagesize);
- swap_submit_gauge (NULL, "swap", "free", (gauge_t) pmemory.pgsp_free * pagesize);
- swap_submit_gauge (NULL, "swap", "reserved", (gauge_t) pmemory.pgsp_rsvd * pagesize);
- }
- if (values_percentage)
- {
- gauge_t swap_total = (gauge_t) pmemory.pgsp_total;
- swap_submit_gauge (NULL, "percent", "used", 100.0 * ((gauge_t) (pmemory.pgsp_total - pmemory.pgsp_free)) / swap_total);
- swap_submit_gauge (NULL, "percent", "free", 100.0 * ((gauge_t) pmemory.pgsp_free) / swap_total);
- swap_submit_gauge (NULL, "percent", "reserved", 100.0 * ((gauge_t) pmemory.pgsp_rsvd) / swap_total);
- }
+ total = (gauge_t) (pmemory.pgsp_total * pagesize);
+ free = (gauge_t) (pmemory.pgsp_free * pagesize);
+ reserved = (gauge_t) (pmemory.pgsp_rsvd * pagesize);
+
+ swap_submit_usage (NULL, total - free, free, "reserved", reserved);