亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2630 | 回復: 8
打印 上一主題 下一主題

Sun Solaris 上 如何獲得cpu的使用狀況? [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2005-04-25 11:28 |只看該作者 |倒序瀏覽
在Tru64上 用table()系統(tǒng)調(diào)用可以得到cpu的當前使用狀況  包括用戶指令時間 系統(tǒng)指令時間等。請問:在Sun Solaris上有沒有類似的系統(tǒng)調(diào)用?我找了很久都沒有找到。麻煩哪位有經(jīng)驗的ggjj指點一下!小女子拜謝了。

論壇徽章:
1
榮譽版主
日期:2011-11-23 16:44:17
2 [報告]
發(fā)表于 2005-04-25 13:01 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

Solaris 系統(tǒng)的不清楚..
linux系統(tǒng)/proc下有個cpuinfo文件

論壇徽章:
0
3 [報告]
發(fā)表于 2005-04-25 15:29 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

樓上的大哥:能不能對PROC下面的文件目錄結(jié)構(gòu)詳細給我講解一下?謝謝了

論壇徽章:
0
4 [報告]
發(fā)表于 2005-04-25 16:09 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

[quote]原帖由 "sdzhhx"]樓上的大哥:能不能對PROC下面的文件目錄結(jié)構(gòu)詳細給我講解一下?謝謝了[/quote 發(fā)表:


看看man proc能不能找到每個字段的說明。

不同OS的proc不一樣,就拿linux來說,不同kernel版本都不一樣,只能看聯(lián)機文檔

論壇徽章:
0
5 [報告]
發(fā)表于 2005-04-25 16:16 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

Explore /proc filesystem     
     The /proc/ filesystem is a trick the Linux kernel uses to make certain internal information available to user-space processes. The kernel presents the information in virtual files in virtual directories. The files and directories of the /proc/ filesystems are virtual because the data is not actually stored on any sort of permanent storage like a hard disk; instead, the directories, files, and data within them are created dynamically in memory from raw kernel data whenever you attempt to read from them.

     Mounting the /proc/ filesystem:

     All Linux distributions automatically mount the /proc/ filesystem at boot time. It's not essential that this be done, but a number of programs rely on it, so it's wise.

     To see if the /proc filesystem is mounted on your machine, use the mount command without any arguments. You should see output that looks something like this:
     mount
..
proc on /proc type proc (rw)
..

If not, you can mount the /proc/ filesystem manually using the command:

mount -t proc proc /proc

and put the following entry into your /etc/fstab file so it is mounted automatically next time you reboot your machine:

proc /proc proc defaults 0 0

     Similarly by
looking at the values of the various parameters in the /proc file system,one can determine a lot about the current state of the kernel and theprocesses under way. For example, we have the dmesg command.

bash# dmesg

     Dmesg helps us determine the devices that have been detected and
initialized by the Linux kernel. We have utilities like "ps" and "top"
which give an accurate snapshot about the status of the processes running on the machine and a list of awake and sleeping processes currently running on the machine. Have you ever wondered where exactly the information dished out to you by the "ps" and the "top" process comes from? The information for these processes come from the /proc file system which is updated on the fly as changes take place in the processes.

   Since the /proc file system is a virtual file system and resides in
memory, a new /proc file system is created every time your Linux machine reboots. Take a look at the snapshot of the root directory shown above.
   The size of the proc directory is 0 and the last time of modification is the current date.

   Using the /proc/sys file system to parse kernel parameters.

   Another very important part of the /proc file system is the /proc/sys directory. Making changes in this directory enables you to make real time changes to certain kernel parameters. One fine example that can illustrate this is as follows.
   
     /proc/sys/net/ipv4/ip_forward

    The above file ip_forward has a default value of "0" which you can see  when you cat the contents of this file. This means that IP forwarding by  this machine isn't allowed by the kernel. But this configuration can be  changed in real time by just changing the value stored in this file from  "0" to "1". Thus we have enabled IP forwarding on our Linux machine.

               Contents of the /proc File System

    The output of the directory listing of the /proc directory is as follows.
    The actual listing was really lengthy. What's given below is a much
shorter version.

1 114 1210 1211 1212 1227 133 137 148 160 161 163 167 168 169
170 171 172 173 174 186 190 193 194 195 203 206 207 208 209
210 211 220 221 222 223 224 225 226 227 229 230 234 246 253 279
296 3 4 5 500 501 6 667 668 669 683 684 685 7 711 712 713 737 763
764 765 766 773 774 775 782 79 88 92 asound bus cmdline config.gz
cpuinfo devices dma fb filesystems fs ide interrupts ioports
kcore kcore_elf kmsg ksyms loadavg locks lvm mdstat meminfo
memstat misc modules mounts net partitions pci rtc scsi self
slabinfo stat swaps sys tty uptime version

    Every number and word that you see in the above snapshot are the contents of  the /proc directory. Lets learn a little more about the contents of the  directories with the numerical naming scheme.

          The numerical named directories
                 
1 114 1210 1211 1212 1227 133 137 148 160 161 163 167 168 169
170 171 172 173 174 186 190 193 194 195 203 206 207 208 209
210 211 220 221 222 223 224 225 226 227 229 230 234 246 253 279
296 3 4 5 500 501 6 667 668 669 683 684 685 7 711 712 713 737 763
764 765 766 773 774 775 782 79 88 92

The various directories that you see out here are the processes that were  running on our machine at the instant we took a snapshot of the /proc  file system. Let's look at the contents of one of these directories.

al:~ # cd /proc
al:/proc # ls -la 114
total 0
dr-xr-xr-x 3 named named 0 Nov 30 12:20 .
dr-xr-xr-x 89 root root 0 Nov 30 2000 ..
-r--r--r-- 1 root root 0 Nov 30 12:20 cmdline
lrwx------ 1 root root 0 Nov 30 12:20 cwd ->; /var/named
-r-------- 1 root root 0 Nov 30 12:20 environ
lrwx------ 1 root root 0 Nov 30 12:20 exe ->; /usr/sbin/named
dr-x------ 2 root root 0 Nov 30 12:20 fd
pr--r--r-- 1 root root 0 Nov 30 12:20 maps
-rw------- 1 root root 0 Nov 30 12:20 mem
lrwx------ 1 root root 0 Nov 30 12:20 root ->; /
-r--r--r-- 1 root root 0 Nov 30 12:20 stat
-r--r--r-- 1 root root 0 Nov 30 12:20 statm
-r--r--r-- 1 root root 0 Nov 30 12:20 status

    Before executing this command you need to log in as root because the various processes running on the system may be owned by various other users. As usual you have access only to the processes that you have started. After having logged in as root just execute the above command for  any of the directories and compare the output to what is listed above.

   Did you notice any similarity in the output you got and the one listed above? Yes, the contents of all the directories are the same irrespective of the directory you choose to view as these directories contain the various parameters and the status of the process whose PID is the name of the current directory that you are in. The values of the various parameters and status information would of course vary from process to process.

   Look at the first line of the output as viewed above.

-r--r--r-- 1 root root 0 Nov30 12:20 cmdline

"cmdline", this file contains the whole command line used to invoke the
process. The contents of this file are the command line arguments with all the parameters that one has passed to start the particular process. All the information contained in the file is without any formatting and any space between the command line arguments and various arguments.

lrwx------ 1 root root 0 Nov 30 12:20 cwd ->; /var/named

"cwd", as is visible from above this is a symbolic link to the current
working directory of that particular process.

-r-------- 1 root root 0 Nov 30 12:20 environ

"environ" contains all the environment variables defined for this
particular process in the form VARIABLE=value. As with cmdline, all the
information contained in the file is without any formatting or space
between the command line arguments and various arguments.

lrwx------ 1 root root 0 Nov 30 12:20 exe ->; /usr/sbin/named

"exe", this is a symbolic link to the executable file that the current
process is linked to.

dr-x------ 2 root root 0 Nov 30 12:20 fd

"fd", this directory contains the list file descriptors as opened by the particular process.

pr--r--r-- 1 root root 0 Nov 30 12:20 maps

"maps", when you print the contents of this named pipe, you can see the
parts of the process' address space which are currently mapped to a file. The fields, from left to right, are: the address space associated to this mapping, the permissions associated to this mapping, the offset from the beginning of the file where the mapping starts, the device on which the mapped file is located, the inode number of the file and finally, the name of the file itself.

lrwx------ 1 root root 0 Nov 30 12:20 root ->; /

"root", this is a symbolic link pointing to the directory which is the
root file system for the particular process.

-r--r--r-- 1 root root 0 Nov 30 12:20 status

"status", this file gives information regarding the name of the process, its current status, i.e sleeping or awake, its PID, its UID, its PPID and a lot of other general information. This information can be viewed in a simpler and structured manner by using tools like, "ps" and "top".

Generic information about the various /proc/* directories

This information has been sourced from the LASG, Chapter 3

The /proc filesystem

/proc/cpuinfo
Information about the processor, such as its type, make, model, and
performance.

/proc/devices
List of device drivers configured into the currently running kernel.

/proc/dma
Shows which DMA channels are being used at the moment.

/proc/filesystems
Filesystems configured into the kernel.

/proc/interrupts
Shows which interrupts are in use, and how many of each there have been.

/proc/ioports
Which I/O ports are in use at the moment.

沒有時間翻譯,請諒解!!如果有N多人強烈要求翻譯,我會考慮的,呵呵!

論壇徽章:
0
6 [報告]
發(fā)表于 2005-04-25 23:34 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

可以用libkstat.so. 看看kstat.h

論壇徽章:
0
7 [報告]
發(fā)表于 2005-04-29 16:58 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

kstat_lookup()的函數(shù)原型是:

kstat_t *kstat_lookup(kstat_ctl_t *kc, char *ks_module, int
ks_instance, char *ks_name);

kstat_data_lookup()的原型是:
void *kstat_data_lookup(kstat_t *ksp, char *name);

關(guān)鍵是我如果要查cpu的idle時間,用戶時間,以及系統(tǒng)指令時間,到底應該在ks_module ,ks_name 這兩個形參傳入什么樣的實參?
]
還有*kstat_data_lookup的name參數(shù)也是如此

更重要的是 我在哪里能知道這個?
能不能 對函數(shù)kstat_lookup()的這兩個參數(shù) 可能的值以及每個值的含義具體解釋一下
man手冊里沒有 網(wǎng)上也沒有查到。
謝謝各位了

論壇徽章:
0
8 [報告]
發(fā)表于 2005-04-29 19:27 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

% /sbin/prstat

論壇徽章:
0
9 [報告]
發(fā)表于 2005-04-30 03:54 |只看該作者

Sun Solaris 上 如何獲得cpu的使用狀況?

原帖由 "sdzhhx" 發(fā)表:
kstat_lookup()的函數(shù)原型是:

kstat_t *kstat_lookup(kstat_ctl_t *kc, char *ks_module, int
ks_instance, char *ks_name);

kstat_data_lookup()的原型是:
void *kstat_data_lookup(kstat_t *ksp, char *..........

http://developers.sun.com/solaris/articles/kstatc.html
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP