Linux性能优化工具系列详解(1)

📅 发布时间:2026/8/16 22:34:54
Linux性能优化工具系列详解(1) 本系列内容参考极客时间 —— 倪朋飞 《Linux性能优化实战》特此致谢序言Linux系统性能优化是基于Linux操作系统软硬件全栈通过监控定位瓶颈、调整内核参数、优化调度/存储/网络、调整应用架构、合理分配硬件资源等手段定位并消除系统资源瓶颈提升系统吞吐量、降低响应延迟、减少资源损耗、保障业务稳定运行的整套工程体系。性能优化是一个系统工程涉及从程序设计、算法分析、编程语言到系统、存储、网络等各种底层基础设施的方方面面。因此性能优化五一是软件系统中最具有挑战的工作之一同时也是最考验并体现个人综合能力的工作之一。本系列是笔者基于极客时间中的倪朋飞《Linux性能优化实战》课程对于其中提到的工具进行的引申学习。一方面帮助笔者深入学习和理解该课程也算作随笔另一方面在此基础上扩展和引申帮助自己以及其它同仁更好地理解和掌握Linux性能优化以及相关工具。闲言少叙书归正文。系列工具1. uptime1概述uptime是计算机系统中用于反映系统运行状态的术语在Unix/Linux系统中也是一个命令行工具。uptime是一个简单却功能强大的工具它以一行简洁的输出提供关键信息显示系统运行时长、当前登录用户数量及过去1、5、15分钟内的系统平均负载值为服务器状态监测提供基础依据。uptime适合快速查看系统状态无需复杂参数即可使用。2详情NAMEuptime - Tell how long the system has been running.名称uptime —— 告诉系统已经运行了多长时间。SYNOPSISuptime [options]简介uptime [选项]DESCRIPTIONuptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.This is the same information contained in the header line displayed by w(1).System load averages is the average number of processes that are either in a runnable or uninterruptable state. A process in a runnable state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting for disk. The averages are taken over the three time intervals.Load averages are not normalized for the number of CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.描述uptime提供以下信息的单行显示当前时间、系统运行时间、当前登录用户数以及过去1、5和15分钟的系统负载平均值。这与w(1)显示的标题行中包含的信息相同。系统负载平均值是处于可运行或不可中断状态的进程的平均数量。处于可运行状态的进程要么正在使用CPU要么正在等待使用CPU。处于不可中断状态的进程正在等待某些I/O访问例如等待磁盘。在三个种时间间隔内取平均值。负载平均值不是针对系统中的CPU数量进行归一化的因此负载平均值为1意味着单CPU系统一直在加载而在4 CPU系统上这意味着它有75%的时间处于空闲状态。OPTIONS-p, --prettyshow uptime in pretty format-h, --helpdisplay this help text-s, --sincesystem up since, in yyyy-mm-dd HH:MM:SS format-V, --versiondisplay version information and exit选项-p, --pretty以漂亮的格式显示正常运行时间。-h, --help显示此帮助文本。-s, --since以yyyy-mm-dd HH:mm:SS格式显示系统已运行时间。-V, --version显示版本信息并退出。FILES/var/run/utmpinformation about who is currently logged on/proc process information文件/var/run/utmp关于当前登录用户的信息。/proc进程信息。AUTHORSuptime was written by Larry Greenfield ⟨greenfiegauss.rutgers.edu⟩ and Michael K. Johnson ⟨johnsonmsunsite.unc.edu⟩作者uptime命令是由Larry Greenfield (greenfiegauss.rutgers.edu) 和Michael K.Johnson (johnsonmsunsite.unc.edu)编写的。更多内容请看下回。