Linux命令-系统统计命令

时间:2020-02-23 14:39:27  来源:igfitidea点击:

以下是Linux中一些重要的系统统计命令。

free -h

该命令显示系统中的可用内存量。

在下面的示例中,我们将获得可用的可用内存。

$free -h
              total        used        free      shared  buff/cache   available
Mem:           1.9G        933M        208M         10M        851M        880M
Swap:          1.4G        780K        1.4G

df -h

此命令报告文件系统磁盘空间使用情况。

在以下示例中,我们将获取磁盘空间使用情况。

$df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            969M     0  969M   0% /dev
tmpfs           200M  1.5M  198M   1% /run
/dev/sda1        30G  6.0G   22G  22% /
...
...
...

iostat

此命令报告设备和分区的CPU(中央处理单元)统计信息和I/O(输入/输出)统计信息。

在以下示例中,我们将获得IO统计信息。

$iostat
Linux 4.15.0-20-generic (theitroad-ubuntu)  Monday 01 January 2016        _x86_64_        (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           3.32    0.59    0.94    0.17    0.00   94.98

Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
loop0             0.02         0.42         0.00       1048          0
loop1             3.68         4.09         0.00      10150          0
loop2             0.02         0.14         0.00        348          0
loop3             0.02         0.05         0.00        116          0
loop4             0.02         0.14         0.00        347          0
loop5             0.04         0.45         0.00       1114          0
loop6             0.02         0.05         0.00        120          0
loop7             0.02         0.14         0.00        350          0
scd0              0.02         0.07         0.00        186          0
sda              12.28       313.30       134.68     778389     334612
loop8             0.02         0.04         0.00        110          0
loop9             0.02         0.14         0.00        350          0
loop10            0.03         0.44         0.00       1082          0
loop11            3.03         3.15         0.00       7824          0
loop12            0.16         0.27         0.00        678          0
loop13            0.04         0.07         0.00        171          0
loop14            0.02         0.05         0.00        115          0
loop15            0.00         0.00         0.00          1          0

iostat -d 2

这将以2秒的间隔显示连续的设备报告。

$iostat -d 2

要中断连续报告,请按Ctrl + C。

vmstat

此命令将报告虚拟内存统计信息。

在下面的示例中,我们将获取虚拟内存统计信息。

$vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0    780 138884  85884 801708    0    0   245   103   89  374  3  1 96  0  0

mpstat

此命令将显示与进程相关的统计信息。

在以下示例中,我们将打印与处理器相关的统计信息。

$mpstat
Linux 4.15.0-20-generic (theitroad-ubuntu)  Monday 01 January 2016        _x86_64_        (1 CPU)

08:17:48  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
08:17:48  IST  all    2.96    0.41    0.72    0.12    0.00    0.03    0.00    0.00    0.00   95.75

tail -n N/var/log/syslog

该命令将打印系统日志文件的最后" N"行。

在下面的示例中,我们将打印系统日志文件的最后5行。

$tail -n 5 /var/log/syslog
Jan  9 08:22:26 theitroad-ubuntu systemd[1]: Started Network Manager Script Dispatcher Service.
Jan  9 08:22:26 theitroad-ubuntu nm-dispatcher: req:1 'connectivity-change': new request (1 scripts)
Jan  9 08:22:26 theitroad-ubuntu nm-dispatcher: req:1 'connectivity-change': start running ordered scripts...
Jan  9 08:22:27 theitroad-ubuntu whoopsie[662]: [08:22:27] online
Jan  9 08:45:02 theitroad-ubuntu CRON[4228]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)