Sponsored Content
Full Discussion: Get the memory and cpu usage
Top Forums Shell Programming and Scripting Get the memory and cpu usage Post 302770691 by busyboy on Monday 18th of February 2013 02:56:21 AM
Old 02-18-2013
Code:
ps -ae -o user,pid,ppid,project,zone,class,pri,lwp,psr,pset,pmem,etime,time,tty,args

should give you the process wide cpu/memory utilization, however if you are going to take this from within the system or kernel statistical data it comes primarily from different methods.
 

10 More Discussions You Might Find Interesting

1. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

2. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

3. UNIX for Dummies Questions & Answers

recording cpu and memory usage

Is there a way for me to record cpu and memory usage over time without buying and installing new software? I know I can use top to see the current state, but can I record that data somehow? (2 Replies)
Discussion started by: cshih31
2 Replies

4. UNIX for Dummies Questions & Answers

cpu, memory and virtual memory usage

Hi All, Does anyone know what the best commands in the UNIX command line are for obtaining this info: current CPU usage memory usage virtual memory usage preferably with date and time parameters too? thanks ocelot (4 Replies)
Discussion started by: ocelot
4 Replies

5. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

6. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

7. UNIX for Dummies Questions & Answers

CPU Utilization and Memory Usage

Can any one suggest me, how to get the last week's (Last n weeks) average CPU utilization and Memory usage? (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

8. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

9. UNIX for Advanced & Expert Users

How often should I monitor the CPU and memory usage ?

Hi all, When you monitor the CPU and memory usage, how often do you do it ? Do it too often or too rarely will both cause the problem. So does anyone have hand-on experience ? And for my case, the requirement says that when CPU usage is above X% or memory usage is above Y%, I should reject... (5 Replies)
Discussion started by: qiulang
5 Replies

10. Shell Programming and Scripting

Cpu and memory usage scripts

All I am writing a script to generate an email when cpu and memory usage is high for 5 min continuously help me urgent I wrote below scritpt LOAD=75.00 CPU_LOAD= 'sar -P all 300 5 |grep 'Average.all* '| awk -F " " '(print 100.0 -$NF)'' IF }; ECHO "pLEASE CHECK YOUR PROCESS ON YOUR... (1 Reply)
Discussion started by: anil529
1 Replies
getpriority(3C) 					   Standard C Library Functions 					   getpriority(3C)

NAME
getpriority, setpriority - get or set process scheduling priority SYNOPSIS
#include <sys/resource.h> int getpriority(int which, id_t who); int setpriority(int which, id_t who, int priority); DESCRIPTION
The getpriority() function obtains the current scheduling priority of a process, process group, or user. The setpriority() function sets the scheduling priority of a process, process group, or user. Target processes are specified by the values of the which and who arguments. The which argument can be one of the following values: PRIO_PROCESS, PRIO_PGRP, PRIO_USER, PRIO_GROUP, PRIO_SESSION, PRIO_LWP, PRIO_TASK, PRIO_PROJECT, PRIO_ZONE, or PRIO_CONTRACT, indicating that the who argument is to be interpreted as a process ID, a process group ID, an effective user ID, an effective group ID, a session ID, an lwp ID, a task ID, a project ID, a zone ID, or a process contract ID, respectively. A 0 value for the who argument specifies the cur- rent process, process group, or user. A 0 value for the who argument is treated as valid group ID, session ID, lwp ID, task ID, project ID, zone ID, or process contract ID. A P_MYID value for the who argument can be used to specify the current group, session, lwp, task, project, zone, or process contract, respectively. If more than one process is specified, getpriority() returns the highest priority (lowest numerical value) pertaining to any of the speci- fied processes, and setpriority() sets the priorities of all of the specified processes to the specified value. The default priority is 0; negative priorities cause more favorable scheduling. The range of valid priority values is [-20, 20]. If the value specified to setpriority() is less than the system's lowest supported priority value, the system's lowest supported value is used. If it is greater than the system's highest supported value, the system's highest supported value is used. Only a process with appropriate privileges can raise its priority (that is, assign a lower numerical priority value). Any processes or threads using SCHED_FIFO or SCHED_RR is unaffected by a call to setpriority(). This is not considered an error. A process that subsequently reverts to SCHED_OTHER need not have its priority affected by such a setpriority() call. RETURN VALUES
Upon successful completion, getpriority() returns an integer in the range from -20 to 20. Otherwise, -1 is returned and errno is set to indicate the error. Upon successful completion, setpriority() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The getpriority() and setpriority() functions will fail if: ESRCH No process could be located using the which and who argument values specified. EINVAL The value of the which argument was not recognized, or the value of the who argument is not a valid process ID, process group ID, user ID, group ID, session ID, lwp ID, task ID, project ID, or zone ID. In addition, setpriority() may fail if: EPERM A process was located, but neither the real nor effective user ID of the executing process is the privileged user or match the effective user ID of the process whose priority is being changed. EACCES A request was made to change the priority to a lower numeric value (that is, to a higher priority) and the current process does not have appropriate privileges. EXAMPLES
Example 1: Example using getpriority() The following example returns the current scheduling priority for the process ID returned by the call to getpid(2). #include <sys/resource.h> ... int which = PRIO_PROCESS; id_t pid; int ret; pid = getpid(); ret = getpriority(which, pid); Example 2: Example using setpriority() The following example sets the priority for the current process ID to -20. #include <sys/resource.h> ... int which = PRIO_PROCESS; id_t pid; int priority = -20; int ret; pid = getpid(); ret = setpriority(which, pid, priority); USAGE
The effect of changing the scheduling priority can vary depending on the process-scheduling algorithm in effect. Because getpriority() can return -1 on successful completion, it is necessary to set errno to 0 prior to a call to getpriority(). If get- priority() returns -1, then errno can be checked to see if an error occurred or if the value is a legitimate priority. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
nice(1), renice(1), fork(2), sched_get_priority_max(3RT), sched_setscheduler(3RT), attributes(5), standards(5) SunOS 5.10 19 Jul 2004 getpriority(3C)
All times are GMT -4. The time now is 07:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy