Skip to content

Commit d91ecce

Browse files
committed
Add option to display mountpoint names instead of filesystem names.
1 parent b8369bf commit d91ecce

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

man/sar.in

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,21 @@ Set the ending time of the report. The default ending time is
348348
18:00:00. Hours must be given in 24-hour format.
349349
This option can be used when data are read from
350350
or written to a file (options -f or -o).
351-
.IP -F
351+
.IP "-F [ MOUNT ]"
352352
Display statistics for currently mounted filesystems. Pseudo-filesystems are
353-
ignored. At the end of the report,
354-
.B sar
353+
ignored. At the end of the report,
354+
.B sar
355355
will display a summary of all those filesystems.
356356
Note that filesystems statistics depend on
357357
.B sadc
358358
option
359359
.B "-S XDISK"
360360
to be collected.
361+
Use of the
362+
.B MOUNT
363+
parameter keyword indicates that mountpoint will be reported instead of
364+
filesystem device.
365+
361366
The following values are displayed:
362367

363368
.B MBfsfree

pr_stats.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,11 +2500,11 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
25002500
int i, j;
25012501
struct stats_filesystem *sfc, *sfm;
25022502

2503-
25042503
if (dis) {
25052504
printf("\n%-11s MBfsfree MBfsused %%fsused %%ufsused"
2506-
" Ifree Iused %%Iused FILESYSTEM\n",
2507-
(dispavg ? _("Summary:") : timestamp[!curr]));
2505+
" Ifree Iused %%Iused %s\n",
2506+
(dispavg ? _("Summary:") : timestamp[!curr]),
2507+
DISPLAY_MOUNT(a->opt_flags) ? _("MOUNTPOINT") : _("FILESYSTEM"));
25082508
}
25092509

25102510
for (i = 0; i < a->nr; i++) {
@@ -2528,7 +2528,7 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
25282528
sfc->f_files - sfc->f_ffree,
25292529
sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
25302530
: 0.0,
2531-
sfc->fs_name);
2531+
DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
25322532

25332533
if (!dispavg) {
25342534
/* Save current filesystem in summary list */

rd_stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
20982098
st_filesystem_i->f_files = buf.f_files;
20992099
st_filesystem_i->f_ffree = buf.f_ffree;
21002100
strcpy(st_filesystem_i->fs_name, fs_name);
2101+
strcpy(st_filesystem_i->mountp, mountp);
21012102
}
21022103
}
21032104

rd_stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ struct stats_filesystem {
543543
unsigned long long f_files __attribute__ ((aligned (16)));
544544
unsigned long long f_ffree __attribute__ ((aligned (16)));
545545
char fs_name[MAX_FS_LEN] __attribute__ ((aligned (16)));
546+
char mountp[MAX_FS_LEN] __attribute__ ((aligned (16)));
546547
};
547548

548549
#define STATS_FILESYSTEM_SIZE (sizeof(struct stats_filesystem))

sa.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136

137137
#define COLLECT_PARTITIONS(m) (((m) & AO_F_DISK_PART) == AO_F_DISK_PART)
138138

139+
/* Output flags for option -F */
140+
#define AO_F_MOUNT 0x00000001
141+
142+
#define DISPLAY_MOUNT(m) (((m) & AO_F_MOUNT) == AO_F_MOUNT)
143+
139144
/*
140145
***************************************************************************
141146
* Various keywords and constants.

sa_common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,12 @@ int parse_sar_opt(char *argv[], int *opt, struct activity *act[],
15851585

15861586
case 'F':
15871587
SELECT_ACTIVITY(A_FILESYSTEM);
1588+
p = get_activity_position(act, A_FILESYSTEM, EXIT_IF_NOT_FOUND);
1589+
if (!*(argv[*opt] + i + 1) && argv[*opt + 1] && !strcmp(argv[*opt + 1], "MOUNT")) {
1590+
(*opt)++;
1591+
act[p]->opt_flags |= AO_F_MOUNT;
1592+
return 0;
1593+
}
15881594
break;
15891595

15901596
case 'H':

sar.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ void usage(char *progname)
107107
{
108108
print_usage_title(stderr, progname);
109109
fprintf(stderr, _("Options are:\n"
110-
"[ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F ] [ -H ] [ -h ] [ -p ] [ -q ]\n"
111-
"[ -R ] [ -r [ ALL ] ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ]\n"
112-
"[ -w ] [ -y ]\n"
110+
"[ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F [ MOUNTS ] ] [ -H ] [ -h ]\n"
111+
"[ -p ] [ -q ] [ -R ] [ -r [ ALL ] ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ]\n"
112+
"[ -v ] [ -W ] [ -w ] [ -y ]\n"
113113
"[ -I { <int> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ]\n"
114114
"[ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ]\n"
115115
"[ -j { ID | LABEL | PATH | UUID | ... } ]\n"
@@ -133,7 +133,8 @@ void display_help(char *progname)
133133
printf(_("\t-B\tPaging statistics\n"));
134134
printf(_("\t-b\tI/O and transfer rate statistics\n"));
135135
printf(_("\t-d\tBlock devices statistics\n"));
136-
printf(_("\t-F\tFilesystems statistics\n"));
136+
printf(_("\t-F [ MOUNTS ]\n"));
137+
printf(_("\t\tFilesystems statistics\n"));
137138
printf(_("\t-H\tHugepages utilization statistics\n"));
138139
printf(_("\t-I { <int> | SUM | ALL | XALL }\n"
139140
"\t\tInterrupts statistics\n"));
@@ -170,7 +171,7 @@ void display_help(char *progname)
170171
printf(_("\t-q\tQueue length and load average statistics\n"));
171172
printf(_("\t-R\tMemory statistics\n"));
172173
printf(_("\t-r [ ALL ]\n"
173-
"\tMemory utilization statistics\n"));
174+
"\t\tMemory utilization statistics\n"));
174175
printf(_("\t-S\tSwap space utilization statistics\n"));
175176
printf(_("\t-u [ ALL ]\n"
176177
"\t\tCPU utilization statistics\n"));

0 commit comments

Comments
 (0)