how to get the hostnames and memory usage biger than 30M?

how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 15:32:53 von robertchen117

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.

Re: how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 16:09:57 von Bill Marcum

On 2008-04-15, robertchen117@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}'

Re: how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 16:23:31 von Mevlut

On Tuesday 15 April 2008 15:32, robertchen117@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.

Re: how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 16:27:00 von Mevlut

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.

Re: how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 18:57:50 von gazelle

In article ,
Bill Marcum wrote:
>On 2008-04-15, robertchen117@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.

Re: how to get the hostnames and memory usage biger than 30M?

am 15.04.2008 21:43:28 von Bill Marcum

On 2008-04-15, Kenny McCormack wrote:
>
>
>>>
>>awk '0+$1>=30000 {print $1,$2}'
>
> I know AWK can do this, but I just want to use shell.
>
while read mem host; do
if [ "$mem" -gt 29999 ]; then echo "$mem $host"
done

Re: how to get the hostnames and memory usage biger than 30M?

am 16.04.2008 09:56:33 von PK

On Tuesday 15 April 2008 21:43, Bill Marcum wrote:

>>>awk '0+$1>=30000 {print $1,$2}'
>>
>> I know AWK can do this, but I just want to use shell.
>>
> while read mem host; do
> if [ "$mem" -gt 29999 ]; then echo "$mem $host"
> done

You are missing a "fi".

Then, are you sure this is what the OP wanted?

$ while read mem host; do
if [ "$mem" -gt 29999 ]; then echo "$mem $host"; fi
done < file
-bash: [:
############################################################ ################:
integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Return: integer expression expected
-bash: [: ------Standard: integer expression expected
-bash: [: SUCCESS: integer expression expected
-bash: [: ------Standard: integer expression expected
-bash: [:
############################################################ ################:
integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Return: integer expression expected
-bash: [: ------Standard: integer expression expected
-bash: [: SUCCESS: integer expression expected
-bash: [: ------Standard: integer expression expected
-bash: [:
############################################################ ################:
integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Task: integer expression expected
-bash: [: Return: integer expression expected
-bash: [: ------Standard: integer expression expected
-bash: [: SUCCESS: integer expression expected
52000 tecad
-bash: [: ------Standard: integer expression expected
-bash: [:
############################################################ ################:
integer expression expected