Sponsored Content
Top Forums UNIX for Advanced & Expert Users ps avg | grep ? filter the desired out put. Post 302302866 by varungupta on Wednesday 1st of April 2009 08:02:04 AM
Old 04-01-2009
ps avg | grep ? filter the desired out put.

Hi Folk,

Following is the command I used to get data related to the DataFlowEngine.
I wanted to know the % usage of cpu and memory.
Code:
ps avg | grep Data

This command will show the processes with its PID as :
Code:
PID   TTY  STAT  TIME   PGIN SIZE  RSS    LIM  TSIZ   TRS %CPU %MEM COMMAND 
  303248   - A    306:32  378 96628 77420    xx    20    56    0.0  0.0           DataFlo
  315404   - A     7:52   109 77944 51104     xx    20    56    0.0  0.0         DataFlo
  426060    - A    230:41  16 100196 100252  xx    20    56   0.1  0.0          DataFlo


Now I want the further details related to that PID that I can get after searching in ps -elf table.

How to use the output of above given command (ps avg | grep Data) as input to the ps -elf and then filter the PID and Process Name using one line command?
If script then it would be ok as well.
I know we can use awk or sed command to filter that.

Last edited by Yogesh Sawant; 04-07-2009 at 05:33 AM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Put the output of grep in a variable

Hi, in a shell script how can I put the result of a grep command in a variable : myvariable=grep mystring myfilename Thank you. (3 Replies)
Discussion started by: big123456
3 Replies

2. Solaris

How to grep (say)last-3 and next-3 lines of Desired Pattern

Hi All, OS-Type=Sun-OS 5.8 Sparc9 Processor Can I grep the previous 4 lines and next 4 lines of a matched pattern(context grep)? For example here we need to monitor logs of live traffic.The data obtained from "tail -f LiveTrafficData.log" looks something like this:-... (3 Replies)
Discussion started by: Sujan Banerjee
3 Replies

3. Shell Programming and Scripting

Grep script to filter

Hi, Wondering if anyone could help me with a simple script to filter out multiple things from a file. Right now I just have long lines of grep -v remove file | greg -v etc etc What I would like to do is have grep -v <run everything in a file> tofilter If that makes sense. Basically a... (2 Replies)
Discussion started by: kevin9
2 Replies

4. Shell Programming and Scripting

filter grep command

I have ran into a small issue and I am not sure how to fix it. In one of our current scripts we have this line which does a grep to get the pid of the process. ps -ef | grep nco_p_syslog | grep $x | awk '{print $2}' However this is not returning anything due to the how long the value... (7 Replies)
Discussion started by: LRoberts
7 Replies

5. Shell Programming and Scripting

Filter on a grep

I am attempting to figure out how to only capture part of a grep command I am doing. So far no luck. When I execute.... leviathan:/gfs/home/tivoli>ps -ef | /usr/ucb/ps -auxww | grep nco_p_syslog The results are.... tivoli 10185 0.0 0.0 5888 5168 ? S Oct 23 0:26... (2 Replies)
Discussion started by: LRoberts
2 Replies

6. UNIX for Advanced & Expert Users

filter last 24 hour data and put in new file

i have file server 1 (filesvr01acess.log) and disc server 1 (discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.81) Similiarly i have file server 2 (filesvr01acess.log) and disc server 2(discsvr01acess.log) in another unix box(say ip adress of the box 10.39.66.82). Now my... (1 Reply)
Discussion started by: nripa1
1 Replies

7. Shell Programming and Scripting

ls | grep (i dont know what to put here)

Dear users, I googled for a while, but i have got a lot of different answers regarding a simple unix command. lets say there are a lot of files in a directory. How can i list the files in a directory whose file types is "text"? Thank you in advance (4 Replies)
Discussion started by: kevincobain2000
4 Replies

8. Shell Programming and Scripting

Grep regex filter

Hi, How can I run the grep search in a script to only include compute, not bigcomputer in following search input? " properties = local compute" " properties = local bigcompute" Thank you. -j (6 Replies)
Discussion started by: hce
6 Replies

9. Shell Programming and Scripting

Filter pattern in grep command

Hi, I am having a file like below hello how are you hello... (5 Replies)
Discussion started by: rohit_shinez
5 Replies

10. UNIX for Beginners Questions & Answers

Grep -P does not capture the desired output

Hi, I'm trying to filter the following output to only display information about an alarm where the Status: corresponds to Set. -------------------------------------------------------- Description: hw_optics: RX POWER LANE-0 LOW ALARM Location: Optics0/0/0/21... (6 Replies)
Discussion started by: sand1234
6 Replies
ps(1)							      General Commands Manual							     ps(1)

Name
       ps - print process status statistics

Syntax
       ps [ options ] [ namelist ] [ corefile ]

Description
       The  command  displays  information about processes. Information on processes can change while is running, so the information it gives is a
       snapshot taken at a given time.

       If you omit the -a option, only your processes are candidates to be displayed by Specifying the -a option causes  information  about  other
       users' processes to be displayed; specifying the -x option includes information on processes without control terminals.

       You must use the -k option and specify both the namelist and corefile arguments when you look at a crash dump.  The namelist argument indi-
       cates that information is to be gathered using the specified system namelist file.  (The namelist file is a kernel  image  file).   If  you
       omit namelist, uses The core argument indicates that information is to be gathered using the specified core file.  If you omit core, uses

Options
       -#	 Represents any given process number and must be the last option given.  You cannot use this option with the -a and -tx options.

       -C	 Causes the %CPU field of the display to reflect the absolute percentage of cpu used by the process for scheduling during its res-
		 ident time .

       -S	 Causes the TIME field of the display to reflect the amount of user+system time spent by a process and its children.

       -a	 Displays information for processes executed from all users' terminals.  The default is to show processes executed from your  ter-
		 minal only.  You cannot use this option with the -# or -t option.

       -c	 Displays the command names as stored internally in the system for accounting purposes instead of the command arguments, which are
		 kept in the process address space.  This display is more reliable, if less informative, because a process is free to destroy  the
		 latter information.

       -e	 Displays the environment as well as the command arguments.

       -g	 Displays  all	processes within the process group.  Without this option, displays only ``interesting'' processes.  Processes that
		 are process group leaders are not considered interesting; therefore, top-level command interpreters  and  processes  waiting  for
		 users to log in are normally not shown.

       -k	 Uses the file specified in the core argument in place of and If you specify the -k option but no core argument, uses

       -l	 Displays  information	in long format, showing the fields PPID, CP, PRI, NI, ADDR, SIZE, RSS, and WCHAN as described under Output
		 Fields.

       -s	 Adds the size SSIZ of the kernel stack of each process to the basic output format for use by system administrators.

       -tx	 Displays information for only the specified terminal.	This option restricts output to processes whose controlling terminal is x.
		 Specify  x  in  the same format as displays terminal names. For example, displays for tty3, for console, for ttyd0, for processes
		 with no terminal, and for processes at the current terminal.  This option must be the last one given.	You cannot use this option
		 with the -# or -a options.

       -u	 Displays  user-oriented  output, which includes fields USER, %CPU, and %MEM. This option also displays SZ and RSS, which are com-
		 puted differently than they are for the -l and -v options.  The SZ field is computed as SIZE + TSIZ (virtual size  plus  size	of
		 text).  The RRS field is computed as RSS + (TRS/xccount) where xccount is the number of processes currently sharing the text.

       -v	 Displays  process  system  time and user time in addition to cumulative time.	This display includes fields RE, SL, PAGEIN, SIZE,
		 RSS, LIM, TSIZ, TRS, %CPU, and %MEM, described under Output Fields.

       -w	 Produces 132-column rather than 80 column output.  If repeated, as -ww, produces arbitrarily wide output.  This option allows	to
		 display more of wide displays.

       -x	 Displays information for all processes, including those not executed from terminals.

Output Fields
       The command displays the following fields in all output formats:

       PID	 The process identification (PID) number

       TT	 The control terminal of the process

       TIME	 The time, including both user and system time

       STAT	 The state of the process given by a sequence of five letters, such as RWNAV.

		 The first letter indicates the run status of the process:

		 R    The process is running.

		 T    The process is stopped.

		 P    The process is in page wait.

		 D    The process is in disk (or other short-term) wait.

		 S    The process is sleeping for less than about 20 seconds.

		 I    The process is idle (sleeping longer than about 20 seconds).

		 The second letter indicates whether a process is swapped out:

		 W	The process is swapped out.

		 Z	The process is killed, but not yet removed.

		 (blank)
			The process is in core.

		 >	The  process  has  a specified soft limit on memory requirements and is exceeding that limit.  This type of process is not
			swapped.

		 The third letter indicates whether a process is running with an altered CPU scheduling priority, using

		 N    The process priority is reduced.

		 <    The process priority has been artificially raised.

		 (blank)
		      The process is running without special treatment.

		 The fourth letter indicates any special treatment of the process for virtual memory:

		 A    Represents VA_ANOM.  This status typically represents a process using a disk more efficiently by	removing  gaps	caused	by
		      deletes and then collecting the remaining data.

		 S    Represents VA_SEQL.  This status is typical of large image processing programs that are using virtual memory to sequentially
		      address voluminous data.

		 (blank)
		      Represents VA_NORM.

		 The fifth letter indicates whether the process is a vector process:

		 V	Indicates that the process is using vector hardware. Only processes running on a VAX processor that contains vector  hard-
			ware can have this status.

		 (blank)
			Indicates the process is not using vector hardware.

       The following fields are not displayed in all output formats:

       USER	 Names the owner of the process.

       %CPU	 Describes  the  use  of  the  CPU by the process.  This percentage is a decaying average over a minute or less of previous (real)
		 time.	The time base over which this percentage is computed varies because processes may be new.  The sum of all %CPU fields  can
		 therefore exceed 200%.

       NICE (or NI)
		 Indicates the process scheduling increment.  For further information, see

       SIZE (or SZ)
		 Shows the virtual size of the process in 1024-byte units.

       RSS	 Shows the real memory (resident set) size of the process in 1024-byte units.

       LIM	 Indicates the soft limit on memory used, which is specified by a call to If no limit has been specified, this limit is shown as

       TSIZ	 Shows the size of the text (shared program) image.

       TRS	 Shows the size of resident (real memory) set of text.

       %MEM	 Gives the percentage of real memory used by this process.

       RE	 Indicates the residency time of the process (seconds in core).

       SL	 Indicates the sleep time of the process (seconds blocked).

       PAGEIN	 Shows the number of disk input and output operations resulting from references by the process to pages not loaded in core.

       UID	 Shows the numerical user identification number of the process owner.

       PPID	 Shows the numerical identification number of the parent of process.

       CP	 Displays the short-term CPU use factor used in scheduling.

       PRI	 Displays process priority. (This value is nonpositive when the process is in a wait state that cannot be interrupted.)

       ADDR	 Displays the swap address of the process or page frame of the beginning of the user page table entries.

       WCHAN	 Indicates  the event for which the process is waiting (an address in the system), with the initial part of the address truncated.
		 For example, the address 80004000 displays as 4000.

       F	 Displays flags associated with the process as in

       SLOAD	  00000001    Process is resident in memory.
       SSYS	  00000002    System process:  swapper, pager,
			      idle (RISC only), trusted path daemon.
       SLOCK	  00000004    Process is being swapped out.
       SSWAP	  00000008    Process requested to swap out for page table
			      growth.
       STRC	  00000010    Traced.
       SWTED	  00000020    Used in tracing.
       SULOCK	  00000040    Locked in by plock(2).
       SPAGE	  00000080    Process is waiting for page-in to complete.
       SKEEP	  00000100    Process is protected from swapout while transferring.
			      resources to another process.
       SOMASK	  00000200    Used by sigpause(2).
       SWEXIT	  00000400    Process is exiting.
       SPHYSIO	  00000800    Process is protected from swapout while doing physical
			      input or output.
       SVFORK	  00001000    Process resulted from a vfork(2) that is not
			      yet complete.
       SVFDONE	  00002000    Parent has received resources returned by
			      vfork(2) child.
       SNOVM	  00004000    Process has no virtual memory, as it is a
			      parent in the context of vfork(2).
       SPAGI	  00008000    Process is demand-paging data pages from its
			      text gnode.
       SSEQL	  00010000    Process has advised of sequential memory access.
       SUANOM	  00020000    Process has advised of random memory access.
       SXCTDAT	  00080000    Process has indicated intent to execute data
			      or stack (RISC only).
       SNOCLDSTP  00100000    POSIX environment: no SIGCLD generated when
			      children stop (formerly named SOUSIG).
       SOWEUPC	  00200000    Process is owed a profiling tick.
       SSEL	  00400000    Used by select(2).
       SLOGIN	  00800000    Process is a login process.
       SPTECHG	  01000000    The page table entries for the process have changed.
       SLKDONE	  04000000    System V file lock has been applied.
       SFIXADE	  08000000    Fix of unaligned accesses is being attempted
			      (RISC only).
       SEXECDN	  10000000    Process has done an execve(2).
       SIDLEP	  20000000    The idle process (RISC only).

       A process that has a parent and has exited, but for which the parent has not yet waited, is marked <defunct>.  A process  that  is  blocked
       trying  to exit is marked <exiting>. The command determines the filename and arguments given when the process was created by examining mem-
       ory or the swap area.  The method is unreliable because, for example,  a process can destroy this information. The filename  and  arguments
       displays might be incorrect.

Files
       Searched to find swap device and terminal names

       Swap device

       Kernel memory

       User process information

       Core file

       System namelist

See Also
       kill(1), w(1), getpriority (2), getrlimit(2), dump(5)

																	     ps(1)
All times are GMT -4. The time now is 11:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy