服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - 详解Linux服务器状态、性能相关命令

详解Linux服务器状态、性能相关命令

2022-07-24 12:43波波说运维 Linux

这篇文章主要介绍了详解Linux服务器状态、性能相关命令,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下

服务器状态分析

查看linux服务器cpu详细情况

#查看cpu的信息

[root@host ~]# cat /proc/cpuinfo 

#查看物理cpu的个数

[root@host /]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

#查看每个物理cpu的核数

[root@host /]# cat /proc/cpuinfo | grep "cpu cores" | uniq

#逻辑cpu的个数(逻辑cpu = 物理cpu个数*核数)

[root@host /]# cat /proc/cpuinfo | grep "processor" | wc -l

详解Linux服务器状态、性能相关命令

查看linux服务器内存情况

#查看内存使用情况

?
1
2
3
4
5
[root@host ~]# free -m
total used free shared buffers cached
mem: 372 256 115 0 17 158
-/+ buffers/cache: 81 290
swap: 509 0 509

>total:内存总数

>user:已使用内存数

>free:空闲内存数

>shared:多进程共享内存数

>buffers:缓冲内存数

>cached:缓存内存数

可用内存 = free+buffers+cached

已用内存 = used-buffers-cached

swap 交换内存数,此项可判断内存是否够用的标准

查看linux服务器硬盘使用情况

#查看硬盘及分区信息

fdisk -l 

?
1
2
3
4
5
6
7
8
9
[root@host ~]# fdisk -l
disk /dev/sda: 10.7 gb, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
units = cylinders of 16065 * 512 = 8225280 bytes
device boot start end blocks id system
/dev/sda1 * 1 13 104391 83 linux
/dev/sda2 14 78 522112+ 82 linux swap / solaris
/dev/sda3 79 1305 9855877+ 83 linux
#检查文件系统的磁盘空间占用情况

df -h

?
1
2
3
4
5
6
[root@host ~]# df -h
filesystem size used avail use% mounted on
/dev/sda3 9.2g 6.4g 2.3g 74% /
/dev/sda1 99m 12m 82m 13% /boot
tmpfs 187m 0 187m 0% /dev/shm
/dev/hdc 4.1g 4.1g 0 100% /mnt

详解Linux服务器状态、性能相关命令

服务器性能分析

#查看硬盘的i/o性能

?
1
[root@host /]# iostat -d -x -k 1 5

#iostaat是含在套装systat中,在centos5.5用命令yum -y install sysstat来安装

详解Linux服务器状态、性能相关命令

i/0

查看linux服务器的平均负载

?
1
2
[root@host /]# uptime
12:39:12 up 2:50, 3 users, load average: 0.00, 0.03, 0.00

详解Linux服务器状态、性能相关命令

?
1
2
3
4
5
6
[root@host /]# w
12:39:59 up 2:50, 3 users, load average: 0.00, 0.03, 0.00
user tty from login@ idle jcpu pcpu what
root tty1 - 09:53 32:17 0.36s 0.36s -bash
root pts/0 192.168.1.102 10:23 1:54m 0.03s 0.03s -bash
root pts/1 192.168.1.105 12:16 0.00s 0.09s 0.02s w

监控linux服务器的整体性能

详解Linux服务器状态、性能相关命令

整体性能

?
1
2
3
4
5
6
7
[root@host /]# vmstat 1 4
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 50464 50096 101356 0 0 21 13 925 183 0 0 99 1 0
0 0 0 50464 50096 101380 0 0 0 0 830 18 0 0 100 0 0
0 0 0 50464 50096 101380 0 0 0 0 833 27 0 0 100 0 0
0 0 0 50464 50104 101372 0 0 0 32 822 27 0 0 99 1 0

#proces r:等待运行的进程数 b:非中断睡眠状态的进程数 w:被交换出去的可运行进程数

#memory swpd:虚拟内存使用情况 fres:空闲的内存 buff:用作缓存的内存数(单位:kb)

#swap si:从磁盘交换到内存的交换页数量 so:从内存交换到磁盘的交换页数量(单位:kb/秒)

#io bi:发送到块设备的块数 bo:从块设备接收到的块数(单位:块/秒)

#system in:每秒的中断数,包括时钟中断 cs:每秒的环境(上下文)切换数

#cpu us:cpu使用时间 sy:cpu系统使用时间 id:闲置时间(单位:百分比)

标准情况下:r小于5,b约为0

如果user + sys 小于70 表示系统性能较好;如果大于等于85以上,表示性能比较糟糕

查看linux服务器的其他参数

查看系统内核的版本号

?
1
2
3
4
[root@host /]# uname -a
linux host.domain.com 2.6.18-194.el5 #1 smp fri apr 2 14:58:14 edt 2010 x86_64 x86_64 x86_64 gnu/linux
[root@host /]# uname -r
2.6.18-194.el5

查看系统32位还是64位

[root@host /]# ls -1f / |grep /$

查找是否有/lib64,有则系统为64位

另一种查看系统32位还是64位

?
1
2
[root@host /]# file /sbin/init
/sbin/init: elf 64-bit lsb executable, amd x86-64, version 1 (sysv), for gnu/linux 2.6.9, dynamically linked (uses shared libs), for gnu/linux 2.6.9, stripped

查看服务器使用的linux发行版的相关信息

?
1
2
3
4
5
6
[root@host /]# lsb_release -a
lsb version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
distributor id: centos
description: centos release 5.5 (final)
release: 5.5
codename: final

查看系统已载入的相关模块

?
1
2
3
4
5
6
[root@host /]# lsmod |grep ip
ipv6 435361 24
xfrm_nalgo 43333 1 ipv6
dm_multipath 56920 0
scsi_dh 42177 1 dm_multipath
dm_mod 101649 4 dm_mirror,dm_multipath,dm_raid45,dm_log

在linux下查看pci设置,lspci命令能列出机器中的pci信息,比如声卡、显卡、modem

?
1
2
[root@host /]# lspci | grep ether
02:01.0 ethernet controller: intel corporation 82545em gigabit ethernet controller (copper) (rev 01)

总结

以上所述是小编给大家介绍的linux服务器状态、性能相关命令,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:http://server.51cto.com/sOS-584105.htm

延伸 · 阅读

精彩推荐
  • Linuxlinux Vim基本操作方法

    linux Vim基本操作方法

    Ubuntu的Vi也不好用,搞了个Vim用来学习了,简单记录下它的基本操作。还有一本相关的电子书可下载。...

    Linux命令大全4622020-12-19
  • Linuxlinux下查看内存条数及每根内存大小的实现方法(推荐)

    linux下查看内存条数及每根内存大小的实现方法(推荐)

    下面小编就为大家带来一篇linux下查看内存条数及每根内存大小的实现方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小...

    Linux教程网8512021-11-24
  • LinuxLinux 工程师的 6类好习惯 和 23个教训

    Linux 工程师的 6类好习惯 和 23个教训

    本文介绍了Linux 工程师的 6类好习惯 和 23个教训。一起来看看吧。 ...

    良许Linux5372021-11-10
  • LinuxLinux如何使用shell查看Linux是32位还是64位

    Linux如何使用shell查看Linux是32位还是64位

    Windows系统有分32位和64位,其实Linux系统也有32位和64位之分,那你知道Linux系统是几位的吗?下面为大家详细介绍下使用shell查看Linux是32位还是64 ...

    系统之家4982019-09-16
  • LinuxLinux下swap耗尽该怎么办?如何释放swap?

    Linux下swap耗尽该怎么办?如何释放swap?

    Linux下swap耗尽该怎么办?如何释放swap?Linux下交换内存耗尽如何查看及如何处理。以及查看shell脚本描述。交换内存不足时,启动应用时会报内存不足。下...

    百度经验17172019-10-14
  • LinuxLinux系统怎么启用临时IP地址?

    Linux系统怎么启用临时IP地址?

    Linux系统下暂时修改IP地址?在Linux系统下可以非常方便的修改IP地址,下面就介绍下如何快捷实现暂时修改IP地址,需要的朋友可以参考下 ...

    Linux技术网7732019-10-16
  • Linux一篇学会 Linux at 命令详解

    一篇学会 Linux at 命令详解

    在 Linux 系统里,我们同样也有类似的需求。比如我们想在凌晨 1 点将文件上传服务器,或者在晚上 10 点确认系统状态,等等。...

    良许Linux9352021-10-29
  • Linuxlinux利用CSF防火墙屏蔽恶意请求

    linux利用CSF防火墙屏蔽恶意请求

    本篇文章主要介绍了linux利用CSF防火墙屏蔽恶意请求,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    Myths10842022-01-19