07-17-2011
Hi ,
Thanks Mayur for your inputs..
I need a PID of the highest CPU consuming process.
#!/usr/bin/ksh
cpu_usage_limit=60 #In percentage
host=`hostname`
top -l 1| awk ‘/CPU usage/ {print $3, $12}’ >> $host_top_output.txt
usage=`grep "^ *$1 " $host_top_output.txt | awk '{print $2}' | sed 's/%//'`
PID=`grep "^ *$1 " $host_top_output.txt | awk '{print $1}'`
if [[ $usage -gt $cpu_usage_limit ]] then
SQL_Statement to get the SQL code of high CPU consuming process by using the above PID.
Is there any other way to grep CPU & PID using TOP command in HP-UX system?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number.
top -n 20
i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies
2. Solaris
I want to figure out what is the reason of error message I have in Solaris 10. Why Solaris 10 dosn't recognize 65535?
ps: 65535 is an invalid non-numeric argument for -p option
usage: ps
'format' is one or more of:
Thank you (5 Replies)
Discussion started by: gogogo
5 Replies
3. Shell Programming and Scripting
Hi all,
I am parsing command line options using getopts.
The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument.
Below is the script:
while getopts :hd:t:s:l:p:f: opt
do
case "$opt" in
-h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies
4. AIX
Is there a 'top' command equivalent in AIX 4.2 ?
I already checked and I do not see the following ones anywhere:
top
nmon
topas (1 Reply)
Discussion started by: Browser_ice
1 Replies
5. Shell Programming and Scripting
In the following code
a=
echo $?
echo $?
Why the op is (2 Replies)
Discussion started by: lipun4u
2 Replies
6. AIX
Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold
I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies
7. Shell Programming and Scripting
To find all the files in your home directory that have been edited in some way since the last tar file, use this command:
find . -newer backup.tar.gz
Is anyone familiar with an older solution?
looking to identify files older then 15mins across several directories.
thanks,
manny (2 Replies)
Discussion started by: mr_manny
2 Replies
8. Shell Programming and Scripting
What is the significance of the *) and ?) in the below code.
while getopts a:b:c:he opt
do
case $opt in
a) _name="$OPTARG";;
b) _project="$OPTARG";;
c) line="$OPTARG";;
e) _cmd="XX";;
h) Projects=1;;
*) echo "$OPTARG is an invalid option";
my_exit 1;;
?)... (3 Replies)
Discussion started by: posix
3 Replies
9. UNIX for Dummies Questions & Answers
The script below fails with the following error messages:
gzip: invalid option -- 'w'
Try `gzip --help' for more information.
mysqldump: Got errno 32 on write
cp: invalid option -- 'w'
Try `cp --help' for more information.
rm: invalid option -- 'w'
Try `rm --help' for more information.
... (1 Reply)
Discussion started by: ANNACTION
1 Replies
10. Solaris
Hi,
I installed some packages required by an app built with python.
But when I try python setup.py install, I get the following error:
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32'
Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies
LEARN ABOUT MOJAVE
taskset
TASKSET(1) User Commands TASKSET(1)
NAME
taskset - set or retrieve a process's CPU affinity
SYNOPSIS
taskset [options] mask command [argument...]
taskset [options] -p [mask] pid
DESCRIPTION
taskset is used to set or retrieve the CPU affinity of a running process given its pid, or to launch a new command with a given CPU affin-
ity. CPU affinity is a scheduler property that "bonds" a process to a given set of CPUs on the system. The Linux scheduler will honor the
given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU affinity: the
scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU
affinity is useful only in certain applications.
The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit
corresponding to the last logical CPU. Not all CPUs may exist on a given system but a mask may specify more CPUs than are present. A
retrieved mask will reflect only the bits that correspond to CPUs physically on the system. If an invalid mask is given (i.e., one that
corresponds to no valid CPUs on the current system) an error is returned. The masks may be specified in hexadecimal (with or without a
leading "0x"), or as a CPU list with the --cpu-list option. For example,
0x00000001 is processor #0,
0x00000003 is processors #0 and #1,
0xFFFFFFFF is processors #0 through #31,
32 is processors #1, #4, and #5,
--cpu-list 0-2,6
is processors #0, #1, #2, and #6.
When taskset returns, it is guaranteed that the given program has been scheduled to a legal CPU.
OPTIONS
-a, --all-tasks
Set or retrieve the CPU affinity of all the tasks (threads) for a given PID.
-c, --cpu-list
Interpret mask as numerical list of processors instead of a bitmask. Numbers are separated by commas and may include ranges. For
example: 0,5,8-11.
-p, --pid
Operate on an existing PID and do not launch a new task.
-V, --version
Display version information and exit.
-h, --help
Display help text and exit.
USAGE
The default behavior is to run a new command with a given affinity mask:
taskset mask command [arguments]
You can also retrieve the CPU affinity of an existing task:
taskset -p pid
Or set it:
taskset -p mask pid
PERMISSIONS
A user can change the CPU affinity of a process belonging to the same user. A user must possess CAP_SYS_NICE to change the CPU affinity of
a process belonging to another user. A user can retrieve the affinity mask of any process.
SEE ALSO
chrt(1), nice(1), renice(1), sched_getaffinity(2), sched_setaffinity(2)
See sched(7) for a description of the Linux scheduling scheme.
AUTHOR
Written by Robert M. Love.
COPYRIGHT
Copyright (C) 2004 Robert M. Love. This is free software; see the source for copying conditions. There is NO warranty; not even for MER-
CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AVAILABILITY
The taskset command is part of the util-linux package and is available from https://www.kernel.org/pub/linux/utils/util-linux/.
util-linux August 2014 TASKSET(1)