|
From: robertchen117 on 15 Apr 2008 09:32 I am trying to scan 100+ hosts for tecad process memory usage, there are maybe a few tecad processes on one host. see the result is a long list: ############################################################################ Task Name: task Task Endpoint: hostname1 Return Code: 0 ------Standard Output------ SUCCESS 5248 tecad ------Standard Error Output------ ############################################################################ Task Name: task Task Endpoint: hostname2 Return Code: 0 ------Standard Output------ SUCCESS 5248 tecad ------Standard Error Output------ ############################################################################ Task Name: task Task Endpoint: hostname3 Return Code: 0 ------Standard Output------ SUCCESS 5176 tecad 52000 tecad ------Standard Error Output------ ############################################################################ ................. I use this command: awk '0 + $1 >= 30000 {print $1}' result.log find all these line with biger than 50M memory usage. But the issue is I need to get the hostname. For example, I need to get hostname3 because one of the tecad memory is 52000 (> 30000). What is the trick to get these hostnames and it memory usage > 30000. Please help me. I know perl can do this but I just want to use shell. Thanks.
From: Dave B on 15 Apr 2008 10:23 On Tuesday 15 April 2008 15:32, robertchen117(a)gmail.com wrote: > I am trying to scan 100+ hosts for tecad process memory usage, there > are maybe a few tecad processes on one host. see the result is a long > list: > > ############################################################################ > Task Name: task > Task Endpoint: hostname1 > Return Code: 0 > ------Standard Output------ > SUCCESS > 5248 tecad > ------Standard Error Output------ > ############################################################################ > Task Name: task > Task Endpoint: hostname2 > Return Code: 0 > ------Standard Output------ > SUCCESS > 5248 tecad > ------Standard Error Output------ > ############################################################################ > Task Name: task > Task Endpoint: hostname3 > Return Code: 0 > ------Standard Output------ > SUCCESS > 5176 tecad > 52000 tecad > ------Standard Error Output------ > ############################################################################ > ................ > > I use this command: > awk '0 + $1 >= 30000 {print $1}' result.log This command is a bit rough if run directly on the input you show above...it probably works though. > find all these line with biger than 50M memory usage. But the issue is > I need to get the hostname. For example, I need to get hostname3 > because one of the tecad memory is 52000 (> 30000). > > What is the trick to get these hostnames and it memory usage > 30000. It's not clear whether you want only the hostname or hostname+tecad memory usage. Furthermore, you don't say what can be found in the "Standard Error Output" section. However, let's stay on the safe side (process only the "Standard Output" section), and let's assume you want hostname+tecad memory usage. $ awk '/^Task Endpoint:/ {h=$3;next} $0=="------Standard Output------" {f=1;next} $0=="------Standard Error Output------" { if(ok){print h mu};ok=f=0;m="";next} (f==1)&&($2=="tecad")&&($1+0>=30000) {ok=1;m=m" "$1}' result.log hostname3 52000 Note that the above allows for more than one "tecad" entry with memory usage > 30000 per host (which you didn't say could happen, but just in case...). -- D.
From: Dave B on 15 Apr 2008 10:27 On Tuesday 15 April 2008 16:23, Dave B wrote: > $ awk '/^Task Endpoint:/ {h=$3;next} > $0=="------Standard Output------" {f=1;next} > $0=="------Standard Error Output------" { > if(ok){print h mu};ok=f=0;m="";next} > (f==1)&&($2=="tecad")&&($1+0>=30000) {ok=1;m=m" "$1}' result.log > hostname3 52000 Sorry, fat fingering. The 4th line above should be if(ok){print h m};ok=f=0;m="";next} -- D.
From: Bill Marcum on 15 Apr 2008 10:09 On 2008-04-15, robertchen117(a)gmail.com <robertchen117(a)gmail.com> wrote: > > I use this command: > awk '0 + $1 >= 30000 {print $1}' result.log > > find all these line with biger than 50M memory usage. But the issue is > I need to get the hostname. For example, I need to get hostname3 > because one of the tecad memory is 52000 (> 30000). > > What is the trick to get these hostnames and it memory usage > 30000. > awk '0+$1>=30000 {print $1,$2}'
From: Kenny McCormack on 15 Apr 2008 12:57 In article <slrng09dpl.6sk.marcumbill(a)lark.localnet>, Bill Marcum <marcumbill(a)bellsouth.net> wrote: >On 2008-04-15, robertchen117(a)gmail.com <robertchen117(a)gmail.com> wrote: >> >> I use this command: >> awk '0 + $1 >= 30000 {print $1}' result.log >> >> find all these line with biger than 50M memory usage. But the issue is >> I need to get the hostname. For example, I need to get hostname3 >> because one of the tecad memory is 52000 (> 30000). >> >> What is the trick to get these hostnames and it memory usage > 30000. >> >awk '0+$1>=30000 {print $1,$2}' I know AWK can do this, but I just want to use shell.
|
Next
|
Last
Pages: 1 2 Prev: suspending cron job execution between certain period Next: Environment Files |