Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to grep output from top command. Post 302607301 by Siddheshk on Wednesday 14th of March 2012 05:51:11 AM
Old 03-14-2012
Shell Script to grep output from top command.

Hello,

I want a script which would grep details from top command for specific processes. I m not sure of the PID of these processes but i know the names.

Code:
[xmp@tswebpxmp8 ~]$ top -c
top - 16:41:55 up 160 days,  5:53,  2 users,  load average: 9.36, 9.18, 8.98
Tasks: 288 total,   9 running, 279 sleeping,   0 stopped,   0 zombie
Cpu(s): 34.0%us, 16.3%sy,  0.0%ni, 45.3%id,  0.3%wa,  0.2%hi,  3.9%si,  0.0%st
Mem:  49452208k total, 49154692k used,   297516k free,   539372k buffers
Swap: 16779884k total,      244k used, 16779640k free, 32430072k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5473 xmp       25   0 51224  34m 2864 R 99.7  0.1   1:53.26 logscan -in /var/xmp/logmgmt/work_billing/pending/XMP_tswebpxmp8_1203140830.log -out XMP_tswebpxmp8_1203140
23199 xmp       15   0 1135m 1.1g 5660 R 81.4  2.2   5398:45 cee -n TCP-ROUTER.tswebpxmp8.4
28549 xmp       16   0 1264m 1.2g 5660 R 73.8  2.5   7514:20 cee -n TCP-ROUTER.tswebpxmp8.11
32675 xmp       16   0 1274m 1.2g 5660 R 72.1  2.5   7297:01 cee -n TCP-ROUTER.tswebpxmp8.12
23148 xmp       15   0 1147m 1.1g 5660 S 71.8  2.3   5698:58 cee -n TCP-ROUTER.tswebpxmp8.2
26869 xmp       16   0 1147m 1.1g 5660 R 66.2  2.3   5644:15 cee -n TCP-ROUTER.tswebpxmp8.8
24956 xmp       15   0 1142m 1.1g 5660 R 59.2  2.2   5706:29 cee -n TCP-ROUTER.tswebpxmp8.6
21247 xmp       15   0 1205m 1.1g 5672 S 58.5  2.4   5316:25 cee -n TCP-ROUTER.tswebpxmp8.1
26862 xmp       15   0 1130m 1.0g 5660 S 57.5  2.2   5451:44 cee -n TCP-ROUTER.tswebpxmp8.7
23155 xmp       15   0 1117m 1.0g 5660 S 48.2  2.2   5261:25 cee -n TCP-ROUTER.tswebpxmp8.3
26870 xmp       15   0 1119m 1.0g 5660 S 47.9  2.2   5542:04 cee -n TCP-ROUTER.tswebpxmp8.9
24955 xmp       16   0 1163m 1.1g 5660 S 46.9  2.3   5607:23 cee -n TCP-ROUTER.tswebpxmp8.5
28546 xmp       15   0 1132m 1.0g 5660 R 46.9  2.2   5472:32 cee -n TCP-ROUTER.tswebpxmp8.10

I want to grep details of every TCP-ROUTER process. how do i do it.

-Siddhesh
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to get the output of a grep command to a file inside a shell script

hi, i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (1 Reply)
Discussion started by: kripssmart
1 Replies

2. Shell Programming and Scripting

how to redirect the output of a grep command to a file inside a shell script

hi, i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (11 Replies)
Discussion started by: kripssmart
11 Replies

3. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

4. Shell Programming and Scripting

Extract header from top command output

hi, I want to extract and save the cpu(s) information from top command output, but individual cpu statistics separately on a multi-processor machine. In command line, top will show this statistics when we press the switch "1". any ideas? thanks, meharo (3 Replies)
Discussion started by: meharo
3 Replies

5. Shell Programming and Scripting

Need help with shell script - output of top command

I have written shell script to send file as an attachemt of email and output of "top -o res" command as email body. it works fine if i execute manually from prompt but it does not send "top -o res" command output in email body when it is executed via crontab. Any suggestions. My script is below:... (5 Replies)
Discussion started by: needyourhelp10
5 Replies

6. UNIX for Advanced & Expert Users

Conflicts in the output of TOP command

Hi All, In the output of TOP command in my unix system, i monitored that some process has utilization more than 100% even some process has 4000% utilisation. Please help me understand how it is possible to show more than 100% utilization. Please see the screenshot below:... (2 Replies)
Discussion started by: anand2308
2 Replies

7. HP-UX

Formatted TOP command output in file

Hi All, I want generate HP-UX overall system performance report. I tried executing top command and write that out put to file. but am not able to view the report in proper format. I can see report like below in file but i can see properly in terminal. Please suggest how can i get... (2 Replies)
Discussion started by: lravip123
2 Replies

8. Shell Programming and Scripting

Format Top and prstat command output

need help with formatting output of command top and prstat. My requirment is to remove few columns and display remaining . But when i used awk to do that the output seems to be have gone vague, mixing the column values. After using awk to print particular column the output seems to have lost... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

9. UNIX for Dummies Questions & Answers

Unable to scroll to the top of the output of a command

Hello, I am a beginner, I have currently Solaris 11 on a vmware machine. Whenever I type a command like 'ls' the screen scrolls to the end of the screen. I am unable to see the entire list of directories and files. I have tried ls |page command, but looking out for a better option. (3 Replies)
Discussion started by: farheenprasad
3 Replies

10. UNIX for Dummies Questions & Answers

Top Command Output is not coming via Cronjob

Dear All, I created a small script to get the CPU, GIS usage etc automatically. However when i run this script manually its working , but when i run through cronjob i am not getting any output. Can anyone please help me on this. I am using SuseLinux. Thank you in advance. #!/bin/sh {... (2 Replies)
Discussion started by: Nitin Kapoor
2 Replies
FAITH(4)						   BSD Kernel Interfaces Manual 						  FAITH(4)

NAME
faith -- IPv6-to-IPv4 TCP relay capturing interface SYNOPSIS
device faith DESCRIPTION
The faith interface captures IPv6 TCP traffic, for implementing userland IPv6-to-IPv4 TCP relay like faithd(8). Each faith interface is created at runtime using interface cloning. This is most easily done with the ifconfig(8) create command or using the cloned_interfaces variable in rc.conf(5). Special action will be taken when IPv6 TCP traffic is seen on a router, and the routing table suggests to route it to the faith interface. In this case, the packet will be accepted by the router, regardless of the list of IPv6 interface addresses assigned to the router. The packet will be captured by an IPv6 TCP socket, if it has the IN6P_FAITH flag turned on and matching address/port pairs. As a result, faith will let you capture IPv6 TCP traffic to some specific destination addresses. Userland programs, such as faithd(8) can use this behavior to relay IPv6 TCP traffic to IPv4 TCP traffic. The program can accept some specific IPv6 TCP traffic, perform getsockname(2) to get the IPv6 destination address specified by the client, and perform application-specific address mapping to relay IPv6 TCP to IPv4 TCP. The IN6P_FAITH flag on a IPv6 TCP socket can be set by using setsockopt(2), with level IPPROTO_IPV6 and optname IPv6_FAITH. To handle error reports by ICMPv6, some ICMPv6 packets routed to an faith interface will be delivered to IPv6 TCP, as well. To understand how faith can be used, take a look at the source code of faithd(8). As the faith interface implements potentially dangerous operations, great care must be taken when configuring it. To avoid possible misuse, the sysctl(8) variable net.inet6.ip6.keepfaith must be set to 1 prior to using the interface. When net.inet6.ip6.keepfaith is 0, no packets will be captured by the faith interface. The faith interface is intended to be used on routers, not on hosts. SEE ALSO
inet(4), inet6(4), faithd(8) Jun-ichiro itojun Hagino and Kazu Yamamoto, An IPv6-to-IPv4 transport relay translator, RFC3142. HISTORY
The FAITH IPv6-to-IPv4 TCP relay translator first appeared in the WIDE hydrangea IPv6 stack. BSD
April 10, 1999 BSD
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy