2

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!

Community
  • 1
  • 1
Vijay
  • 65,327
  • 90
  • 227
  • 319
  • When it comes to ````top```` command in Solaris, need to consider the __Irix__ mode when investigating high cpu scenarios. Found this article explaining it nicely [How to Investigate high CPU utilization of Java processes](https://devreads.xyz/how-to-investigate-high-cpu-utilization-of-java-processes/) – DinushaNT Jul 17 '19 at 06:11

2 Answers2

2

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.

shellter
  • 36,525
  • 7
  • 83
  • 90
2

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.

jlliagre
  • 29,783
  • 6
  • 61
  • 72