Blame SOURCES/0004-Filesystems-statistics-part-4-ppc-and-db-output-form.patch

72abff
From b6905bafa7fc82ba22afaeb26ff46c900738e9d4 Mon Sep 17 00:00:00 2001
72abff
From: Sebastien GODARD <sysstat@orange.fr.fake>
72abff
Date: Sun, 12 May 2013 15:17:01 +0200
72abff
Subject: [PATCH] Filesystems statistics (part 4): ppc and db output formats
72abff
72abff
This patch adds ppc and database (CSV) output formats for filesystems
72abff
statistics. These formats can be displayed with sadf options -p and -d.
72abff
72abff
Also add a new flag (PT_USERND) to the render() function so that
72abff
a statistic value can be rounded to the nearest integer value.
72abff
72abff
(cherry picked from commit 37e6da76fd59dcdff84e216e2c8ef10c439d9f84)
72abff
---
72abff
 activity.c   |  2 +-
72abff
 rndr_stats.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
72abff
 rndr_stats.h |  1 +
72abff
 3 files changed, 75 insertions(+), 2 deletions(-)
72abff
72abff
diff --git a/activity.c b/activity.c
72abff
index b1aba37..734df4a 100644
72abff
--- a/activity.c
72abff
+++ b/activity.c
72abff
@@ -1214,7 +1214,7 @@ struct activity filesystem_act = {
72abff
 	.f_render	= render_filesystem_stats,
72abff
 	.f_xml_print	= xml_print_filesystem_stats,
72abff
 	.f_json_print	= json_print_filesystem_stats,
72abff
-	.hdr_line	= "Mbfsfree;Mbfsused;%fsused;%ufsused;Ifree;Iused;%Iused;FILESYSTEM",
72abff
+	.hdr_line	= "FILESYSTEM,MBfsfree;MBfsused;%fsused;%ufsused;Ifree;Iused;%Iused",
72abff
 	.name		= "A_FILESYSTEM",
72abff
 #endif
72abff
 	.nr		= -1,
72abff
diff --git a/rndr_stats.c b/rndr_stats.c
72abff
index 8349e9a..a3dcb22 100644
72abff
--- a/rndr_stats.c
72abff
+++ b/rndr_stats.c
72abff
@@ -147,6 +147,9 @@ static void render(int isdb, char *pre, int rflags, const char *pptxt,
72abff
 	else if (rflags & PT_USESTR) {
72abff
 		printf("%s%s", seps[isdb], sval);
72abff
 	}
72abff
+	else if (rflags & PT_USERND) {
72abff
+		printf("%s%.0f", seps[isdb], dval);
72abff
+	}
72abff
 	else {
72abff
 		printf("%s%.2f", seps[isdb], dval);
72abff
 	}
72abff
@@ -2808,5 +2811,74 @@ __print_funct_t render_pwr_usb_stats(struct activity *a, int isdb, char *pre,
72abff
 __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
72abff
 					int curr, unsigned long long itv)
72abff
 {
72abff
-	/* FIXME */
72abff
+	int i;
72abff
+	struct stats_filesystem *sfc;
72abff
+
72abff
+	for (i = 0; i < a->nr; i++) {
72abff
+		sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
72abff
+
72abff
+		if (!sfc->f_blocks)
72abff
+			/* Size of filesystem is null: We are at the end of the list */
72abff
+			break;
72abff
+
72abff
+		render(isdb, pre, PT_USERND,
72abff
+		       "%s\tMBfsfree",
72abff
+		       "%s",
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       NOVAL,
72abff
+		       (double) sfc->f_bfree / 1024 / 1024,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre, PT_USERND,
72abff
+		       "%s\tMBfsused",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       NOVAL,
72abff
+		       (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre, PT_NOFLAG,
72abff
+		       "%s\t%%fsused",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       NOVAL,
72abff
+		       sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
72abff
+				     : 0.0,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre, PT_NOFLAG,
72abff
+		       "%s\t%%ufsused",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       NOVAL,
72abff
+		       sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
72abff
+				     : 0.0,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre, PT_USEINT,
72abff
+		       "%s\tIfree",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       sfc->f_ffree,
72abff
+		       NOVAL,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre, PT_USEINT,
72abff
+		       "%s\tIused",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       sfc->f_files - sfc->f_ffree,
72abff
+		       NOVAL,
72abff
+		       NULL);
72abff
+
72abff
+		render(isdb, pre,
72abff
+		       (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN),
72abff
+		       "%s\t%%Iused",
72abff
+		       NULL,
72abff
+		       cons(sv, sfc->fs_name, NOVAL),
72abff
+		       NOVAL,
72abff
+		       sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
72abff
+				    : 0.0,
72abff
+		       NULL);
72abff
+	}
72abff
 }
72abff
diff --git a/rndr_stats.h b/rndr_stats.h
72abff
index ff6452a..9de51b2 100644
72abff
--- a/rndr_stats.h
72abff
+++ b/rndr_stats.h
72abff
@@ -18,6 +18,7 @@
72abff
 #define PT_USEINT  0x0001	/* Use the integer arg, not double nor string */
72abff
 #define PT_NEWLIN  0x0002	/* Terminate the current output line */
72abff
 #define PT_USESTR  0x0004	/* Use the string arg */
72abff
+#define PT_USERND  0x0008	/* Double value, format %.0f */
72abff
 
72abff
 #define NOVAL      0		/* For placeholder zeros */
72abff
 #define DNOVAL     0.0		/* Wilma!  */
72abff
-- 
72abff
2.14.3
72abff