Linux systems have some basic commands that can be well used for server monitoring.
For a brief introduction, use Help to view or access relevant information.
- Network: Ifconfig,netstat
- Disk: DF
- Cpu:w
- Process: PS
- Memory: Free
- I/o:iostat
Ifconfig
Enter ifconfig and the output is:
Eth0:flags=4163<Up,broadcast,running,multicast>Mtu theinet10.144. Bayi. 226Netmask255.255.. 0Broadcast10.144.. 255Etherxx: -:3E: Geneva:Geneva: BA Txqueuelen +(Ethernet)RXPackets69775 bytes 91364566(87.1MiB)RXErrors0Dropped0Overruns0Frame0TX Packets26057 bytes 1937311(1.8MiB) TX Errors0Dropped0Overruns0Carrier0Collisions0Lo:flags= the<Up,loopback,running>Mtu65536inet127.0. 0. 1Netmask255.0. 0. 0 LoopTxqueuelen0(LocalLoopback)RXPackets286 bytes 32054(31.3KiB)RXErrors0Dropped0Overruns0Frame0TX Packets286 bytes 32054(31.3KiB) TX Errors0Dropped0Overruns0Carrier0Collisions0
The results show the number of network cards, IP address, MAC address, MTU size, network card transceiver packet.
EthX (x for 0,1,2 ...), there are several net cards, inet is the IP address, netmask is the subnet mask, broadcast is the broadcast address
Netstat
Netstat is a command to view network-related data.
ActiveInternet connections (servers and established) Proto recv-q send-q Local address Foreign address state Timertcp0 0 127.0.0.1:8005 0.0.0.0:* LISTENoff(0. $tcp0 0 0.0.0.0:8009 0.0.0.0:* LISTENoff(0. $tcp0 0 0.0.0.0:80 0.0.0.0:* LISTENoff(0. $tcp0 0 0.0.0.0:8080 0.0.0.0:* LISTENoff(0. $tcp0 0 0.0.0.0:22 0.0.0.0:* LISTENif(0. $tcp0 0 115.28.204.58:58433 42.156.166.25:80Establishedoff(0. $tcp0 the 115.28.204.58:22 59.71.67.114:21489Established on(0.4$udp0 0 115.28.204.58:123 0.0.0.0:*off(0. $udp0 0 10.144.81.226:123 0.0.0.0:*if(0. $udp0 0 127.0.0.1:123 0.0.0.0:*off(0. $udp0 0 0.0.0.0:123 0.0.0.0:*off(0. $UDP 60 0:::123:::*
Can be used to view all network layer connection conditions on the server.
W
The W command is used to view the load condition of the server, enter W, and the command output is as follows:
16:59:52updays, 18:20, user, loadaverage: 0.09, 0.04, 0.05USER TTY LOGIN@ IDLE JCPU PCPU WHATroot pts/0 16:51 0.00s 0.06s 0.00s w
The results include the server's uptime (4 days,18:20), the number of users, the current user and the program it runs, and the three values for load average are 1-minute, 5-minute, and 10-minute average loads, respectively.
The average value is calculated every 1 minutes, 5 minutes, and 10 minutes for the currently running task and the number of tasks waiting for disk I/O per 5s recording system, which is the mean load.
Df
The DF command is used to view the disk, enter Df-h
Filesystem Size used Avail Use% mounted on/Dev/xvda1 +G 2.1G $G 6% /Devtmpfs 489M 0 489M 0%/devTmpfs 497M 0 497M 0%/dev/shmTmpfs 497M +M 478M 4%/runTmpfs 497M 0 497M 0%/sys/fs/cgroupTmpfs -M 0 -M 0%/run/user/0
You can see the disk usage, the directory of the mounting disk, and so on.
Free
The free command is used to view the memory status
total used free shared buffers cachedMem: 1016656 940168 76488 19384 114052 543612-/+ buffers/cache: 282504 734152Swap: 0 0 0
You can see the total memory size, the memory used, and the remaining memory.
Swap is a swap partition that can be understood as virtual memory
Iostat
Io is I/O, this command is used to output I/O-related data, input iostat-x
Linux3.10.0-123.9.3. el7.x86_64 (IZ28YQVMJKRZ)Geneva/ -/ ._x86_64_(1CPU) Avg-cpu:%user %nice %system %iowait %steal %idle 0. + 0.xx 0. - 0. . 0. - 99.47device:rrqm/swrqm/sr/sw/srkb/swkb/sAvgrq-sz Avgqu-sz A$xvda0.xx 0. - 0.Ten 0. - 0.94 5.14 28.83 0. on 2$
Device represents the data for a disk device
Ps
This command is used to view process information, enter Ps-aux
USER PID%cpu%MEM VSZ RSS TTY STATSTART TimeCommandroot1 0.0 0.3 188792 3804? Ss Mar150:Ten/usr/lib/systemd/syste$root2 0.0 0.0 0 0? S Mar150:xx[Kthreadd]root3 0.0 0.0 0 0? S Mar150: on[ksoftirqd/0]root5 0.0 0.0 0 0? s< Mar150:xx[kworker/0:0H]root7 0.0 0.0 0 0? S Mar150:xx[migration/0]root8 0.0 0.0 0 0? S Mar150:xx[Rcu_bh]root9 0.0 0.0 0 0? S Mar150:xx[rcuob/0]......
You can output the use of process identifiers, CPUs, memory, and so on.
PS parameters are many, remember a few commonly used, have special needs when re-check information
Several Linux commands to understand the performance profile of a Linux system