导航菜单

性能监控与日志管理

性能监控
CPU与内存监控:

# 实时查看系统资源占用
top

# 更友好的交互式监控
top
htop

# 查看内存使用情况
free -h
进程与负载监控:

# 查看进程状态
ps aux

# 查看系统平均负载
uptime

# 查看进程树
pstree -p
磁盘与I/O监控:

# 查看磁盘使用情况
df -h

# 查看磁盘I/O
iotop

# 查看磁盘分区信息
lsblk
网络监控:

# 查看网络流量
iftop

# 查看网络连接
ss -tulnp

# 查看网络统计
sar -n DEV 1 5
历史性能数据:

# 安装并使用sysstat工具包
sudo apt install sysstat

# 收集和查看历史性能数据
sar -u 1 5
日志管理
系统日志管理:

# 查看系统日志
journalctl -xe

# 查看指定服务日志
journalctl -u nginx

# 按时间查看日志
journalctl --since "2024-01-01" --until "2024-01-31"
传统日志文件:

# 查看常见日志文件
cat /var/log/syslog
cat /var/log/messages
cat /var/log/auth.log
日志轮转与管理:

# 手动触发日志轮转
sudo logrotate -f /etc/logrotate.conf

# 查看logrotate配置
cat /etc/logrotate.conf
cat /etc/logrotate.d/*