所有管线均未穿过管道?

所有管线均未穿过管道?

slabtop得到以下输出(50 行):

$slabtop -sc -o
 Active / Total Objects (% used)    : 110864927 / 111473562 (99.5%)
 Active / Total Slabs (% used)      : 2826375 / 2826375 (100.0%)
 Active / Total Caches (% used)     : 83 / 121 (68.6%)
 Active / Total Size (% used)       : 48207397.02K / 48498057.95K (99.4%)
 Minimum / Average / Maximum Object : 0.01K / 0.43K / 16.00K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
10855309 10855309 100%    1.07K 374321       29  11978272K zfs_znode_cache
10893059 10893059 100%    0.85K 294407       37   9421024K dnode_t
412694 410756  99%   16.00K 206347        2   6603104K zio_buf_16384
12502304 12290713  98%    0.50K 390697       32   6251152K kmalloc-512
12776610 12743989  99%    0.29K 232302       55   3716832K dmu_buf_impl_t
10855309 10855309 100%    0.27K 374321       29   2994568K sa_cache
370776 370718  99%    8.00K  92694        4   2966208K kmalloc-8192
3269280 3028688  92%    0.32K  66720       49   1067520K taskstats
10898853 10898853 100%    0.08K 213703       51    854812K selinux_inode_security
12161344 12148434  99%    0.06K 190021       64    760084K kmalloc-64
3257058 3255733  99%    0.19K  77549       42    620392K dentry
5577558 5519367  98%    0.09K 132799       42    531196K kmalloc-96
 92872  82421  88%    4.00K  11609        8    371488K kmalloc-4096
1962464 1953470  99%    0.12K  61327       32    245308K kmalloc-128
6021888 6021888 100%    0.03K  47046      128    188184K kmalloc-32
  8356   8346  99%   12.00K   4178        2    133696K zio_buf_12288
1026675 1026675 100%    0.10K  26325       39    105300K blkdev_ioc
7955456 7955456 100%    0.01K  15538      512     62152K kmalloc-8
 31744  23790  74%    1.00K    992       32     31744K kmalloc-1024
  2040   2008  98%   10.00K    680        3     21760K zio_buf_10240
  1332   1318  98%   14.00K    666        2     21312K zio_buf_14336
  3150   3094  98%    5.00K    525        6     16800K zio_buf_5120
  2050   1984  96%    6.00K    410        5     13120K zio_buf_6144
  6480   5958  91%    2.00K    405       16     12960K kmalloc-2048
  1596   1548  96%    7.00K    399        4     12768K zio_buf_7168
 20075  20075 100%    0.58K    365       55     11680K inode_cache
  7413   7279  98%    1.50K    353       21     11296K zio_buf_1536
 15925  15818  99%    0.64K    325       49     10400K proc_inode_cache
  3360   3252  96%    2.50K    280       12      8960K zio_buf_2560
  2660   2574  96%    3.00K    266       10      8512K zio_buf_3072
  8192   8192 100%    1.00K    256       32      8192K xfs_inode
  2295   2208  96%    3.50K    255        9      8160K zio_buf_3584
 67899  66971  98%    0.10K   1741       39      6964K buffer_head
 27008  13057  48%    0.25K    844       32      6752K kmalloc-256
 59904  59904 100%    0.11K   1664       36      6656K sysfs_dir_cache
  2156   2019  93%    2.84K    196       11      6272K task_struct
  2625   2497  95%    2.06K    175       15      5600K sighand_cache
  9072   9005  99%    0.57K    324       28      5184K radix_tree_node
  3584   3341  93%    1.12K    128       28      4096K signal_cache
 19992  18791  93%    0.19K    476       42      3808K kmalloc-192
 16095  15519  96%    0.21K    435       37      3480K vm_area_struct
124440 124440 100%    0.02K    732      170      2928K fsnotify_event_holder
  1798   1305  72%    1.09K     62       29      1984K zio_cache

但是当管道到尾部时我只得到 23 行:

$slabtop -sc -o | tail -n+0
 Active / Total Objects (% used)    : 110863370 / 111473331 (99.5%)
 Active / Total Slabs (% used)      : 2826376 / 2826376 (100.0%)
 Active / Total Caches (% used)     : 83 / 121 (68.6%)
 Active / Total Size (% used)       : 48207346.77K / 48498099.95K (99.4%)
 Minimum / Average / Maximum Object : 0.01K / 0.43K / 16.00K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
10855309 10855309 100%    1.07K 374321       29  11978272K zfs_znode_cache
10893059 10893059 100%    0.85K 294407       37   9421024K dnode_t
412694 410756  99%   16.00K 206347        2   6603104K zio_buf_16384
12502304 12290595  98%    0.50K 390697       32   6251152K kmalloc-512
12776610 12743989  99%    0.29K 232302       55   3716832K dmu_buf_impl_t
10855309 10855309 100%    0.27K 374321       29   2994568K sa_cache
370776 370718  99%    8.00K  92694        4   2966208K kmalloc-8192
3269280 3028688  92%    0.32K  66720       49   1067520K taskstats
10898853 10898853 100%    0.08K 213703       51    854812K selinux_inode_security
12161344 12148483  99%    0.06K 190021       64    760084K kmalloc-64
3257058 3255733  99%    0.19K  77549       42    620392K dentry
5577558 5519367  98%    0.09K 132799       42    531196K kmalloc-96
 92872  82417  88%    4.00K  11609        8    371488K kmalloc-4096
1962464 1953501  99%    0.12K  61327       32    245308K kmalloc-128
6021888 6021888 100%    0.03K  47046      128    188184K kmalloc-32
  8356   8346  99%   12.00K   4178        2    133696K zio_buf_12288

可以通过直接通过管道连接到 wc 来确认这一点:

$slabtop -sc -o | tail -n+0 | wc -l
23

其余的输出在哪里?

答案1

最有可能的是,源程序正在检查输出是否是 TTY,并相应地对其进行调整。如果它表现良好,将会有一个选项可以明确地控制它,如果您愿意,您可以使用它来自动处理完整的终端输出。如果没有,您可以使用expect或类似的方法来模拟终端并捕获输出。

答案2

有些程序无论是否交互式,其行为都会有所不同。如果你通过管道传输他们的输出,他们就会知道这一点。检查其选项以告知您想要查看多少行。

相关内容