~ubuntu-branches/ubuntu/vivid/sysstat/vivid-proposed

« back to all changes in this revision

Viewing changes to iostat.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2011-02-07 20:57:05 UTC
  • mfrom: (12.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110207205705-6rbilpmalr1gkfra
Tags: 9.1.7-2
* Upload to unstable.
* debian/rules:
  + call dpkg-buildflags for initial values of CFLAGS & LDFLAGS;
  + use dh_auto_{configure,install,clean} debhelper commands;
  + provide build-arch and build-indep targets.
* Updated 00-Makefile.patch to make it possible to install isag only.
* 09-format-warning.patch: Fix a warning given by gcc -Wformat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * iostat: report CPU and I/O statistics
3
 
 * (C) 1998-2009 by Sebastien GODARD (sysstat <at> orange.fr)
 
3
 * (C) 1998-2010 by Sebastien GODARD (sysstat <at> orange.fr)
4
4
 *
5
5
 ***************************************************************************
6
6
 * This program is free software; you can redistribute it and/or modify it *
54
54
unsigned long long uptime[2]  = {0, 0};
55
55
unsigned long long uptime0[2] = {0, 0};
56
56
struct io_stats *st_iodev[2];
57
 
struct io_nfs_stats *st_ionfs[2];
58
 
struct io_hdr_stats *st_hdr_iodev, *st_hdr_ionfs;
 
57
struct io_hdr_stats *st_hdr_iodev;
59
58
struct io_dlist *st_dev_list;
60
59
 
61
60
int iodev_nr = 0;       /* Nb of devices and partitions found */
62
 
int ionfs_nr = 0;       /* Nb of NFS mounted directories found */
63
61
int cpu_nr = 0;         /* Nb of processors on the machine */
64
62
int dlist_idx = 0;      /* Nb of devices entered on the command line */
65
63
int flags = 0;          /* Flag for common options and system state */
 
64
unsigned int dm_major;  /* Device-mapper major number */
66
65
 
67
66
long interval = 0;
68
67
char timestamp[64];
80
79
{
81
80
        fprintf(stderr, _("Usage: %s [ options ] [ <interval> [ <count> ] ]\n"),
82
81
                progname);
83
 
 
84
 
        fprintf(stderr, _("Options are:\n"
85
 
                          "[ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
 
82
#ifdef DEBUG
 
83
        fprintf(stderr, _("Options are:\n"
 
84
                          "[ -c ] [ -d ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
 
85
                          "[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ] [ --debuginfo ]\n"));
 
86
#else
 
87
        fprintf(stderr, _("Options are:\n"
 
88
                          "[ -c ] [ -d ] [ -N ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ]\n"
86
89
                          "[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ]\n"));
 
90
#endif
87
91
        exit(1);
88
92
}
89
93
 
90
94
/*
91
95
 ***************************************************************************
 
96
 * Set disk output unit. Unit will be kB/s unless POSIXLY_CORRECT
 
97
 * environment variable has been set, in which case the output will be
 
98
 * expressed in blocks/s.
 
99
 ***************************************************************************
 
100
 */
 
101
void set_disk_output_unit(void)
 
102
{
 
103
        char *e;
 
104
        
 
105
        if (DISPLAY_KILOBYTES(flags) || DISPLAY_MEGABYTES(flags))
 
106
                return;
 
107
 
 
108
        /* Check POSIXLY_CORRECT environment variable */
 
109
        if ((e = getenv(ENV_POSIXLY_CORRECT)) == NULL) {
 
110
                /* Variable not set: Unit is kB/s and not blocks/s */
 
111
                flags |= I_D_KILOBYTES;
 
112
        }
 
113
}
 
114
 
 
115
/*
 
116
 ***************************************************************************
92
117
 * SIGALRM signal handler.
93
118
 *
94
119
 * IN:
122
147
 
123
148
/*
124
149
 ***************************************************************************
125
 
 * Set every disk_io or nfs_io entry to inactive state (unregistered).
 
150
 * Set every disk_io entry to inactive state (unregistered).
126
151
 *
127
152
 * IN:
128
 
 * @ioln_nr     Number of devices and partitions or NFS filesystems.
129
 
 * @st_hdr_ioln Pointer on first structure describing a device/partition or
130
 
 *              an NFS filesystem.
 
153
 * @ioln_nr     Number of devices and partitions.
 
154
 * @st_hdr_ioln Pointer on first structure describing a device/partition.
131
155
 ***************************************************************************
132
156
 */
133
157
void set_entries_inactive(int ioln_nr, struct io_hdr_stats *st_hdr_ioln)
145
169
 * Free inactive entries (mark them as unused).
146
170
 *
147
171
 * IN:
148
 
 * @ioln_nr     Number of devices and partitions or NFS filesystems.
149
 
 * @st_hdr_ioln Pointer on first structure describing a device/partition or
150
 
 *              an NFS filesystem.
 
172
 * @ioln_nr     Number of devices and partitions.
 
173
 * @st_hdr_ioln Pointer on first structure describing a device/partition.
151
174
 ***************************************************************************
152
175
 */
153
176
void free_inactive_entries(int ioln_nr, struct io_hdr_stats *st_hdr_ioln)
193
216
 
194
217
/*
195
218
 ***************************************************************************
196
 
 * Allocate and init I/O NFS directories structures.
197
 
 *
198
 
 * IN:
199
 
 * @ionfs_nr    Number of NFS filesystems.
200
 
 ***************************************************************************
201
 
 */
202
 
void salloc_nfs(int ionfs_nr)
203
 
{
204
 
        int i;
205
 
 
206
 
        for (i = 0; i < 2; i++) {
207
 
                if ((st_ionfs[i] =
208
 
                     (struct io_nfs_stats *) malloc(IO_NFS_STATS_SIZE * ionfs_nr)) == NULL) {
209
 
                        perror("malloc");
210
 
                        exit(4);
211
 
                }
212
 
                memset(st_ionfs[i], 0, IO_NFS_STATS_SIZE * ionfs_nr);
213
 
        }
214
 
 
215
 
        if ((st_hdr_ionfs =
216
 
             (struct io_hdr_stats *) malloc(IO_HDR_STATS_SIZE * ionfs_nr)) == NULL) {
217
 
                perror("malloc");
218
 
                exit(4);
219
 
        }
220
 
        memset(st_hdr_ionfs, 0, IO_HDR_STATS_SIZE * ionfs_nr);
221
 
}
222
 
 
223
 
/*
224
 
 ***************************************************************************
225
219
 * Allocate structures for devices entered on the command line.
226
220
 *
227
221
 * IN:
290
284
 */
291
285
void io_sys_init(void)
292
286
{
293
 
        int i;
294
 
 
295
287
        /* Allocate and init stat common counters */
296
288
        init_stats();
297
289
 
317
309
                        flags |= I_F_HAS_SYSFS;
318
310
                        iodev_nr += NR_DEV_PREALLOC;
319
311
                }
320
 
                /*
321
 
                 * Get number of block devices and partitions in /proc/partitions,
322
 
                 * those with statistics...
323
 
                 */
324
 
                else if ((iodev_nr = get_ppartitions_dev_nr(CNT_PART)) > 0) {
325
 
                        flags |= I_F_HAS_PPARTITIONS;
326
 
                        iodev_nr += NR_DEV_PREALLOC;
327
 
                }
328
 
                /* Get number of "disk_io:" entries in /proc/stat */
329
 
                else if ((iodev_nr = get_disk_io_nr()) > 0) {
330
 
                        flags |= I_F_PLAIN_KERNEL24;
331
 
                        iodev_nr += NR_DISK_PREALLOC;
332
 
                }
333
312
                else {
334
 
                        /* Assume we have an old kernel: stats for 4 disks are in /proc/stat */
335
 
                        iodev_nr = 4;
336
 
                        flags |= I_F_OLD_KERNEL;
 
313
                        fprintf(stderr, _("Cannot find disk data\n"));
 
314
                        exit(2);
337
315
                }
338
316
        }
339
317
        /*
341
319
         * iodev_nr must be <> 0.
342
320
         */
343
321
        salloc_device(iodev_nr);
344
 
 
345
 
        if (HAS_OLD_KERNEL(flags)) {
346
 
                struct io_hdr_stats *shi = st_hdr_iodev;
347
 
                /*
348
 
                 * If we have an old kernel with the stats for the first four disks
349
 
                 * in /proc/stat, then set the devices names to hdisk[0..3].
350
 
                 */
351
 
                for (i = 0; i < 4; i++, shi++) {
352
 
                        shi->used = TRUE;
353
 
                        sprintf(shi->name, "%s%d", K_HDISK, i);
354
 
                }
355
 
        }
356
 
 
357
 
        /* Get number of NFS directories in /proc/self/mountstats */
358
 
        if (DISPLAY_NFS(flags) &&
359
 
            ((ionfs_nr = get_nfs_mount_nr()) > 0)) {
360
 
                flags |= I_F_HAS_NFS;
361
 
                ionfs_nr += NR_NFS_PREALLOC;
362
 
 
363
 
                /* Allocate structures for number of NFS directories found */
364
 
                salloc_nfs(ionfs_nr);
365
 
        }
366
322
}
367
323
 
368
324
/*
385
341
                if (st_iodev[i]) {
386
342
                        free(st_iodev[i]);
387
343
                }
388
 
                
389
 
                /* Free I/O NFS directories structures */
390
 
                if (st_ionfs[i]) {
391
 
                        free(st_ionfs[i]);
392
 
                }
393
344
        }
394
345
        
395
346
        if (st_hdr_iodev) {
396
347
                free(st_hdr_iodev);
397
348
        }
398
 
        if (st_hdr_ionfs) {
399
 
                free(st_hdr_ionfs);
400
 
        }
401
349
}
402
350
 
403
351
/*
404
352
 ***************************************************************************
405
 
 * Save stats for current device, partition or NFS filesystem.
 
353
 * Save stats for current device or partition.
406
354
 *
407
355
 * IN:
408
 
 * @name        Name of the device/partition or NFS filesystem.
 
356
 * @name        Name of the device/partition.
409
357
 * @curr        Index in array for current sample statistics.
410
 
 * @st_io       Structure with device, partition or NFS statistics to save.
411
 
 * @ioln_nr     Number of devices and partitions or NFS filesystems.
412
 
 * @st_hdr_ioln Pointer on structures describing a device/partition or an
413
 
 *              NFS filesystem.
 
358
 * @st_io       Structure with device or partition to save.
 
359
 * @ioln_nr     Number of devices and partitions.
 
360
 * @st_hdr_ioln Pointer on structures describing a device/partition.
414
361
 *
415
362
 * OUT:
416
 
 * @st_hdr_ioln Pointer on structures describing a device/partition or an
417
 
 *              NFS filesystem.
 
363
 * @st_hdr_ioln Pointer on structures describing a device/partition.
418
364
 ***************************************************************************
419
365
 */
420
366
void save_stats(char *name, int curr, void *st_io, int ioln_nr,
423
369
        int i;
424
370
        struct io_hdr_stats *st_hdr_ioln_i;
425
371
        struct io_stats *st_iodev_i;
426
 
        struct io_nfs_stats *st_ionfs_i;
427
372
 
428
 
        /* Look for device or NFS directory in data table */
 
373
        /* Look for device in data table */
429
374
        for (i = 0; i < ioln_nr; i++) {
430
375
                st_hdr_ioln_i = st_hdr_ioln + i;
431
376
                if (!strcmp(st_hdr_ioln_i->name, name)) {
432
377
                        break;
433
378
                }
434
379
        }
435
 
        
 
380
 
436
381
        if (i == ioln_nr) {
437
382
                /*
438
383
                 * This is a new device: look for an unused entry to store it.
444
389
                                /* Unused entry found... */
445
390
                                st_hdr_ioln_i->used = TRUE; /* Indicate it is now used */
446
391
                                strcpy(st_hdr_ioln_i->name, name);
447
 
                                if (st_hdr_ioln == st_hdr_iodev) {
448
 
                                        st_iodev_i = st_iodev[!curr] + i;
449
 
                                        memset(st_iodev_i, 0, IO_STATS_SIZE);
450
 
                                }
451
 
                                else {
452
 
                                        st_ionfs_i = st_ionfs[!curr] + i;
453
 
                                        memset(st_ionfs_i, 0, IO_NFS_STATS_SIZE);
454
 
                                }
 
392
                                st_iodev_i = st_iodev[!curr] + i;
 
393
                                memset(st_iodev_i, 0, IO_STATS_SIZE);
455
394
                                break;
456
395
                        }
457
396
                }
459
398
        if (i < ioln_nr) {
460
399
                st_hdr_ioln_i = st_hdr_ioln + i;
461
400
                st_hdr_ioln_i->active = TRUE;
462
 
                if (st_hdr_ioln == st_hdr_iodev) {
463
 
                        st_iodev_i = st_iodev[curr] + i;
464
 
                        *st_iodev_i = *((struct io_stats *) st_io);
465
 
                }
466
 
                else {
467
 
                        st_ionfs_i = st_ionfs[curr] + i;
468
 
                        *st_ionfs_i = *((struct io_nfs_stats *) st_io);
469
 
                }
 
401
                st_iodev_i = st_iodev[curr] + i;
 
402
                *st_iodev_i = *((struct io_stats *) st_io);
470
403
        }
471
404
        /*
472
 
         * else it was a new device or NFS directory
 
405
         * else it was a new device
473
406
         * but there was no free structure to store it.
474
407
         */
475
408
}
476
409
 
477
410
/*
478
411
 ***************************************************************************
479
 
 * Read stats from /proc/stat file...
480
 
 * Used to get disk stats if /sys not available.
481
 
 *
482
 
 * IN:
483
 
 * @curr        Index in array for current sample statistics.
484
 
 ***************************************************************************
485
 
 */
486
 
void read_proc_stat(int curr)
487
 
{
488
 
        FILE *fp;
489
 
        char line[8192];
490
 
        int pos, i;
491
 
        unsigned long v_tmp[4];
492
 
        unsigned int v_major, v_index;
493
 
        struct io_stats *st_iodev_tmp[4];
494
 
 
495
 
        /*
496
 
         * Prepare pointers on the 4 disk structures in case we have a
497
 
         * /proc/stat file with "disk_rblk", etc. entries.
498
 
         */
499
 
        for (i = 0; i < 4; i++) {
500
 
                st_iodev_tmp[i] = st_iodev[curr] + i;
501
 
        }
502
 
 
503
 
        if ((fp = fopen(STAT, "r")) == NULL) {
504
 
                fprintf(stderr, _("Cannot open %s: %s\n"), STAT, strerror(errno));
505
 
                exit(2);
506
 
        }
507
 
 
508
 
        while (fgets(line, 8192, fp) != NULL) {
509
 
 
510
 
                if (!strncmp(line, "disk_rblk ", 10)) {
511
 
                        /*
512
 
                         * Read the number of blocks read from disk.
513
 
                         * A block is of indeterminate size.
514
 
                         * The size may vary depending on the device type.
515
 
                         */
516
 
                        sscanf(line + 10, "%lu %lu %lu %lu",
517
 
                               &v_tmp[0], &v_tmp[1], &v_tmp[2], &v_tmp[3]);
518
 
 
519
 
                        st_iodev_tmp[0]->dk_drive_rblk = v_tmp[0];
520
 
                        st_iodev_tmp[1]->dk_drive_rblk = v_tmp[1];
521
 
                        st_iodev_tmp[2]->dk_drive_rblk = v_tmp[2];
522
 
                        st_iodev_tmp[3]->dk_drive_rblk = v_tmp[3];
523
 
                }
524
 
 
525
 
                else if (!strncmp(line, "disk_wblk ", 10)) {
526
 
                        /* Read the number of blocks written to disk */
527
 
                        sscanf(line + 10, "%lu %lu %lu %lu",
528
 
                               &v_tmp[0], &v_tmp[1], &v_tmp[2], &v_tmp[3]);
529
 
        
530
 
                        st_iodev_tmp[0]->dk_drive_wblk = v_tmp[0];
531
 
                        st_iodev_tmp[1]->dk_drive_wblk = v_tmp[1];
532
 
                        st_iodev_tmp[2]->dk_drive_wblk = v_tmp[2];
533
 
                        st_iodev_tmp[3]->dk_drive_wblk = v_tmp[3];
534
 
                }
535
 
 
536
 
                else if (!strncmp(line, "disk ", 5)) {
537
 
                        /* Read the number of I/O done since the last reboot */
538
 
                        sscanf(line + 5, "%lu %lu %lu %lu",
539
 
                               &v_tmp[0], &v_tmp[1], &v_tmp[2], &v_tmp[3]);
540
 
                        
541
 
                        st_iodev_tmp[0]->dk_drive = v_tmp[0];
542
 
                        st_iodev_tmp[1]->dk_drive = v_tmp[1];
543
 
                        st_iodev_tmp[2]->dk_drive = v_tmp[2];
544
 
                        st_iodev_tmp[3]->dk_drive = v_tmp[3];
545
 
                }
546
 
 
547
 
                else if (!strncmp(line, "disk_io: ", 9)) {
548
 
                        struct io_stats sdev;
549
 
                        char dev_name[MAX_NAME_LEN];
550
 
 
551
 
                        pos = 9;
552
 
 
553
 
                        /* Every disk_io entry is potentially unregistered */
554
 
                        set_entries_inactive(iodev_nr, st_hdr_iodev);
555
 
        
556
 
                        /* Read disks I/O statistics (for 2.4 kernels) */
557
 
                        while (pos < strlen(line) - 1) {
558
 
                                /* Beware: a CR is already included in the line */
559
 
                                sscanf(line + pos, "(%u,%u):(%lu,%*u,%lu,%*u,%lu) ",
560
 
                                       &v_major, &v_index, &v_tmp[0], &v_tmp[1], &v_tmp[2]);
561
 
 
562
 
                                sprintf(dev_name, "dev%d-%d", v_major, v_index);
563
 
                                sdev.dk_drive      = v_tmp[0];
564
 
                                sdev.dk_drive_rblk = v_tmp[1];
565
 
                                sdev.dk_drive_wblk = v_tmp[2];
566
 
                                save_stats(dev_name, curr, &sdev, iodev_nr, st_hdr_iodev);
567
 
 
568
 
                                pos += strcspn(line + pos, " ") + 1;
569
 
                        }
570
 
 
571
 
                        /* Free structures corresponding to unregistered disks */
572
 
                        free_inactive_entries(iodev_nr, st_hdr_iodev);
573
 
                }
574
 
        }
575
 
 
576
 
        fclose(fp);
577
 
}
578
 
 
579
 
/*
580
 
 ***************************************************************************
581
412
 * Read sysfs stat for current block device or partition.
582
413
 *
583
414
 * IN:
848
679
                        }
849
680
                }
850
681
 
851
 
                if ((DISPLAY_DEVMAP_NAME(flags)) && (major == DEVMAP_MAJOR)) {
 
682
                if ((DISPLAY_DEVMAP_NAME(flags)) && (major == dm_major)) {
852
683
                        /*
853
684
                         * If the device is a device mapper device, try to get its
854
685
                         * assigned name of its logical device.
869
700
 
870
701
/*
871
702
 ***************************************************************************
872
 
 * Read stats from /proc/partitions.
873
 
 *
874
 
 * IN:
875
 
 * @curr        Index in array for current sample statistics.
876
 
 ***************************************************************************
877
 
 */
878
 
void read_ppartitions_stat(int curr)
879
 
{
880
 
        FILE *fp;
881
 
        char line[256], dev_name[MAX_NAME_LEN];
882
 
        struct io_stats sdev;
883
 
        unsigned long rd_ios, rd_merges, rd_ticks, wr_ios, wr_merges, wr_ticks;
884
 
        unsigned long ios_pgr, tot_ticks, rq_ticks;
885
 
        unsigned long long rd_sec, wr_sec;
886
 
        char *ioc_dname, *dm_name;
887
 
        unsigned int major, minor;
888
 
 
889
 
        /* Every I/O device entry is potentially unregistered */
890
 
        set_entries_inactive(iodev_nr, st_hdr_iodev);
891
 
 
892
 
        if ((fp = fopen(PPARTITIONS, "r")) == NULL)
893
 
                return;
894
 
 
895
 
        while (fgets(line, 256, fp) != NULL) {
896
 
                /* major minor #blocks name rio rmerge rsect ruse wio wmerge wsect wuse running use aveq */
897
 
                if (sscanf(line, "%u %u %*u %s %lu %lu %llu %lu %lu %lu %llu"
898
 
                           " %lu %lu %lu %lu",
899
 
                           &major, &minor, dev_name,
900
 
                           &rd_ios, &rd_merges, &rd_sec, &rd_ticks, &wr_ios, &wr_merges,
901
 
                           &wr_sec, &wr_ticks, &ios_pgr, &tot_ticks, &rq_ticks) == 14) {
902
 
                        /* Device or partition */
903
 
                        sdev.rd_ios     = rd_ios;  sdev.rd_merges = rd_merges;
904
 
                        sdev.rd_sectors = rd_sec;  sdev.rd_ticks  = rd_ticks;
905
 
                        sdev.wr_ios     = wr_ios;  sdev.wr_merges = wr_merges;
906
 
                        sdev.wr_sectors = wr_sec;  sdev.wr_ticks  = wr_ticks;
907
 
                        sdev.ios_pgr    = ios_pgr; sdev.tot_ticks = tot_ticks;
908
 
                        sdev.rq_ticks   = rq_ticks;
909
 
                }
910
 
                else
911
 
                        /* Unknown entry: Ignore it */
912
 
                        continue;
913
 
 
914
 
                if ((ioc_dname = ioc_name(major, minor)) != NULL) {
915
 
                        if (strcmp(dev_name, ioc_dname) && strcmp(ioc_dname, K_NODEV)) {
916
 
                                /* Compensate for EMC PowerPath driver bug */
917
 
                                strncpy(dev_name, ioc_dname, MAX_NAME_LEN);
918
 
                        }
919
 
                }
920
 
 
921
 
                if ((DISPLAY_DEVMAP_NAME(flags)) && (major == DEVMAP_MAJOR)) {
922
 
                        /* Get device mapper logical name */
923
 
                        dm_name = transform_devmapname(major, minor);
924
 
                        if (dm_name) {
925
 
                                strcpy(dev_name, dm_name);
926
 
                        }
927
 
                }
928
 
 
929
 
                save_stats(dev_name, curr, &sdev, iodev_nr, st_hdr_iodev);
930
 
        }
931
 
        fclose(fp);
932
 
 
933
 
        /* Free structures corresponding to unregistered devices */
934
 
        free_inactive_entries(iodev_nr, st_hdr_iodev);
935
 
}
936
 
 
937
 
/*
938
 
 ***************************************************************************
939
 
 * Read NFS-mount directories stats from /proc/self/mountstats.
940
 
 *
941
 
 * IN:
942
 
 * @curr        Index in array for current sample statistics.
943
 
 ***************************************************************************
944
 
 */
945
 
void read_nfs_stat(int curr)
946
 
{
947
 
        FILE *fp;
948
 
        int sw = 0;
949
 
        char line[8192];
950
 
        char *xprt_line;
951
 
        char nfs_name[MAX_NAME_LEN];
952
 
        char mount[10], on[10], prefix[10], aux[32];
953
 
        char operation[16];
954
 
        struct io_nfs_stats snfs;
955
 
        long int v1;
956
 
 
957
 
        /* Every I/O NFS entry is potentially unregistered */
958
 
        set_entries_inactive(ionfs_nr, st_hdr_ionfs);
959
 
 
960
 
        if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
961
 
                return;
962
 
 
963
 
        sprintf(aux, "%%%ds %%10s %%10s",
964
 
                MAX_NAME_LEN < 200 ? MAX_NAME_LEN : 200);
965
 
 
966
 
        while (fgets(line, 256, fp) != NULL) {
967
 
 
968
 
                /* read NFS directory name */
969
 
                if (!strncmp(line, "device", 6)) {
970
 
                        sw = 0;
971
 
                        sscanf(line + 6, aux, nfs_name, mount, on);
972
 
                        if ((!strncmp(mount, "mounted", 7)) && (!strncmp(on, "on", 2))) {
973
 
                                sw = 1;
974
 
                        }
975
 
                }
976
 
 
977
 
                sscanf(line, "%10s", prefix);
978
 
                if (sw && (!strncmp(prefix, "bytes:", 6))) {
979
 
                        /* Read the stats for the last NFS-mounted directory */
980
 
                        sscanf(strstr(line, "bytes:") + 6, "%llu %llu %llu %llu %llu %llu",
981
 
                               &snfs.rd_normal_bytes, &snfs.wr_normal_bytes,
982
 
                               &snfs.rd_direct_bytes, &snfs.wr_direct_bytes,
983
 
                               &snfs.rd_server_bytes, &snfs.wr_server_bytes);
984
 
                        sw = 2;
985
 
                }
986
 
 
987
 
                if ((sw == 2) && (!strncmp(prefix, "xprt:", 5))) {
988
 
                        /*
989
 
                         * Read extended statistic for the last NFS-mounted directory
990
 
                         * - number of sent rpc requests.
991
 
                         */
992
 
                        xprt_line = (strstr(line, "xprt:") + 6);
993
 
                        /* udp, tcp or rdma data */
994
 
                        if (!strncmp(xprt_line, "udp", 3)) {
995
 
                                /* port bind_count sends recvs (bad_xids req_u bklog_u) */
996
 
                                sscanf(strstr(xprt_line, "udp") + 4, "%*u %*u %lu",
997
 
                                       &snfs.rpc_sends);
998
 
                        }
999
 
                        if (!strncmp(xprt_line, "tcp", 3)) {
1000
 
                                /*
1001
 
                                 * port bind_counter connect_count connect_time idle_time
1002
 
                                 * sends recvs (bad_xids req_u bklog_u)
1003
 
                                 */
1004
 
                                sscanf(strstr(xprt_line, "tcp") + 4,
1005
 
                                       "%*u %*u %*u %*u %*d %lu",
1006
 
                                       &snfs.rpc_sends);
1007
 
                        }
1008
 
                        if (!strncmp(xprt_line,"rdma", 4)) {
1009
 
                                /*
1010
 
                                 * 0(port) bind_count connect_count connect_time idle_time
1011
 
                                 * sends recvs (bad_xids req_u bklog_u...)
1012
 
                                 */
1013
 
                                sscanf(strstr(xprt_line, "rdma") + 5,
1014
 
                                       "%*u %*u %*u %*u %*d %lu",
1015
 
                                       &snfs.rpc_sends);
1016
 
                        }
1017
 
                        sw = 3;
1018
 
                }
1019
 
 
1020
 
                if ((sw == 3) && (!strncmp(prefix, "per-op", 6))) {
1021
 
                        sw = 4;
1022
 
                        while (sw == 4) {
1023
 
                                fgets(line, 256, fp);
1024
 
                                sscanf(line, "%15s %lu", operation, &v1);
1025
 
                                if (!strncmp(operation, "READ:", 5)) {
1026
 
                                        snfs.nfs_rops = v1;
1027
 
                                }
1028
 
                                else if (!strncmp(operation, "WRITE:", 6)) {
1029
 
                                        snfs.nfs_wops = v1;
1030
 
                                        save_stats(nfs_name, curr, &snfs, ionfs_nr, st_hdr_ionfs);
1031
 
                                        sw = 0;
1032
 
                                }
1033
 
                        }
1034
 
                }
1035
 
        }
1036
 
 
1037
 
        fclose(fp);
1038
 
 
1039
 
        /* Free structures corresponding to unregistered devices */
1040
 
        free_inactive_entries(ionfs_nr, st_hdr_ionfs);
1041
 
}
1042
 
 
1043
 
/*
1044
 
 ***************************************************************************
1045
703
 * Display CPU utilization.
1046
704
 *
1047
705
 * IN:
1095
753
                else {
1096
754
                        printf("   rsec/s   wsec/s");
1097
755
                }
1098
 
                printf(" avgrq-sz avgqu-sz   await  svctm  %%util\n");
 
756
                printf(" avgrq-sz avgqu-sz   await r_await w_await  svctm  %%util\n");
1099
757
        }
1100
758
        else {
1101
759
                /* Basic stats */
1116
774
 
1117
775
/*
1118
776
 ***************************************************************************
1119
 
 * Display NFS stats header.
1120
 
 *
1121
 
 * OUT:
1122
 
 * @fctr        Conversion factor.
1123
 
 ***************************************************************************
1124
 
 */
1125
 
void write_nfs_stat_header(int *fctr)
1126
 
{
1127
 
        printf("Filesystem:           ");
1128
 
        if (DISPLAY_KILOBYTES(flags)) {
1129
 
                printf("    rkB_nor/s    wkB_nor/s    rkB_dir/s    wkB_dir/s"
1130
 
                       "    rkB_svr/s    wkB_svr/s");
1131
 
                *fctr = 1024;
1132
 
        }
1133
 
        else if (DISPLAY_MEGABYTES(flags)) {
1134
 
                printf("    rMB_nor/s    wMB_nor/s    rMB_dir/s    wMB_dir/s"
1135
 
                       "    rMB_svr/s    wMB_svr/s");
1136
 
                *fctr = 1024 * 1024;
1137
 
        }
1138
 
        else {
1139
 
                printf("   rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s"
1140
 
                       "   rBlk_svr/s   wBlk_svr/s");
1141
 
                *fctr = 512;
1142
 
        }
1143
 
        printf("     ops/s    rops/s    wops/s\n");
1144
 
}
1145
 
 
1146
 
/*
1147
 
 ***************************************************************************
1148
777
 * Display extended stats, read from /proc/{diskstats,partitions} or /sys.
1149
778
 *
1150
779
 * IN:
1162
791
{
1163
792
        struct stats_disk sdc, sdp;
1164
793
        struct ext_disk_stats xds;
 
794
        double r_await, w_await;
1165
795
        
1166
796
        /*
1167
797
         * Counters overflows are possible, but don't need to be handled in
1190
820
        
1191
821
        compute_ext_disk_stats(&sdc, &sdp, itv, &xds);
1192
822
        
1193
 
        /*      DEV   rrq/s wrq/s   r/s   w/s  rsec  wsec  rqsz  qusz await svctm %util */
1194
 
        printf("%-13s %8.2f %8.2f %7.2f %7.2f %8.2f %8.2f %8.2f %8.2f %7.2f %6.2f %6.2f\n",
 
823
        r_await = (ioi->rd_ios - ioj->rd_ios) ?
 
824
                  (ioi->rd_ticks - ioj->rd_ticks) /
 
825
                  ((double) (ioi->rd_ios - ioj->rd_ios)) : 0.0;
 
826
        w_await = (ioi->wr_ios - ioj->wr_ios) ?
 
827
                  (ioi->wr_ticks - ioj->wr_ticks) /
 
828
                  ((double) (ioi->wr_ios - ioj->wr_ios)) : 0.0;
 
829
 
 
830
        /*      DEV   rrq/s wrq/s   r/s   w/s  rsec  wsec  rqsz  qusz await r_await w_await svctm %util */
 
831
        printf("%-13s %8.2f %8.2f %7.2f %7.2f %8.2f %8.2f %8.2f %8.2f %7.2f %7.2f %7.2f %6.2f %6.2f\n",
1195
832
               shi->name,
1196
833
               S_VALUE(ioj->rd_merges, ioi->rd_merges, itv),
1197
834
               S_VALUE(ioj->wr_merges, ioi->wr_merges, itv),
1202
839
               xds.arqsz,
1203
840
               S_VALUE(ioj->rq_ticks, ioi->rq_ticks, itv) / 1000.0,
1204
841
               xds.await,
 
842
               r_await,
 
843
               w_await,
1205
844
               /* The ticks output is biased to output 1000 ticks per second */
1206
845
               xds.svctm,
1207
846
               /* Again: Ticks in milliseconds */
1210
849
 
1211
850
/*
1212
851
 ***************************************************************************
1213
 
 * Write basic stats, read from /proc/stat, /proc/{diskstats,partitions}
1214
 
 * or from sysfs.
 
852
 * Write basic stats, read from /proc/diskstats or from sysfs.
1215
853
 *
1216
854
 * IN:
1217
855
 * @curr        Index in array for current sample statistics.
1230
868
 
1231
869
        printf("%-13s", shi->name);
1232
870
 
1233
 
        if (HAS_SYSFS(flags) ||
1234
 
            HAS_DISKSTATS(flags) || HAS_PPARTITIONS(flags)) {
1235
 
                /* Print stats coming from /sys or /proc/{diskstats,partitions} */
1236
 
                rd_sec = ioi->rd_sectors - ioj->rd_sectors;
1237
 
                if ((ioi->rd_sectors < ioj->rd_sectors) && (ioj->rd_sectors <= 0xffffffff)) {
1238
 
                        rd_sec &= 0xffffffff;
1239
 
                }
1240
 
                wr_sec = ioi->wr_sectors - ioj->wr_sectors;
1241
 
                if ((ioi->wr_sectors < ioj->wr_sectors) && (ioj->wr_sectors <= 0xffffffff)) {
1242
 
                        wr_sec &= 0xffffffff;
1243
 
                }
1244
 
 
1245
 
                printf(" %8.2f %12.2f %12.2f %10llu %10llu\n",
1246
 
                       S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv),
1247
 
                       ll_s_value(ioj->rd_sectors, ioi->rd_sectors, itv) / fctr,
1248
 
                       ll_s_value(ioj->wr_sectors, ioi->wr_sectors, itv) / fctr,
1249
 
                       (unsigned long long) rd_sec / fctr,
1250
 
                       (unsigned long long) wr_sec / fctr);
1251
 
        }
1252
 
        else {
1253
 
                /* Print stats coming from /proc/stat */
1254
 
                printf(" %8.2f %12.2f %12.2f %10lu %10lu\n",
1255
 
                       S_VALUE(ioj->dk_drive, ioi->dk_drive, itv),
1256
 
                       S_VALUE(ioj->dk_drive_rblk, ioi->dk_drive_rblk, itv) / fctr,
1257
 
                       S_VALUE(ioj->dk_drive_wblk, ioi->dk_drive_wblk, itv) / fctr,
1258
 
                       (ioi->dk_drive_rblk - ioj->dk_drive_rblk) / fctr,
1259
 
                       (ioi->dk_drive_wblk - ioj->dk_drive_wblk) / fctr);
1260
 
        }
1261
 
}
1262
 
 
1263
 
 
1264
 
/*
1265
 
 ***************************************************************************
1266
 
 * Write NFS stats read from /proc/self/mountstats.
1267
 
 *
1268
 
 * IN:
1269
 
 * @curr        Index in array for current sample statistics.
1270
 
 * @itv         Interval of time.
1271
 
 * @fctr        Conversion factor.
1272
 
 * @shi         Structures describing the NFS filesystems.
1273
 
 * @ioi         Current sample statistics.
1274
 
 * @ioj         Previous sample statistics.
1275
 
 ***************************************************************************
1276
 
 */
1277
 
void write_nfs_stat(int curr, unsigned long long itv, int fctr,
1278
 
                    struct io_hdr_stats *shi, struct io_nfs_stats *ioni,
1279
 
                    struct io_nfs_stats *ionj)
1280
 
{
1281
 
        if (DISPLAY_HUMAN_READ(flags)) {
1282
 
                printf("%-22s\n%23s", shi->name, "");
1283
 
        }
1284
 
        else {
1285
 
                printf("%-22s ", shi->name);
1286
 
        }
1287
 
        printf("%12.2f %12.2f %12.2f %12.2f %12.2f %12.2f %9.2f %9.2f %9.2f\n",
1288
 
               S_VALUE(ionj->rd_normal_bytes, ioni->rd_normal_bytes, itv) / fctr,
1289
 
               S_VALUE(ionj->wr_normal_bytes, ioni->wr_normal_bytes, itv) / fctr,
1290
 
               S_VALUE(ionj->rd_direct_bytes, ioni->rd_direct_bytes, itv) / fctr,
1291
 
               S_VALUE(ionj->wr_direct_bytes, ioni->wr_direct_bytes, itv) / fctr,
1292
 
               S_VALUE(ionj->rd_server_bytes, ioni->rd_server_bytes, itv) / fctr,
1293
 
               S_VALUE(ionj->wr_server_bytes, ioni->wr_server_bytes, itv) / fctr,
1294
 
               S_VALUE(ionj->rpc_sends, ioni->rpc_sends, itv),
1295
 
               S_VALUE(ionj->nfs_rops,  ioni->nfs_rops,  itv),
1296
 
               S_VALUE(ionj->nfs_wops,  ioni->nfs_wops,  itv));
 
871
        /* Print stats coming from /sys or /proc/diskstats */
 
872
        rd_sec = ioi->rd_sectors - ioj->rd_sectors;
 
873
        if ((ioi->rd_sectors < ioj->rd_sectors) && (ioj->rd_sectors <= 0xffffffff)) {
 
874
                rd_sec &= 0xffffffff;
 
875
        }
 
876
        wr_sec = ioi->wr_sectors - ioj->wr_sectors;
 
877
        if ((ioi->wr_sectors < ioj->wr_sectors) && (ioj->wr_sectors <= 0xffffffff)) {
 
878
                wr_sec &= 0xffffffff;
 
879
        }
 
880
 
 
881
        printf(" %8.2f %12.2f %12.2f %10llu %10llu\n",
 
882
               S_VALUE(ioj->rd_ios + ioj->wr_ios, ioi->rd_ios + ioi->wr_ios, itv),
 
883
               ll_s_value(ioj->rd_sectors, ioi->rd_sectors, itv) / fctr,
 
884
               ll_s_value(ioj->wr_sectors, ioi->wr_sectors, itv) / fctr,
 
885
               (unsigned long long) rd_sec / fctr,
 
886
               (unsigned long long) wr_sec / fctr);
1297
887
}
1298
888
 
1299
889
/*
1324
914
                        strftime(timestamp, sizeof(timestamp), "%x %X", rectime);
1325
915
                }
1326
916
                printf("%s\n", timestamp);
 
917
#ifdef DEBUG
 
918
                if (DISPLAY_DEBUG(flags)) {
 
919
                        fprintf(stderr, "%s\n", timestamp);
 
920
                }
 
921
#endif
1327
922
        }
1328
923
 
1329
924
        /* Interval is multiplied by the number of processors */
1330
925
        itv = get_interval(uptime[!curr], uptime[curr]);
1331
926
 
1332
927
        if (DISPLAY_CPU(flags)) {
 
928
#ifdef DEBUG
 
929
                if (DISPLAY_DEBUG(flags)) {
 
930
                        /* Debug output */
 
931
                        fprintf(stderr, "itv=%llu st_cpu[curr]{ cpu_user=%llu cpu_nice=%llu "
 
932
                                        "cpu_sys=%llu cpu_idle=%llu cpu_iowait=%llu cpu_steal=%llu "
 
933
                                        "cpu_hardirq=%llu cpu_softirq=%llu cpu_guest=%llu }\n",
 
934
                                itv,
 
935
                                st_cpu[curr]->cpu_user,
 
936
                                st_cpu[curr]->cpu_nice,
 
937
                                st_cpu[curr]->cpu_sys,
 
938
                                st_cpu[curr]->cpu_idle,
 
939
                                st_cpu[curr]->cpu_iowait,
 
940
                                st_cpu[curr]->cpu_steal,
 
941
                                st_cpu[curr]->cpu_hardirq,
 
942
                                st_cpu[curr]->cpu_softirq,
 
943
                                st_cpu[curr]->cpu_guest
 
944
                                );
 
945
                }
 
946
#endif
 
947
 
1333
948
                /* Display CPU utilization */
1334
949
                write_cpu_stat(curr, itv);
1335
950
        }
1347
962
                /* Display disk stats header */
1348
963
                write_disk_stat_header(&fctr);
1349
964
 
1350
 
                if (DISPLAY_EXTENDED(flags) &&
1351
 
                    (HAS_OLD_KERNEL(flags) || HAS_PLAIN_KERNEL24(flags))) {
1352
 
                        /* No extended stats with old 2.2-2.4 kernels */
1353
 
                        printf("\n");
1354
 
                        return;
1355
 
                }
1356
 
 
1357
965
                for (i = 0; i < iodev_nr; i++, shi++) {
1358
966
                        if (shi->used) {
1359
967
        
1361
969
                                        /*
1362
970
                                         * With sysfs, only stats for the requested
1363
971
                                         * devices are read.
1364
 
                                         * With /proc/{diskstats,partitions}, stats for
 
972
                                         * With /proc/diskstats, stats for
1365
973
                                         * every device are read. Thus we need to check
1366
974
                                         * if stats for current device are to be displayed.
1367
975
                                         */
1379
987
                                ioj = st_iodev[!curr] + i;
1380
988
 
1381
989
                                if (!DISPLAY_UNFILTERED(flags)) {
1382
 
                                        if (HAS_OLD_KERNEL(flags) ||
1383
 
                                            HAS_PLAIN_KERNEL24(flags)) {
1384
 
                                                if (!ioi->dk_drive)
1385
 
                                                        continue;
1386
 
                                        }
1387
 
                                        else {
1388
 
                                                if (!ioi->rd_ios && !ioi->wr_ios)
1389
 
                                                        continue;
1390
 
                                        }
 
990
                                        if (!ioi->rd_ios && !ioi->wr_ios)
 
991
                                                continue;
1391
992
                                }
1392
993
                                
1393
994
                                if (DISPLAY_ZERO_OMIT(flags)) {
1394
 
                                        if (HAS_OLD_KERNEL(flags) ||
1395
 
                                            HAS_PLAIN_KERNEL24(flags)) {
1396
 
                                                if (ioi->dk_drive == ioj->dk_drive)
1397
 
                                                        /* No activity: Ignore it */
1398
 
                                                        continue;
1399
 
                                        }
1400
 
                                        else {
1401
 
                                                if ((ioi->rd_ios == ioj->rd_ios) &&
1402
 
                                                    (ioi->wr_ios == ioj->wr_ios))
1403
 
                                                        /* No activity: Ignore it */
1404
 
                                                        continue;
1405
 
                                        }
1406
 
                                }
 
995
                                        if ((ioi->rd_ios == ioj->rd_ios) &&
 
996
                                                (ioi->wr_ios == ioj->wr_ios))
 
997
                                                /* No activity: Ignore it */
 
998
                                                continue;
 
999
                                }
 
1000
#ifdef DEBUG
 
1001
                                if (DISPLAY_DEBUG(flags)) {
 
1002
                                        /* Debug output */
 
1003
                                        fprintf(stderr, "name=%s itv=%llu fctr=%d ioi{ rd_sectors=%llu "
 
1004
                                                        "wr_sectors=%llu rd_ios=%lu rd_merges=%lu rd_ticks=%lu "
 
1005
                                                        "wr_ios=%lu wr_merges=%lu wr_ticks=%lu ios_pgr=%lu tot_ticks=%lu "
 
1006
                                                        "rq_ticks=%lu dk_drive=%lu dk_drive_rblk=%lu dk_drive_wblk=%lu }\n",
 
1007
                                                shi->name,
 
1008
                                                itv,
 
1009
                                                fctr,
 
1010
                                                ioi->rd_sectors,
 
1011
                                                ioi->wr_sectors,
 
1012
                                                ioi->rd_ios,
 
1013
                                                ioi->rd_merges,
 
1014
                                                ioi->rd_ticks,
 
1015
                                                ioi->wr_ios,
 
1016
                                                ioi->wr_merges,
 
1017
                                                ioi->wr_ticks,
 
1018
                                                ioi->ios_pgr,
 
1019
                                                ioi->tot_ticks,
 
1020
                                                ioi->rq_ticks,
 
1021
                                                ioi->dk_drive,
 
1022
                                                ioi->dk_drive_rblk,
 
1023
                                                ioi->dk_drive_wblk
 
1024
                                                );
 
1025
                                }
 
1026
#endif
1407
1027
 
1408
1028
                                if (DISPLAY_EXTENDED(flags)) {
1409
1029
                                        write_ext_stat(curr, itv, fctr, shi, ioi, ioj);
1415
1035
                }
1416
1036
                printf("\n");
1417
1037
        }
1418
 
 
1419
 
        if (DISPLAY_NFS(flags)) {
1420
 
                struct io_nfs_stats *ioni, *ionj;
1421
 
 
1422
 
                shi = st_hdr_ionfs;
1423
 
 
1424
 
                /* Display NFS stats header */
1425
 
                write_nfs_stat_header(&fctr);
1426
 
 
1427
 
                if (!HAS_NFS(flags)) {
1428
 
                        /* No NFS stats */
1429
 
                        printf("\n");
1430
 
                        return;
1431
 
                }
1432
 
 
1433
 
                for (i = 0; i < ionfs_nr; i++, shi++) {
1434
 
                        if (shi->used) {
1435
 
        
1436
 
                                ioni = st_ionfs[curr] + i;
1437
 
                                ionj = st_ionfs[!curr] + i;
1438
 
                                write_nfs_stat(curr, itv, fctr, shi, ioni, ionj);
1439
 
                        }
1440
 
                }
1441
 
                printf("\n");
1442
 
        }
1443
1038
}
1444
1039
 
1445
1040
/*
1476
1071
                 */
1477
1072
                read_stat_cpu(st_cpu[curr], 2, &(uptime[curr]), &(uptime0[curr]));
1478
1073
 
1479
 
                /*
1480
 
                 * If we don't want extended statistics, and if /proc/diskstats and
1481
 
                 * /proc/partitions don't exist, and /sys is not mounted, then
1482
 
                 * we try to get disks stats from /proc/stat.
1483
 
                 */
1484
 
                if (!DISPLAY_EXTENDED(flags) && !HAS_DISKSTATS(flags) &&
1485
 
                    !HAS_PPARTITIONS(flags) && !HAS_SYSFS(flags)) {
1486
 
                        read_proc_stat(curr);
1487
 
                }
1488
 
 
1489
1074
                if (dlist_idx) {
1490
1075
                        /*
1491
1076
                         * A device or partition name was entered on the command line,
1497
1082
                        else if (HAS_SYSFS(flags)) {
1498
1083
                                read_sysfs_dlist_stat(curr);
1499
1084
                        }
1500
 
                        else if (HAS_PPARTITIONS(flags) && !DISPLAY_PARTITIONS(flags)) {
1501
 
                                read_ppartitions_stat(curr);
1502
 
                        }
1503
1085
                }
1504
1086
                else {
1505
1087
                        /*
1512
1094
                        else if (HAS_SYSFS(flags)) {
1513
1095
                                read_sysfs_stat(curr);
1514
1096
                        }
1515
 
                        else if (HAS_PPARTITIONS(flags)) {
1516
 
                                read_ppartitions_stat(curr);
1517
 
                        }
1518
 
                }
1519
 
 
1520
 
                /* Read NFS directories stats */
1521
 
                if (HAS_NFS(flags)) {
1522
 
                        read_nfs_stat(curr);
1523
1097
                }
1524
1098
 
1525
1099
                /* Get time */
1548
1122
{
1549
1123
        int it = 0;
1550
1124
        int opt = 1;
1551
 
        int i;
 
1125
        int i, report_set = FALSE;
1552
1126
        long count = 1;
1553
1127
        struct utsname header;
1554
1128
        struct io_dlist *st_dev_list_i;
1596
1170
                        }
1597
1171
                }
1598
1172
 
 
1173
#ifdef DEBUG
 
1174
                else if (!strcmp(argv[opt], "--debuginfo")) {
 
1175
                        flags |= I_D_DEBUG;
 
1176
                        opt++;
 
1177
                }
 
1178
#endif
 
1179
 
1599
1180
                else if (!strncmp(argv[opt], "-", 1)) {
1600
1181
                        for (i = 1; *(argv[opt] + i); i++) {
1601
1182
 
1604
1185
                                case 'c':
1605
1186
                                        /* Display cpu usage */
1606
1187
                                        flags |= I_D_CPU;
 
1188
                                        report_set = TRUE;
1607
1189
                                        break;
1608
1190
 
1609
1191
                                case 'd':
1610
1192
                                        /* Display disk utilization */
1611
1193
                                        flags |= I_D_DISK;
 
1194
                                        report_set = TRUE;
1612
1195
                                        break;
1613
1196
 
1614
 
                                case 'h':
1615
 
                                        /* Display an easy-to-read NFS report */
1616
 
                                        flags |= I_D_HUMAN_READ;
1617
 
                                        break;
1618
 
        
1619
1197
                                case 'k':
1620
1198
                                        if (DISPLAY_MEGABYTES(flags)) {
1621
1199
                                                usage(argv[0]);
1636
1214
                                        /* Display device mapper logical name */
1637
1215
                                        flags |= I_D_DEVMAP_NAME;
1638
1216
                                        break;
1639
 
        
1640
 
                                case 'n':
1641
 
                                        /* Display NFS stats */
1642
 
                                        flags |= I_D_NFS;
1643
 
                                        break;
1644
1217
 
1645
1218
                                case 't':
1646
1219
                                        /* Display timestamp */
1706
1279
        }
1707
1280
        
1708
1281
        /* Default: Display CPU and DISK reports */
1709
 
        if (!DISPLAY_CPU(flags) && !DISPLAY_DISK(flags) && !DISPLAY_NFS(flags)) {
 
1282
        if (!report_set) {
1710
1283
                flags |= I_D_CPU + I_D_DISK;
1711
1284
        }
1712
1285
        /*
1718
1291
                flags |= I_D_DISK;
1719
1292
        }
1720
1293
 
 
1294
        /* Select disk output unit (kB/s or blocks/s) */
 
1295
        set_disk_output_unit();
 
1296
 
1721
1297
        /* Ignore device list if '-p ALL' entered on the command line */
1722
1298
        if (DISPLAY_PART_ALL(flags)) {
1723
1299
                dlist_idx = 0;
1724
1300
        }
1725
1301
 
 
1302
        if (DISPLAY_DEVMAP_NAME(flags)) {
 
1303
                dm_major = get_devmap_major();
 
1304
        }
 
1305
 
1726
1306
        /* Init structures according to machine architecture */
1727
1307
        io_sys_init();
1728
1308