This topic describes how to check the host status on the CLI.
Note
The output of the commands in this topic may vary slightly based on the system configuration and version.
Check whether the host is online
You can use the following commands to check whether a host is online.
ping: checks the network connectivity of a host. The command sends a network probe packet to the host for a response to determine whether a host is reachable.ping <host_name_or_ip_address>Here,
<host_name_or_ip_address>is the name or IP address of the host. If the host is online, a series of responses are returned from the host. If the host is not online, an error message or no response is displayed.ssh: tries to remotely log on to the host over the SSH protocol. If the connection is successful, the host is online.ssh <user>@<host_name_or_ip_address>Here,
<user>is the user name used to log on to the host, and<host_name_or_ip_address>is the name or IP address of the host. If the host is successfully connected, a logon prompt for the host is displayed.
Check the CPU information
mpstat: returns a series of parameters about CPU usage for multi-core CPU monitoring and reporting.
mpstat
The parameters returned by the mpstat command are described as follows:
- CPU: the number of the CPU.
- %usr: the percentage of CPU time for the execution of userspace processes.
- %nice: the percentage of CPU time for the execution of user-mode processes with a Nice value.
- % sys: the percentage of CPU time for the execution of core-mode threads.
- % iowait: the percentage of CPU time for I/O waiting.
- %irq: the percentage of CPU time consumed by hardware interrupts.
- %soft: the percentage of CPU time consumed by software interrupts.
- %steal: the percentage of CPU time occupied by a virtualized environment, such as a virtual machine.
- %guest: the percentage of user tasks that are running virtual CPUs in a virtualized environment.
- %idle: the percentage of CPU idle time.
Here is an example:
[admin@xxx /home/admin]
$mpstat
Linux 3.10.0-327.ali2019.alios7.x86_64 (xxx) 09/13/2023 _x86_64_
(64 CPU)
10:25:42 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
10:25:42 AM all 8.36 0.00 2.38 0.04 0.00 0.18 0.00 0.00 0.00 89.04
Check the memory information
free -h: returns parameters about the memory usage of the system.
free -h
The parameters returned by the free -h command are described as follows:
total: the total amount of the physical memory (RAM).
used: the amount of physical memory that has been used.
free: the amount of free physical memory.
shared: the amount of physical memory shared by multiple processes.
buff/cache: the amount of physical memory for the cache and buffer.
available: the current amount of available physical memory, that is, the remaining available memory, which is the sum of free and buff/cache.
Swap: the usage of swap partitions.
total: the total amount of swap partitions.
used: the amount of the used swap partitions.
free: the amount of the idle swap partitions.
Note
The -h option displays the memory size in a more user-friendly way for easier reading.
Here is an example:
[admin@xxx /home/admin]
$free -h
total used free shared buff/cache available
Mem: 503G 255G 7.2G 4.2M 240G 238G
Swap: 0B 0B 0B
Check the disk information
df: returns the disk usage and information about the path, partition disk size, used size, available size, usage, and mounted directories.
df [-h] [dir_name]
The -h parameter specifies to display the disk sizes in GB. The dir_name parameter specifies to display the total disk size of a directory.
The output includes the following information:
- Filesystem: the path or device name of the file system.
- Size: the total size of the partition disk.
- Used: the size of the disk space used.
- Available: the available disk size.
- Use%: the usage of the disk space.
- Mounted on: the mount directory.
Here is an example:
[root@xxx /home/admin]# df -h /data/1
Filesystem Size Used Avail Use% Mounted on
- 196G 168G 19G 91% /data/1