awk doubt
am 14.09.2007 19:45:11 von apogeusistemas
Can you tell me how extract a specified data from sar and put date and
hour in front of each line ?
solaris> sar -d | head
00:05:00 nfs1 0 0.0 0 0
0.0 0.0
sd6 0 0.0 0 0
0.0 0.0
sd85 0 0.0 0 0
0.0 0.0
sd85,c 0 0.0 0 0
0.0 0.0
sd86 0 0.0 0 0
0.0 0.0
solaris> sar -d | head | ./script
09/13/07 00:05:00 nfs1 0 0.0 0 0
0.0 0.0
09/13/07 00:05:00 sd6 0 0.0 0 0
0.0 0.0
09/13/07 00:05:00 sd85 0 0.0 0 0
0.0 0.0
09/13/07 00:05:00 sd85,c 0 0.0 0 0
0.0 0.0
09/13/07 00:05:00 sd86 0 0.0 0 0
0.0 0.0
Re: awk doubt
am 14.09.2007 20:03:38 von Janis Papanagnou
apogeusistemas@gmail.com wrote:
> Can you tell me how extract a specified data from sar and put date and
> hour in front of each line ?
In your example below there's already the time present, so...
sar -d | head | awk -v d=$(date +%m/%d/%y) '{print d, $0}'
Change the date command format, if necessary.
Janis
>
>
> solaris> sar -d | head
>
> 00:05:00 nfs1 0 0.0 0 0
> 0.0 0.0
> sd6 0 0.0 0 0
> 0.0 0.0
> sd85 0 0.0 0 0
> 0.0 0.0
> sd85,c 0 0.0 0 0
> 0.0 0.0
> sd86 0 0.0 0 0
> 0.0 0.0
>
>
>
>
>
> solaris> sar -d | head | ./script
>
>
> 09/13/07 00:05:00 nfs1 0 0.0 0 0
> 0.0 0.0
> 09/13/07 00:05:00 sd6 0 0.0 0 0
> 0.0 0.0
> 09/13/07 00:05:00 sd85 0 0.0 0 0
> 0.0 0.0
> 09/13/07 00:05:00 sd85,c 0 0.0 0 0
> 0.0 0.0
> 09/13/07 00:05:00 sd86 0 0.0 0 0
> 0.0 0.0
>
Re: awk doubt
am 14.09.2007 20:08:34 von Ed Morton
Janis Papanagnou wrote:
> apogeusistemas@gmail.com wrote:
>
>> Can you tell me how extract a specified data from sar and put date and
>> hour in front of each line ?
>
>
> In your example below there's already the time present, so...
>
> sar -d | head | awk -v d=$(date +%m/%d/%y) '{print d, $0}'
The time's only present on the first input line:
ar -d | head | awk -v d=$(date +%m/%d/%y) 'NR==1{t=$1; print d,$0; next}
{print d,t,$0}'
Ed.
>
> Change the date command format, if necessary.
>
> Janis
>
>>
>>
>> solaris> sar -d | head
>>
>> 00:05:00 nfs1 0 0.0 0 0
>> 0.0 0.0
>> sd6 0 0.0 0 0
>> 0.0 0.0
>> sd85 0 0.0 0 0
>> 0.0 0.0
>> sd85,c 0 0.0 0 0
>> 0.0 0.0
>> sd86 0 0.0 0 0
>> 0.0 0.0
>>
>>
>>
>>
>>
>> solaris> sar -d | head | ./script
>>
>>
>> 09/13/07 00:05:00 nfs1 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd6 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd85 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd85,c 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd86 0 0.0 0 0
>> 0.0 0.0
>>
>
Re: awk doubt
am 14.09.2007 20:10:29 von Janis Papanagnou
Janis Papanagnou wrote:
> apogeusistemas@gmail.com wrote:
>
>> Can you tell me how extract a specified data from sar and put date and
>> hour in front of each line ?
I misread your request. Modulo formatting (use printf()) you wanted
something like...
sar -d | head | awk -v d=$(date +%m/%d/%y) '{print d,t,$0} NR==1{t=$1}'
>
> Janis
>
>>
>>
>> solaris> sar -d | head
>>
>> 00:05:00 nfs1 0 0.0 0 0
>> 0.0 0.0
>> sd6 0 0.0 0 0
>> 0.0 0.0
>> sd85 0 0.0 0 0
>> 0.0 0.0
>> sd85,c 0 0.0 0 0
>> 0.0 0.0
>> sd86 0 0.0 0 0
>> 0.0 0.0
>>
>>
>>
>>
>>
>> solaris> sar -d | head | ./script
>>
>>
>> 09/13/07 00:05:00 nfs1 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd6 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd85 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd85,c 0 0.0 0 0
>> 0.0 0.0
>> 09/13/07 00:05:00 sd86 0 0.0 0 0
>> 0.0 0.0
>>
>
Re: awk doubt
am 14.09.2007 22:14:46 von apogeusistemas
On 14 set, 15:08, Ed Morton wrote:
> Janis Papanagnou wrote:
> > apogeusiste...@gmail.com wrote:
>
> >> Can you tell me how extract a specified data from sar and put date and
> >> hour in front of each line ?
>
> > In your example below there's already the time present, so...
>
> > sar -d | head | awk -v d=$(date +%m/%d/%y) '{print d, $0}'
>
> The time's only present on the first input line:
>
> ar -d | head | awk -v d=$(date +%m/%d/%y) 'NR==1{t=$1; print d,$0; next}
> {print d,t,$0}'
>
> Ed.
>
>
>
>
>
> > Change the date command format, if necessary.
>
> > Janis
>
> >> solaris> sar -d | head
>
> >> 00:05:00 nfs1 0 0.0 0 0
> >> 0.0 0.0
> >> sd6 0 0.0 0 0
> >> 0.0 0.0
> >> sd85 0 0.0 0 0
> >> 0.0 0.0
> >> sd85,c 0 0.0 0 0
> >> 0.0 0.0
> >> sd86 0 0.0 0 0
> >> 0.0 0.0
>
> >> solaris> sar -d | head | ./script
>
> >> 09/13/07 00:05:00 nfs1 0 0.0 0 0
> >> 0.0 0.0
> >> 09/13/07 00:05:00 sd6 0 0.0 0 0
> >> 0.0 0.0
> >> 09/13/07 00:05:00 sd85 0 0.0 0 0
> >> 0.0 0.0
> >> 09/13/07 00:05:00 sd85,c 0 0.0 0 0
> >> 0.0 0.0
> >> 09/13/07 00:05:00 sd86 0 0.0 0 0
> >> 0.0 0.0- Ocultar texto entre aspas -
>
> - Mostrar texto entre aspas -
This command generate this output:
437 17:10:00 cmdk0 0 0.0 1 3 11.3 4.1
438 fd0 0 0.0 1 3 11.3 4.5
439 nfs1 0 0.0 0 0 0.0 0.0
and I'd like this:
09/13/07 17:10:00 cmdk0 0 0.0 1 3 11.3 4.1
09/13/07 17:10:00 fd0 0 0.0 1 5 0.0 0.0
09/13/07 17;10;00 nfs1 0 0.0 2 5 1.0 1.1
Re: awk doubt
am 15.09.2007 00:21:56 von Ed Morton
apogeusistemas@gmail.com wrote:
> On 14 set, 15:08, Ed Morton wrote:
>
>>Janis Papanagnou wrote:
>>
>>>apogeusiste...@gmail.com wrote:
>>
>>>>Can you tell me how extract a specified data from sar and put date and
>>>>hour in front of each line ?
>>
>>>In your example below there's already the time present, so...
>>
>>> sar -d | head | awk -v d=$(date +%m/%d/%y) '{print d, $0}'
>>
>>The time's only present on the first input line:
>>
>>ar -d | head | awk -v d=$(date +%m/%d/%y) 'NR==1{t=$1; print d,$0; next}
>>{print d,t,$0}'
>>
>>
>>>>solaris> sar -d | head
>>
>>>>00:05:00 nfs1 0 0.0 0 0
>>>>0.0 0.0
>>>> sd6 0 0.0 0 0
>>>>0.0 0.0
>>>> sd85 0 0.0 0 0
>>>>0.0 0.0
>>>> sd85,c 0 0.0 0 0
>>>>0.0 0.0
>>>> sd86 0 0.0 0 0
>>>>0.0 0.0
>>
>
> This command generate this output:
> 437 17:10:00 cmdk0 0 0.0 1 3 11.3 4.1
> 438 fd0 0 0.0 1 3 11.3 4.5
> 439 nfs1 0 0.0 0 0 0.0 0.0
I doubt it. Post a screen snapshot of what you actually did.
Ed.