11

我过去常常sar -n DEV 1在 El Capitan 中查找有关网络的信息。

更新后,相同的命令给出错误:-bash: sar: command not found

那么,苹果是用任何其他命令替换了该命令还是将其删除了?

是否可以sar从 Apple 或第 3 方安装?

或者是否有任何其他命令来查找网络相关数据?

4

1 回答 1

6

Apple's source code repository for sar is located here. Download sar.c and sar.h.

You will also need sadc.h and sadc.c from here.

Compile and test:

clang sar.c -o sar -I .
clang sadc.c -o sadc -I . -framework Foundation -framework IOKit

./sar -A -f test > testout
terminated by signal SIGFPE (Floating point exception)

Then the content of the testout file looks like this:

17:32:23  %usr  %nice   %sys   %idle

17:32:23    pgout/s

17:32:23     pgin/s        pflt/s        vflt/s

17:32:23   device    r+w/s    blks/s

17:32:23    IFACE    Ipkts/s      Ibytes/s     Opkts/s      Obytes/s

17:32:23    IFACE     Ierrs/s     Oerrs/s    Coll/s      Drop/s
New Disk: [disk0] IODeviceTree:/PCI0@0/SATA@1F,2/PRT0@0/PMP@0/@0:0

17:32:23  %usr  %nice   %sys   %idle
17:32:23    0      0      0      0

17:32:23    pgout/s
17:32:23        nan

17:32:23     pgin/s        pflt/s        vflt/s
17:32:23        nan           nan           inf

So it compiles, data can be collected and kindof processed, but not fully.

I've found the Apple repository of SAR thanks to this superuser answer: https://superuser.com/a/581128

于 2017-02-23T13:33:41.563 回答