Sar report

Sar report

am 22.11.2007 03:48:47 von apogeusistemas

Hi:
I need create a sar monthly report to my manager.
I think that I need issue:
sar -f /var/adm/sa/sa01 > z
sar -f /var/adm/sa/sa02 >> z
..
..
..
sar -f /var/adm/sa/sa31 >> z

but how create a unique file with average data from these 31 files ?
Thank you !

Re: Sar report

am 22.11.2007 10:18:13 von ramesh.thangamani

On Nov 22, 7:48 am, apogeusiste...@gmail.com wrote:
> Hi:
> I need create a sar monthly report to my manager.
> I think that I need issue:
> sar -f /var/adm/sa/sa01 > z
> sar -f /var/adm/sa/sa02 >> z
> .
> .
> .
> sar -f /var/adm/sa/sa31 >> z
>
> but how create a unique file with average data from these 31 files ?
> Thank you !

You should be using awk. Can you provide the output so that i can try
creating a script for it ?

Re: Sar report

am 22.11.2007 14:20:11 von apogeusistemas

On 22 nov, 06:18, rthangam wrote:
> On Nov 22, 7:48 am, apogeusiste...@gmail.com wrote:
>
> > Hi:
> > I need create a sar monthly report to my manager.
> > I think that I need issue:
> > sar -f /var/adm/sa/sa01 > z
> > sar -f /var/adm/sa/sa02 >> z
> > .
> > .
> > .
> > sar -f /var/adm/sa/sa31 >> z
>
> > but how create a unique file with average data from these 31 files ?
> > Thank you !
>
> You should be using awk. Can you provide the output so that i can try
> creating a script for it ?

Hi:

It's anything like this:


SunOS ultra5 5.9 sun4u 05/14/2002

15:44:26 %usr %sys %wio %idle
15:44:31 1 2 0 97
15:44:36 1 2 0 96
15:44:41 9 2 9 80
15:44:46 2 3 0 95
15:44:51 0 1 0 99
15:44:56 3 2 0 96
15:45:01 0 0 0 100
15:45:06 15 0 0 85
15:45:11 2 0 0 97
15:45:16 3 2 0 95
15:45:21 1 1 0 98
15:45:26 2 2 0 97
15:45:31 0 0 0 100
15:45:36 0 0 0 100
15:45:41 8 1 0 92
15:45:46 1 4 0 95
15:45:51 2 3 0 96
15:45:56 2 0 0 98
15:46:01 0 0 0 100
15:46:06 15 0 0 85

Average 3 1 0 95


Thanks a lot !

Re: Sar report

am 23.11.2007 20:19:38 von Christian Gollwitzer

apogeusistemas@gmail.com schrieb:
> On 22 nov, 06:18, rthangam wrote:
>> On Nov 22, 7:48 am, apogeusiste...@gmail.com wrote:
>>
>>> Hi:
>>> I need create a sar monthly report to my manager.
>>> I think that I need issue:
>>> sar -f /var/adm/sa/sa01 > z
>>> sar -f /var/adm/sa/sa02 >> z
>>> .
>>> .
>>> .
>>> sar -f /var/adm/sa/sa31 >> z
>>> but how create a unique file with average data from these 31 files ?
>>> Thank you !
>> You should be using awk. Can you provide the output so that i can try
>> creating a script for it ?
>
> Hi:
>
> It's anything like this:
>
>
> SunOS ultra5 5.9 sun4u 05/14/2002
>
> 15:44:26 %usr %sys %wio %idle
> 15:44:31 1 2 0 97
> 15:44:36 1 2 0 96
> 15:44:41 9 2 9 80
> 15:44:46 2 3 0 95
> 15:44:51 0 1 0 99
> 15:44:56 3 2 0 96
> 15:45:01 0 0 0 100
> 15:45:06 15 0 0 85
> 15:45:11 2 0 0 97
> 15:45:16 3 2 0 95
> 15:45:21 1 1 0 98
> 15:45:26 2 2 0 97
> 15:45:31 0 0 0 100
> 15:45:36 0 0 0 100
> 15:45:41 8 1 0 92
> 15:45:46 1 4 0 95
> 15:45:51 2 3 0 96
> 15:45:56 2 0 0 98
> 15:46:01 0 0 0 100
> 15:46:06 15 0 0 85
>
> Average 3 1 0 95


Try awk '/:/ { usr+=$2; sys+=$3; wio+=$4; idle+=$5; n++ } END { print
usr/n, sys/n, wio/n, idle/n }' z

Christian

Re: Sar report

am 24.11.2007 13:14:43 von apogeusistemas

On 23 nov, 16:19, Christian Gollwitzer bayreuth.de> wrote:
> apogeusiste...@gmail.com schrieb:
>
>
>
>
>
> > On 22 nov, 06:18, rthangam wrote:
> >> On Nov 22, 7:48 am, apogeusiste...@gmail.com wrote:
>
> >>> Hi:
> >>> I need create a sar monthly report to my manager.
> >>> I think that I need issue:
> >>> sar -f /var/adm/sa/sa01 > z
> >>> sar -f /var/adm/sa/sa02 >> z
> >>> .
> >>> .
> >>> .
> >>> sar -f /var/adm/sa/sa31 >> z
> >>> but how create a unique file with average data from these 31 files ?
> >>> Thank you !
> >> You should be using awk. Can you provide the output so that i can try
> >> creating a script for it ?
>
> > Hi:
>
> > It's anything like this:
>
> > SunOS ultra5 5.9 sun4u 05/14/2002
>
> > 15:44:26 %usr %sys %wio %idle
> > 15:44:31 1 2 0 97
> > 15:44:36 1 2 0 96
> > 15:44:41 9 2 9 80
> > 15:44:46 2 3 0 95
> > 15:44:51 0 1 0 99
> > 15:44:56 3 2 0 96
> > 15:45:01 0 0 0 100
> > 15:45:06 15 0 0 85
> > 15:45:11 2 0 0 97
> > 15:45:16 3 2 0 95
> > 15:45:21 1 1 0 98
> > 15:45:26 2 2 0 97
> > 15:45:31 0 0 0 100
> > 15:45:36 0 0 0 100
> > 15:45:41 8 1 0 92
> > 15:45:46 1 4 0 95
> > 15:45:51 2 3 0 96
> > 15:45:56 2 0 0 98
> > 15:46:01 0 0 0 100
> > 15:46:06 15 0 0 85
>
> > Average 3 1 0 95
>
> Try awk '/:/ { usr+=$2; sys+=$3; wio+=$4; idle+=$5; n++ } END { print
> usr/n, sys/n, wio/n, idle/n }' z
>
> Christian- Ocultar texto entre aspas -
>
> - Mostrar texto entre aspas -

Thanks a lot for this code, but if I have 2 files : file A and file B,
with sar data in this files:
solaris> cat A

SunOS ultra5 5.9 sun4u 05/14/2002


15:44:26 %usr %sys %wio %idle
15:44:31 1 2 0 97
15:44:36 1 2 0 96
15:44:41 9 2 9 80

solaris> cat B

SunOS ultra5 5.8 sun4u 05/23/2002


15:44:26 %usr %sys %wio %idle
15:44:31 3 1 0 93
15:44:36 5 1 0 91
15:44:41 7 1 9 77

I need read each line in each file with same time ,
and sum each column and get the average:

15:44:31 1 2 0 97 +
15:44:31 3 1 0 93
--------------------------------
15:44:31 4 3 0 190 /2
-----------------------------------
15:44:31 2 1.5 0 95 ---> output to a file

Did you understood me ?

Thank You again !

Re: Sar report

am 24.11.2007 17:56:52 von Cyrus Kriticos

apogeusistemas@gmail.com wrote:
>
> I need create a sar monthly report to my manager.
> I think that I need issue:
> sar -f /var/adm/sa/sa01 > z
> sar -f /var/adm/sa/sa02 >> z
> .
> .
> .
> sar -f /var/adm/sa/sa31 >> z
>
> but how create a unique file with average data from these 31 files ?
> Thank you !

A slow solution with bash:

--- cut here ---
#!/bin/bash

LINECOUNTER="1"
SAPATH="/var/adm/sa" # dir of your sa-files
SUM=(0,0,0,0)
DAYS="31" # number of days

while read FOO
do
SUM=(0,0,0,0)

for I in 0{1..9} {10..31} # or 01 02 03 04....29 30 31
do
ELEMENT=($(head -n $LINECOUNTER $SAPATH/sa$I | tail -n 1))

case "${ELEMENT[1]}" in
[0-9]*)
let SUM[1]=${SUM[1]}+${ELEMENT[1]}
let SUM[2]=${SUM[2]}+${ELEMENT[2]}
let SUM[3]=${SUM[3]}+${ELEMENT[3]}
let SUM[4]=${SUM[4]}+${ELEMENT[4]}
;;
*)
NEWLINE="${ELEMENT[@]}"
;;
esac
done

case ${ELEMENT[1]} in
[0-9]*)
let AVG[1]=${SUM[1]}/$DAYS
let AVG[2]=${SUM[2]}/$DAYS
let AVG[3]=${SUM[3]}/$DAYS
let AVG[4]=${SUM[4]}/$DAYS

echo "${ELEMENT[0]} ${AVG[1]} ${AVG[2]} ${AVG[3]} ${AVG[4]}"
;;
*)
echo "$NEWLINE"
;;
esac

let LINECOUNTER=LINECOUNTER+1
done < "$SAPATH/sa01"

--- cut here ---

Feel free to format the output or use "column -t" (if available).

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.

Re: Sar report

am 25.11.2007 01:09:33 von William James

On Nov 24, 6:14 am, apogeusiste...@gmail.com wrote:
> On 23 nov, 16:19, Christian Gollwitzer >
> bayreuth.de> wrote:
> > apogeusiste...@gmail.com schrieb:
>
> > > On 22 nov, 06:18, rthangam wrote:
> > >> On Nov 22, 7:48 am, apogeusiste...@gmail.com wrote:
>
> > >>> Hi:
> > >>> I need create a sar monthly report to my manager.
> > >>> I think that I need issue:
> > >>> sar -f /var/adm/sa/sa01 > z
> > >>> sar -f /var/adm/sa/sa02 >> z
> > >>> .
> > >>> .
> > >>> .
> > >>> sar -f /var/adm/sa/sa31 >> z
> > >>> but how create a unique file with average data from these 31 files ?
> > >>> Thank you !
> > >> You should be using awk. Can you provide the output so that i can try
> > >> creating a script for it ?
>
> > > Hi:
>
> > > It's anything like this:
>
> > > SunOS ultra5 5.9 sun4u 05/14/2002
>
> > > 15:44:26 %usr %sys %wio %idle
> > > 15:44:31 1 2 0 97
> > > 15:44:36 1 2 0 96
> > > 15:44:41 9 2 9 80
> > > 15:44:46 2 3 0 95
> > > 15:44:51 0 1 0 99
> > > 15:44:56 3 2 0 96
> > > 15:45:01 0 0 0 100
> > > 15:45:06 15 0 0 85
> > > 15:45:11 2 0 0 97
> > > 15:45:16 3 2 0 95
> > > 15:45:21 1 1 0 98
> > > 15:45:26 2 2 0 97
> > > 15:45:31 0 0 0 100
> > > 15:45:36 0 0 0 100
> > > 15:45:41 8 1 0 92
> > > 15:45:46 1 4 0 95
> > > 15:45:51 2 3 0 96
> > > 15:45:56 2 0 0 98
> > > 15:46:01 0 0 0 100
> > > 15:46:06 15 0 0 85
>
> > > Average 3 1 0 95
>
> > Try awk '/:/ { usr+=$2; sys+=$3; wio+=$4; idle+=$5; n++ } END { print
> > usr/n, sys/n, wio/n, idle/n }' z
>
> > Christian- Ocultar texto entre aspas -
>
> > - Mostrar texto entre aspas -
>
> Thanks a lot for this code, but if I have 2 files : file A and file B,
> with sar data in this files:
> solaris> cat A
>
> SunOS ultra5 5.9 sun4u 05/14/2002
>
> 15:44:26 %usr %sys %wio %idle
> 15:44:31 1 2 0 97
> 15:44:36 1 2 0 96
> 15:44:41 9 2 9 80
>
> solaris> cat B
>
> SunOS ultra5 5.8 sun4u 05/23/2002
>
> 15:44:26 %usr %sys %wio %idle
> 15:44:31 3 1 0 93
> 15:44:36 5 1 0 91
> 15:44:41 7 1 9 77
>
> I need read each line in each file with same time ,
> and sum each column and get the average:
>
> 15:44:31 1 2 0 97 +
> 15:44:31 3 1 0 93
> --------------------------------
> 15:44:31 4 3 0 190 /2
> -----------------------------------
> 15:44:31 2 1.5 0 95 ---> output to a file
>
> Did you understood me ?
>
> Thank You again !

/:/ && !/%/ {
times[FNR] = $1
for (i=2; i<=NF; i++)
totals[FNR,i] += $i
}

END {
while ( !(line in times)) line++
for ( ; line in times; line++)
{
printf "%s", times[line]
for (i=2; (line,i) in totals; i++)
printf "\t%s", totals[line,i] / (ARGC-1)
print ""
}
}

Re: Sar report

am 27.11.2007 03:05:15 von apogeusistemas

On 24 nov, 13:56, Cyrus Kriticos
wrote:
> apogeusiste...@gmail.com wrote:
>
> > I need create a sar monthly report to my manager.
> > I think that I need issue:
> > sar -f /var/adm/sa/sa01 > z
> > sar -f /var/adm/sa/sa02 >> z
> > .
> > .
> > .
> > sar -f /var/adm/sa/sa31 >> z
>
> > but how create a unique file with average data from these 31 files ?
> > Thank you !
>
> A slow solution with bash:
>
> --- cut here ---
> #!/bin/bash
>
> LINECOUNTER="1"
> SAPATH="/var/adm/sa" # dir of your sa-files
> SUM=(0,0,0,0)
> DAYS="31" # number of days
>
> while read FOO
> do
> SUM=(0,0,0,0)
>
> for I in 0{1..9} {10..31} # or 01 02 03 04....29 30 31
> do
> ELEMENT=($(head -n $LINECOUNTER $SAPATH/sa$I | tail -n 1))
>
> case "${ELEMENT[1]}" in
> [0-9]*)
> let SUM[1]=${SUM[1]}+${ELEMENT[1]}
> let SUM[2]=${SUM[2]}+${ELEMENT[2]}
> let SUM[3]=${SUM[3]}+${ELEMENT[3]}
> let SUM[4]=${SUM[4]}+${ELEMENT[4]}
> ;;
> *)
> NEWLINE="${ELEMENT[@]}"
> ;;
> esac
> done
>
> case ${ELEMENT[1]} in
> [0-9]*)
> let AVG[1]=${SUM[1]}/$DAYS
> let AVG[2]=${SUM[2]}/$DAYS
> let AVG[3]=${SUM[3]}/$DAYS
> let AVG[4]=${SUM[4]}/$DAYS
>
> echo "${ELEMENT[0]} ${AVG[1]} ${AVG[2]} ${AVG[3]} ${AVG[4]}"
> ;;
> *)
> echo "$NEWLINE"
> ;;
> esac
>
> let LINECOUNTER=LINECOUNTER+1
> done < "$SAPATH/sa01"
>
> --- cut here ---
>
> Feel free to format the output or use "column -t" (if available).
>
> --
> Best regards | Be nice to America or they'll bring democracy to
> Cyrus | your country.

Thank You so much !

I made any little modifications and it's working fine !