Sponsored Content
Top Forums Programming How can I get a processor's CPU Percentage? Post 8672 by Perderabo on Tuesday 16th of October 2001 11:24:11 AM
Old 10-16-2001
Kernels always have some code built in to gather statistics. In the case of cpus, several times a second a clock routine fires off and increments one element of a structure. The structure will have counters for idle, user, system, and so on.

In the old days, you could get the structure if you knew its name. You would run nlist(3) on the kernel's symbol table to get the address of the structure. Then you opened /dev/kmem. did a seek to the address and read the structure. The c definations of the structures were usually in /usr/include. This still can be made to work on hp-ux, but the required information is no longer supplied in /usr/include. Skilled gurus can reverse-engineer it, but it's difficult. Vic Able has done this to get lsof to work on recent versions of HP-UX, a feat that very few could match.

New system calls like pstat are the way of the future. And pstat works well enough. Why do you want an alternative?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clearify what it means under 'WHAT' when hit the 'w'-command

I wonder how I shall read the result below, especially 'what' shown below. The result was shown when I entered 'w'. E.g what is TOP? What is gosh ( what does selmgr mean?)? login@ idle JCPU PCPU what 6:15am 7:04 39 39 TOP 6:34am 6:45 45 45 TOP 6:41am ... (1 Reply)
Discussion started by: Aelgen
1 Replies

2. UNIX for Dummies Questions & Answers

CPU's

I have a question. Is Linux (Redhat 7.2 specifically) set up to run better/faster on a Pentium cpu vs. an AMD? The reason I ask is, I have a PIII 733 w/512 pc133, and a 4mb video card at work, and an AMD 1.4 w/1gb ddr, and a Radeon 64mb DDR at home, and the PIII at work runs a lot faster. I have a... (1 Reply)
Discussion started by: jeremiebarber
1 Replies

3. HP-UX

How to determine cpu&memory percentage usage per user

Using HP-UX v11 Need to monitor cpu and memory usage, total for system and separately for each user in command-line mode. Found out next ways to monitor total cpu usage under hp-ux: 1) vmstat, also shows free memory 2) sar -M ps -eo user,pcpu - does not work, means 'user-defined format'... (4 Replies)
Discussion started by: hp-ux-user
4 Replies

4. AIX

CPU Processor ID

Hallo, does anybody knows a trick to change the Processor ID in AIX 4.3.3. Thanks a lot (9 Replies)
Discussion started by: UXNI
9 Replies

5. Shell Programming and Scripting

get percentage cpu from pid

Hi all, I need a script that will check the cpu usage of a certain process and then kill the process if the % cpu is greater than 25%. I know i can get the pid of a process by doing pidof <processname>. Once I have the pid number is there a command in bash to return the current % cpu? (2 Replies)
Discussion started by: borderblaster
2 Replies

6. Shell Programming and Scripting

Help with bash script - Need to get CPU usage as a percentage

I'm writing a bash script to log some selections from a sensors output (core temp, mb temp, etc.) and I would also like to have the current cpu usage as a percentage. I have no idea how to go about getting it in a form that a bash script can use. For example, I would simply look in the output of... (3 Replies)
Discussion started by: graysky
3 Replies

7. Shell Programming and Scripting

Finding total Percentage CPU usage

Hi, How can I find total CPU usage in percentage? e.g. if my system has 8 CPUs and I want to list total usage for all of them, is it possible through a command? I have tried some of the commands like top, mpstat, sar. The output of those commands has to be manipulated to derive the percentage... (14 Replies)
Discussion started by: jal_capri
14 Replies

8. Hardware

Nodes/Processor/CPU's/threads/packages

Hello, can anyone explain me this jargon "Nodes/Processor/CPU's/threads/packages":confused: and what's the relation between these, I need to work on a cluster and I can not figure out the terminology. Thanks! any good link to read about these would also be very helpful Thanks! ... (1 Reply)
Discussion started by: nonothing
1 Replies

9. Solaris

CPU/processor/cores in M4000

Hi Gurus Can someone help me in explaining the below outputs . psrinfo -p 4 /usr/sbin/psrinfo -pv The physical processor has 4 virtual processors (0-3) SPARC64-VI (portid 1024 impl 0x6 ver 0x93 clock 2150 MHz) The physical processor has 4 virtual processors (8-11) SPARC64-VI... (3 Replies)
Discussion started by: ningy
3 Replies

10. Solaris

Capture PRSTAT based on CPU usage percentage

Hi, Recently i have write a simple script to capture CPU high usage based on prstat but i found out that it did capture correctly. I need to capture the rows that contains CPU usage more than 3%. Below line which i thought will capture CPU usage based CPU column in prstat(9th parameter) which is... (3 Replies)
Discussion started by: tharmendran
3 Replies
nlist_ia(3C)															      nlist_ia(3C)

NAME
nlist_ia: nlist(), nlist64() - get entries from name list on Integrity systems SYNOPSIS
Command: [flag]... [library]... Remarks The use of symbol table type and value information is inherently nonportable. The use of or should reduce the effort required to port a program that uses such information, but complete portability across all HP-UX implementations cannot be expected. This manpage describes and for Itanium-based systems. For and on PA-RISC systems, see nlist_pa(3C). DESCRIPTION
and have basically the same functionality and they can process SOM or ELF files. The structure is the same as and is used for source code compatibility. The or function examines the name list in the executable file whose name is pointed to by file_name, and selectively extracts a list of values and puts them in the array of structures pointed to by nl. The array of structures initially contains only the names of variables. Once the or function has been called, the variable names are augmented with symbol information. The list is terminated by a null name, which consists of a null string in the variable-name position of the structure. The name list of the file is searched for each variable name. If the name is found, the symbol's type, scope, and value in the file is inserted into the name list structure. If the file searched is an ELF file, the section index is also inserted. For SOM files, the subspace index is inserted. The symbol value is 64-bit. If the file searched is a SOM file, then the value field is zero padded. If the name is not found, the fields in the name list structure are set to 0. The structures and are defined in the include file See a.out(4) and nlist(4) for further description of the symbol table structure. The file must have the organization and symbol table described for an file in a.out(4). The information is extracted from the symbol table used by the linker, ld(1). On machines that have such a file, this subroutine is useful for examining the system name list kept in file In this way programs can obtain system addresses that are up to date. RETURN VALUE
All structure fields are set to 0 if the file cannot be found or if it is not a valid object file containing a linker symbol table. and return: An error occurred. Success. WARNINGS
The header file is automatically included by for compatibility. However, including is discouraged if the only information needed from is for use by or If is included, the line may need to follow it. SEE ALSO
ld(1), elf(3E), a.out(4), nlist(4). STANDARDS CONFORMANCE
Integrity Systems Only nlist_ia(3C)
All times are GMT -4. The time now is 05:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy