确定 CPU 利用率 - Solaris unix

发布于 2025-01-03 00:29:59 字数 1511 浏览 6 评论 0原文

我刚刚经历过SO,发现了一个问题 确定 CPU 利用率

这个问题很有趣,而且这个问题更有趣的是答案。 所以我想对我的solaris SPARC unix 系统做一些检查。

我以 root 用户身份进入 /proc,发现了一些名称为数字的目录。 我认为这些数字是进程ID。令人惊讶的是我没有找到/stat。(不知道为什么?..)

输出

root@tiger> cd 11770
root@tiger> pwd
/proc/11770
root@tiger> ls
as         contracts  ctl        fd         lstatus    lwp        object     path       psinfo     root       status     watch
auxv       cred       cwd        lpsinfo    lusage     map        pagedata   priv       rmap       sigact     usage      xmap

我拿了一个进程ID(一个目录)并检查了其中存在的内容。下面是我检查的 文件:

root@tigris> file *
as:             empty file
auxv:           data
contracts:      directory
cred:           data
ctl:            cannot read: Invalid argument
cwd:            directory
fd:             directory
lpsinfo:        data
lstatus:        data
lusage:         data
lwp:            directory
map:            TrueType font file version 1.0 (TTF)
object:         directory
pagedata:       cannot read: Arg list too long
path:           directory
priv:           data
psinfo:         data
rmap:           TrueType font file version 1.0 (TTF)
root:           directory
sigact:         ascii text
status:         data
usage:          data
watch:          empty file
xmap:           TrueType font file version 1.0 (TTF)

我不确定..鉴于此我如何确定CPU利用率? 例如:我的进程的空闲时间是多少。

谁能给我正确的方向吗? 大概有一个例子!

I was just going through SO and found out a question Determining CPU utilization

The question is interesting and the one which is more intersting is the answer.
So i thought doing some checks on my solaris SPARC unix system.

i went to /proc as root user and i found out some directories with numbers as their names.
I think these numbers are the process id's.Surprisingly i did not find /stat.(donno why?..)

i took one process id(one directory) and checked whats present inside it.below is the output

root@tiger> cd 11770
root@tiger> pwd
/proc/11770
root@tiger> ls
as         contracts  ctl        fd         lstatus    lwp        object     path       psinfo     root       status     watch
auxv       cred       cwd        lpsinfo    lusage     map        pagedata   priv       rmap       sigact     usage      xmap

i did check what are those files :

root@tigris> file *
as:             empty file
auxv:           data
contracts:      directory
cred:           data
ctl:            cannot read: Invalid argument
cwd:            directory
fd:             directory
lpsinfo:        data
lstatus:        data
lusage:         data
lwp:            directory
map:            TrueType font file version 1.0 (TTF)
object:         directory
pagedata:       cannot read: Arg list too long
path:           directory
priv:           data
psinfo:         data
rmap:           TrueType font file version 1.0 (TTF)
root:           directory
sigact:         ascii text
status:         data
usage:          data
watch:          empty file
xmap:           TrueType font file version 1.0 (TTF)

i am not sure ..given this how can i determine the cpu utilization?
for eg: what is the idle time of my process.

can anyone give me the right direction?
probably with an example!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小苏打饼 2025-01-10 00:29:59

由于没有其他人上钩,我将添加一些评论/答案。

首先,您是否查看了可用于Solaris 系统调整的信息?这是针对旧版 Solarian、2.6、v7 和 2.6 版本的。 8. 想必在developers.sun.com 上稍微搜索一下就会发现更新的东西。

你写道:

我以 root 用户身份进入 /proc,发现了一些名称为数字的目录。我认为这些数字是进程 ID。令人惊讶的是我没有找到 /stat。(不知道为什么?..)

许多非 Linux 操作系统对于如何管理进程都有自己的特殊约定。
对于 Solaris,/proc 目录不是基于磁盘的文件目录,而是有关所有活动系统进程的信息,这些进程像目录层次结构一样排列。很酷,对吧?

我不知道stat的具体含义,status?统计数据?还有别的东西吗?但这只是使用不同操作系统的目录结构来保存进程信息的约定。

正如您所发现的,/proc/ 下面是一堆编号的条目,这些是活动的 processID。当您进入其中任何一个时,您就会看到可用于该进程的系统信息。

我确实检查了这些文件是什么:....

我无法再访问 Solaris 服务器,因此我们必须猜测一下。我建议“深入”到名称暗示任何相关内容的任何文件或目录。

您尝试过cat psinfo吗?那产生了什么?

如果 Solaris 调整页面没有帮助,那么您的 appropos 是否正常工作?执行appropos proc 并查看提到了哪些手册页。深入研究这些。或者尝试 man proc,并查看条目底部附近的“另请参阅”部分和示例部分。

(Un)?幸运的是,大多数手册页都不是教程,因此通读这些手册可能只会让您了解还需要学习多少内容。


您知道提供一些性能监控功能的内置命令,例如 pstop 等吗?

优秀的基于 AIX 的 nmon 已经/正在存在吗?也移植到 Solaris,请参阅 http://sourceforge.net/projects/sarmon/

还有网络管理员喜欢拥有的昂贵的监控/测量/利用工具,作为一个纯粹的开发人员,我们从来没有使用过它们。当您在 Google 上搜索“Solaris 性能监控”时,请查看付费广告。

最后,请记住 nmon 常见问题解答

如果您继续使用越来越短的时间段,您最终会发现 CPU 要么 100% 繁忙,要么 100% 空闲,所有其他数字只是人类思考速度不够快的一个特征,必须平均化 CPU 使用情况更长的时间。

我希望这有帮助。

As no one else is taking the bait, I'll add some comments/answers.

1st off, Did you check out the info available for Solaris System tuning? This is for old Solarian, 2.6, v7 & 8. Presumably a little searching at developers.sun.com will find something newer.

You wrote:

I went to /proc as root user and i found out some directories with numbers as their names. I think these numbers are the process id's.Surprisingly i did not find /stat.(donno why?..)

Many non-Linux OS's have their own special conventions on how processes are managed.
For Solaris, the /proc directory is not a directory of disk-based files, but information about all of the active system processes arranged like a directory hierarchy. Cool, right?!

I don't know the exact meaning of stat, status? statistics? something else? but that is just the convention used a different OS's directory structure that is holding the process information.

As you have discovered, below /proc/ are a bunch of numbered entries, these are the active processIDs. When you cd into any one of those, then you're seeing the system information available for that process.

I did check what are those files : ....

I don't have access to Solaris servers any more, so we'll have to guess a little. I recommend 'drilling down' into any file or directory whose name hints at anything related.

Did you try cat psinfo? What did that produce?

If the solaris tuning page didn't help, then is your appropos is working? Do appropos proc and see what man-pages are mentioned. Drill down on those. Else try man proc, andd look near the bottom of the entry for the 'see also' section AND for the Examples section.

(Un)?fortunately, most man pages are not tutorials, so reading through these may only give you an idea on how much more you need to study.


You know about the built-in commands that offer some performance monitoring capabilities, i.e. ps, top, etc?

And the excellent AIX-based nmon has been/is being? ported to Solaris too, see http://sourceforge.net/projects/sarmon/.

There are also expensive monitoring/measuring/utilization tools that network managers like to have, as a mere developer, we never got to use them. Look at the paid ads when you google for 'solaris performance monitoring'.

Finally, keep in mind this excellent observation from the developer of the nmon-AIX system monitor included in the FAQ for nmon :

If you keep using shorter and shorter periods you will eventually see that the CPUs are either 100% busy or 100% idle all the other numbers are just a feature of humans not thinking fast enough and having to average out the CPU use in longer periods.

I hope this helps.

豆芽 2025-01-10 00:29:59

没有简单而准确的方法可以从 Solaris /proc 层次结构中获取 CPU 利用率。

与 Linux 使用它来存储各种系统信息和统计信息不同,Solaris 仅在 /proc 下呈现与进程相关的数据。

还有一个区别。 Linux 通常呈现预处理的可读数据(文本),而 Solaris 始终呈现实际的内核结构或原始数据(二进制)。

所有这些都在 Solaris 46 页 proc 手册 (man -s 4 proc) 中完整记录

。 /proc//xxx 文件,通常的方式是通过Solaris kstat(内核统计)接口。此外,前一种方法会不准确,因为它会丢失不计入进程而是直接计入内核的 CPU 使用率。

kstat (man -a kstat) 是在幕后使用所有常用命令来报告您正在查找的内容,例如 vmstat、iostat、prstat、sar、top 等。

例如,cpu 使用情况显示在 vmstat 输出的最后三列中(us、sy 和 id 表示用户空间、内核和空闲时间花费的时间)。

$ vmstat 10 8
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr cd s0 -- --   in   sy   cs us sy id
 0 0 0 1346956 359168 34 133 96 0  0  0 53 11  0  0  0  264  842  380  9  7 84
 0 0 0 1295084 275292 0   4  4  0  0  0  0  0  0  0  0  248  288  200  2  3 95
 0 0 0 1295080 275276 0   0  0  0  0  0  0  3  0  0  0  252  271  189  2  3 95
 0 0 0 1295076 275272 0  14  0  0  0  0  0  0  0  0  0  251  282  189  2  3 95
 0 0 0 1293840 262364 1137 1369 4727 0 0 0 0 131 0 0 0  605 1123  620 15 19 66
 0 0 0 1281588 224588 127 561 750 1 1 0  0 89  0  0  0  438 1840  484 51 15 34
 0 0 0 1275392 217824 31 115 233 2 2  0  0 31  0  0  0  377  821  465 20  8 72
 0 0 0 1291532 257892 0   0  0  0  0  0  0  8  0  0  0  270  282  219  2  3 95

如果由于某种原因您不想使用 vmstat,您可以使用 kstat 命令直接获取 kstat 计数器,但这会很麻烦且不易移植。

There is no simple and accurate way to get the CPU utilization from Solaris /proc hierarchy.

Unlike Linux which use it to store various system information and statistics, Solaris is only presenting process related data under /proc.

There is also another difference. Linux is usually presenting preprocessed readable data (text) while Solaris is always presenting the actual kernel structures or raw data (binary).

All of this is fully documented in Solaris 46 pages proc manual ( man -s 4 proc )

While it would be possible to get the CPU utilization by summing the usage per process from this hierarchy, i.e. by reading the /proc//xxx file, the usual way is through the Solaris kstat (kernel statistics) interface. Moreover, the former method would be inaccurate by missing CPU usage not accounted to processes but directly to the kernel.

kstat (man -a kstat) is what are using under the hood all the usual commands that report what you are looking for like vmstat, iostat, prstat, sar, top and the likes.

For example, cpu usage is displayed in the last three columns of vmstat output (us, sy and id for time spend in userland, kernel and idling).

$ vmstat 10 8
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr cd s0 -- --   in   sy   cs us sy id
 0 0 0 1346956 359168 34 133 96 0  0  0 53 11  0  0  0  264  842  380  9  7 84
 0 0 0 1295084 275292 0   4  4  0  0  0  0  0  0  0  0  248  288  200  2  3 95
 0 0 0 1295080 275276 0   0  0  0  0  0  0  3  0  0  0  252  271  189  2  3 95
 0 0 0 1295076 275272 0  14  0  0  0  0  0  0  0  0  0  251  282  189  2  3 95
 0 0 0 1293840 262364 1137 1369 4727 0 0 0 0 131 0 0 0  605 1123  620 15 19 66
 0 0 0 1281588 224588 127 561 750 1 1 0  0 89  0  0  0  438 1840  484 51 15 34
 0 0 0 1275392 217824 31 115 233 2 2  0  0 31  0  0  0  377  821  465 20  8 72
 0 0 0 1291532 257892 0   0  0  0  0  0  0  8  0  0  0  270  282  219  2  3 95

If for some reason you don't want to use vmstat, you can directly get the kstat counters by using the kstat command but that would be cumbersome and less portable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文