Appearance
系统性能
uptime 命令
基本用法
bash
#!/bin/bash
# 查看系统运行时间
uptime查看详细信息
bash
#!/bin/bash
# 查看详细信息
uptime -Vvmstat 命令
基本用法
bash
#!/bin/bash
# 查看系统性能
vmstat查看详细信息
bash
#!/bin/bash
# 查看详细信息
vmstat -s
# 查看详细信息(持续)
vmstat 1iostat 命令
基本用法
bash
#!/bin/bash
# 查看磁盘 I/O
iostat查看详细信息
bash
#!/bin/bash
# 查看详细信息
iostat -x
# 查看详细信息(持续)
iostat 1实用示例
示例1:查看系统运行时间
bash
#!/bin/bash
# 查看系统运行时间
uptime
# 查看系统负载
uptime | awk '{print $10, $11, $12}'示例2:查看系统性能
bash
#!/bin/bash
# 查看系统性能
vmstat
# 查看系统性能(持续)
vmstat 1示例3:查看磁盘 I/O
bash
#!/bin/bash
# 查看磁盘 I/O
iostat
# 查看磁盘 I/O(持续)
iostat 1示例4:查看系统性能
bash
#!/bin/bash
# 查看系统性能
uptime
vmstat
iostat最佳实践
1. 使用 uptime
bash
# 好的做法
uptime
# 不好的做法
cat /proc/uptime2. 使用 vmstat
bash
# 好的做法
vmstat 1
# 不好的做法
watch -n 1 'cat /proc/stat'3. 使用 iostat
bash
# 好的做法
iostat 1
# 不好的做法
watch -n 1 'cat /proc/diskstats'总结
系统性能的关键点:
- uptime 命令:查看系统运行时间
- vmstat 命令:查看系统性能
- iostat 命令:查看磁盘 I/O
- 实用示例:查看系统运行时间、查看系统性能、查看磁盘 I/O、查看系统性能
- 最佳实践:使用 uptime、使用 vmstat、使用 iostat
下一节我们将学习网络监控的使用。