summaryrefslogtreecommitdiffstats
path: root/sbin/vinum/list.c
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>1999-03-31 08:43:40 +0000
committergrog <grog@FreeBSD.org>1999-03-31 08:43:40 +0000
commit5f7149e9f2807fdd14272eeed32d0c3a84b2120c (patch)
treea84f4cc00b5d08a8bfa4148c2392d39755e65da6 /sbin/vinum/list.c
parent2559617dbe9dc07254a3592a1c9cab9c93fe7faf (diff)
downloadFreeBSD-src-5f7149e9f2807fdd14272eeed32d0c3a84b2120c.zip
FreeBSD-src-5f7149e9f2807fdd14272eeed32d0c3a84b2120c.tar.gz
Change the meaning of the combination of -s and no -v option in the
list functions. Previously, it would produce a non-verbose listing of the objects followed individually by a statistics listing. Now it produces only a one-line-per-object statistics listing.
Diffstat (limited to 'sbin/vinum/list.c')
-rw-r--r--sbin/vinum/list.c207
1 files changed, 133 insertions, 74 deletions
diff --git a/sbin/vinum/list.c b/sbin/vinum/list.c
index 452416e..e7cc78b 100644
--- a/sbin/vinum/list.c
+++ b/sbin/vinum/list.c
@@ -35,7 +35,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
- * $Id: list.c,v 1.17 1999/01/17 02:58:44 grog Exp grog $
+ * $Id: list.c,v 1.18 1999/03/10 09:26:46 grog Exp grog $
*/
#include <ctype.h>
@@ -84,14 +84,17 @@ vinum_list(int argc, char *argv[], char *argv0[])
int i;
enum objecttype type;
+ if (stats & (!verbose)) /* just summary stats, */
+ printf("Object\t\t Reads\t\tBytes\tAverage\tRecover\t Writes\t\tBytes\tAverage\t Mblock Mstripe\n\n");
if (argc == 0)
listconfig(); /* list everything */
- else
+ else {
for (i = 0; i < argc; i++) {
object = find_object(argv[i], &type); /* look for it */
if (vinum_li(object, type))
fprintf(stderr, "Can't find object: %s\n", argv[i]);
}
+ }
}
/* List an object */
@@ -175,7 +178,7 @@ vinum_ldi(int driveno, int recurse)
printf("\t\t%9qd\t%9ld\n", freelist.offset, freelist.sectors);
}
}
- } else {
+ } else if (!stats) {
printf("D %-21s State: %s\tDevice %s\tAvail: %qd/%qd MB",
drive.label.name,
drive_state(drive.state),
@@ -189,19 +192,32 @@ vinum_ldi(int driveno, int recurse)
(int) ((drive.sectors_available * 100 * DEV_BSIZE) / drive.label.drive_size));
}
if (stats) {
- printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
- drive.reads,
- drive.bytes_read,
- roughlength(drive.bytes_read, 1));
- if (drive.reads != 0)
- printf("\t\tAverage read:\t%16qd bytes\n", drive.bytes_read / drive.reads);
- printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
- drive.writes,
- drive.bytes_written,
- roughlength(drive.bytes_written, 1));
- if (drive.writes != 0)
- printf("\t\tAverage write:\t%16qd bytes\n",
- drive.bytes_written / drive.writes);
+ if (verbose || Verbose) {
+ printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
+ drive.reads,
+ drive.bytes_read,
+ roughlength(drive.bytes_read, 1));
+ if (drive.reads != 0)
+ printf("\t\tAverage read:\t%16qd bytes\n", drive.bytes_read / drive.reads);
+ printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
+ drive.writes,
+ drive.bytes_written,
+ roughlength(drive.bytes_written, 1));
+ if (drive.writes != 0)
+ printf("\t\tAverage write:\t%16qd bytes\n",
+ drive.bytes_written / drive.writes);
+ } else { /* non-verbose stats */
+ printf("%-15s\t%7qd\t%15qd\t", drive.label.name, drive.reads, drive.bytes_read);
+ if (drive.reads != 0)
+ printf("%7qd\t\t", drive.bytes_read / drive.reads);
+ else
+ printf("\t\t");
+ printf("%7qd\t%15qd\t", drive.writes, drive.bytes_written);
+ if (drive.writes != 0)
+ printf("%7qd\n", drive.bytes_written / drive.writes);
+ else
+ printf("\n");
+ }
}
}
}
@@ -253,28 +269,42 @@ vinum_lvi(int volno, int recurse)
get_plex_info(&plex, vol.plex[vol.preferred_plex]);
printf("plex %d (%s)\n", vol.preferred_plex, plex.name);
}
- } else /* brief */
+ } else if (!stats) /* brief */
printf("V %-21s State: %s\tPlexes: %7d\tSize: %s\n",
vol.name,
volume_state(vol.state),
vol.plexes,
roughlength(vol.size << DEV_BSHIFT, 0));
if (stats) {
- printf("\t\tReads: \t%16qd\n\t\tRecovered:\t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
- vol.reads,
- vol.recovered_reads,
- vol.bytes_read,
- roughlength(vol.bytes_read, 1));
- if (vol.reads != 0)
- printf("\t\tAverage read:\t%16qd bytes\n", vol.bytes_read / vol.reads);
- printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
- vol.writes,
- vol.bytes_written,
- roughlength(vol.bytes_written, 1));
- if (vol.writes != 0)
- printf("\t\tAverage write:\t%16qd bytes\n",
- vol.bytes_written / vol.writes);
- printf("\t\tActive requests:\t%8d\n", vol.active);
+ if (verbose || Verbose) {
+ printf("\t\tReads: \t%16qd\n\t\tRecovered:\t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
+ vol.reads,
+ vol.recovered_reads,
+ vol.bytes_read,
+ roughlength(vol.bytes_read, 1));
+ if (vol.reads != 0)
+ printf("\t\tAverage read:\t%16qd bytes\n", vol.bytes_read / vol.reads);
+ printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
+ vol.writes,
+ vol.bytes_written,
+ roughlength(vol.bytes_written, 1));
+ if (vol.writes != 0)
+ printf("\t\tAverage write:\t%16qd bytes\n",
+ vol.bytes_written / vol.writes);
+ printf("\t\tActive requests:\t%8d\n", vol.active);
+ } else { /* brief stats listing */
+ printf("%-15s\t%7qd\t%15qd\t", vol.name, vol.reads, vol.bytes_read);
+ if (vol.reads != 0)
+ printf("%7qd\t", vol.bytes_read / vol.reads);
+ else
+ printf("\t");
+ printf("%7qd\t", vol.recovered_reads);
+ printf("%7qd\t%15qd\t", vol.writes, vol.bytes_written);
+ if (vol.writes != 0)
+ printf("%7qd\n", vol.bytes_written / vol.writes);
+ else
+ printf("\n");
+ }
}
if (vol.plexes > 0) {
int plexno;
@@ -358,7 +388,7 @@ vinum_lpi(int plexno, int recurse)
get_volume_info(&vol, plex.volno);
printf("\t\tPart of volume %s\n", vol.name);
}
- } else {
+ } else if (!stats) {
char *org = ""; /* organization */
switch (plex.organization) {
@@ -383,28 +413,42 @@ vinum_lpi(int plexno, int recurse)
roughlength(plex.length << DEV_BSHIFT, 0));
}
if (stats) {
- printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
- plex.reads,
- plex.bytes_read,
- roughlength(plex.bytes_read, 1));
- if (plex.reads != 0)
- printf("\t\tAverage read:\t%16qd bytes\n", plex.bytes_read / plex.reads);
- printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
- plex.writes,
- plex.bytes_written,
- roughlength(plex.bytes_written, 1));
- if (plex.writes != 0)
- printf("\t\tAverage write:\t%16qd bytes\n",
- plex.bytes_written / plex.writes);
- if (((plex.reads + plex.writes) > 0)
- && ((plex.organization == plex_striped)
- || (plex.organization == plex_raid5)))
- printf("\t\tMultiblock:\t%16qd (%d%%)\n"
- "\t\tMultistripe:\t%16qd (%d%%)\n",
- plex.multiblock,
- (int) (plex.multiblock * 100 / (plex.reads + plex.writes)),
- plex.multistripe,
- (int) (plex.multistripe * 100 / (plex.reads + plex.writes)));
+ if (verbose || Verbose) {
+ printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
+ plex.reads,
+ plex.bytes_read,
+ roughlength(plex.bytes_read, 1));
+ if (plex.reads != 0)
+ printf("\t\tAverage read:\t%16qd bytes\n", plex.bytes_read / plex.reads);
+ printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
+ plex.writes,
+ plex.bytes_written,
+ roughlength(plex.bytes_written, 1));
+ if (plex.writes != 0)
+ printf("\t\tAverage write:\t%16qd bytes\n",
+ plex.bytes_written / plex.writes);
+ if (((plex.reads + plex.writes) > 0)
+ && ((plex.organization == plex_striped)
+ || (plex.organization == plex_raid5)))
+ printf("\t\tMultiblock:\t%16qd (%d%%)\n"
+ "\t\tMultistripe:\t%16qd (%d%%)\n",
+ plex.multiblock,
+ (int) (plex.multiblock * 100 / (plex.reads + plex.writes)),
+ plex.multistripe,
+ (int) (plex.multistripe * 100 / (plex.reads + plex.writes)));
+ } else {
+ printf("%-15s\t%7qd\t%15qd\t", plex.name, plex.reads, plex.bytes_read);
+ if (plex.reads != 0)
+ printf("%7qd\t\t", plex.bytes_read / plex.reads);
+ else
+ printf("\t\t");
+ printf("%7qd\t%15qd\t", plex.writes, plex.bytes_written);
+ if (plex.writes != 0)
+ printf("%7qd\t", plex.bytes_written / plex.writes);
+ else
+ printf("\t");
+ printf("%7qd\t%7qd\n", plex.multiblock, plex.multistripe);
+ }
}
if (plex.subdisks > 0) {
int sdno;
@@ -484,7 +528,7 @@ vinum_lsi(int sdno, int recurse)
roughlength(sd.revive_blocksize, 0),
sd.revive_interval);
}
- } else {
+ } else if (!stats) { /* brief listing, no stats */
printf("S %-21s State: %s\tPO: %s ",
sd.name,
sd_state(sd.state),
@@ -493,19 +537,32 @@ vinum_lsi(int sdno, int recurse)
roughlength(sd.sectors << DEV_BSHIFT, 0));
}
if (stats) {
- printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
- sd.reads,
- sd.bytes_read,
- roughlength(sd.bytes_read, 1));
- if (sd.reads != 0)
- printf("\t\tAverage read:\t%16qd bytes\n", sd.bytes_read / sd.reads);
- printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
- sd.writes,
- sd.bytes_written,
- roughlength(sd.bytes_written, 1));
- if (sd.writes != 0)
- printf("\t\tAverage write:\t%16qd bytes\n",
- sd.bytes_written / sd.writes);
+ if (verbose || Verbose) {
+ printf("\t\tReads: \t%16qd\n\t\tBytes read:\t%16qd (%s)\n",
+ sd.reads,
+ sd.bytes_read,
+ roughlength(sd.bytes_read, 1));
+ if (sd.reads != 0)
+ printf("\t\tAverage read:\t%16qd bytes\n", sd.bytes_read / sd.reads);
+ printf("\t\tWrites: \t%16qd\n\t\tBytes written:\t%16qd (%s)\n",
+ sd.writes,
+ sd.bytes_written,
+ roughlength(sd.bytes_written, 1));
+ if (sd.writes != 0)
+ printf("\t\tAverage write:\t%16qd bytes\n",
+ sd.bytes_written / sd.writes);
+ } else {
+ printf("%-15s\t%7qd\t%15qd\t", sd.name, sd.reads, sd.bytes_read);
+ if (sd.reads != 0)
+ printf("%7qd\t\t", sd.bytes_read / sd.reads);
+ else
+ printf("\t\t");
+ printf("%7qd\t%15qd\t", sd.writes, sd.bytes_written);
+ if (sd.writes != 0)
+ printf("%7qd\n", sd.bytes_written / sd.writes);
+ else
+ printf("\n");
+ }
}
if (Verbose) {
get_drive_info(&drive, sd.driveno);
@@ -563,11 +620,13 @@ listconfig()
perror("Can't get vinum config");
return;
}
- printf("Configuration summary\n\n");
- printf("Drives:\t\t%d (%d configured)\n", vinum_conf.drives_used, vinum_conf.drives_allocated);
- printf("Volumes:\t%d (%d configured)\n", vinum_conf.volumes_used, vinum_conf.volumes_allocated);
- printf("Plexes:\t\t%d (%d configured)\n", vinum_conf.plexes_used, vinum_conf.plexes_allocated);
- printf("Subdisks:\t%d (%d configured)\n\n", vinum_conf.subdisks_used, vinum_conf.subdisks_allocated);
+ if (verbose || (!stats)) {
+ printf("Configuration summary\n\n");
+ printf("Drives:\t\t%d (%d configured)\n", vinum_conf.drives_used, vinum_conf.drives_allocated);
+ printf("Volumes:\t%d (%d configured)\n", vinum_conf.volumes_used, vinum_conf.volumes_allocated);
+ printf("Plexes:\t\t%d (%d configured)\n", vinum_conf.plexes_used, vinum_conf.plexes_allocated);
+ printf("Subdisks:\t%d (%d configured)\n\n", vinum_conf.subdisks_used, vinum_conf.subdisks_allocated);
+ }
vinum_ld(0, NULL, NULL);
printf("\n");
vinum_lv(0, NULL, NULL);
OpenPOWER on IntegriCloud