文章目录
1.监控CPU使用情况-----uptime命令
[root@VM_0_7_centos tmp]# uptime
14:07:20 up 3 days, 5:20, 2 users, load average: 0.00, 0.02, 0.05
CPU负载最近一分钟,五分钟,15分钟
2.监控内存及交换分区的使用情况-----free命令
[root@VM_0_7_centos tmp]# free
total used free shared buff/cache available
Mem: 1882356 745472 80116 1304 1056768 929172
Swap: 0 0 0
3.监控磁盘的使用情况----df命令
-h人性化方式显示容量信息。
[root@VM_0_7_centos tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 6.0G 41G 13% /
devtmpfs 909M 0 909M 0% /dev
tmpfs 920M 24K 920M 1% /dev/shm
tmpfs 920M 628K 919M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/0
overlay 50G 6.0G 41G 13% /var/lib/docker/overlay2/6e53b80373167a4be3066590a0c4d38a141c11524b8cdfcab335970e59ef1eea/merged
shm 64M 0 64M 0% /var/lib/docker/containers/d74d82661514205d6e1ac56574724277400a26a3095aca4497dad5bf8039816d/shm
4.监控网络使用情况----ip和Netscaler命令
查看网卡流量信息
[root@VM_0_7_centos tmp]# ip -s link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:2d:1d:06 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
1167041560 2918929 0 0 0 0
TX: bytes packets errors dropped carrier collsns
538627637 2546027 0 0 0 0
[root@VM_0_7_centos tmp]#
[root@VM_0_7_centos tmp]# netstat -nltpu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:1000 0.0.0.0:* LISTEN 9877/sshd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3243/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2859/httpd
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2966/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3215/zabbix_server
tcp6 0 0 :::8080 :::* LISTEN 13402/docker-proxy-
tcp6 0 0 :::50000 :::* LISTEN 13391/docker-proxy-
tcp6 0 0 :::10050 :::* LISTEN 2966/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 3215/zabbix_server
udp 0 0 172.17.0.7:123 0.0.0.0:* 2503/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2503/ntpd
5.监控进程使用情况-----ps和top命令
查看当前进程
ps -e/ ps - aux
动态查看进程
top
6.网络故障工具
ping、tracetoute、nslookup、dig、netstat
[root@VM_0_7_centos ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:997:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
syslog:x:996:994::/home/syslog:/bin/false
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
zabbix:x:995:993:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
ftpuser:x:1000:50::/var/ftp/pulic_root:/sbin/nologin
dockerroot:x:994:991:Docker User:/var/lib/docker:/sbin/nologin
查找以root开头的行:
[root@VM_0_7_centos ~]# grep --color ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
查找以bash结尾的行:
[root@VM_0_7_centos ~]# grep --color false$ /etc/passwd
syslog:x:996:994::/home/syslog:/bin/false
[root@VM_0_7_centos ~]#
查找包含root的行
[root@VM_0_7_centos ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
ftpuser:x:1000:50::/var/ftp/pulic_root:/sbin/nologin
dockerroot:x:994:991:Docker User:/var/lib/docker:/sbin/nologin
[root@VM_0_7_centos ~]# grep ^$ /etc/passwd ---g过滤文件的空白行
[root@VM_0_7_centos ~]# grep -v ^$ /etc/passwd ----过滤文件的非空白行