[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problemas com Script
From: |
Michel I. Moreira |
Subject: |
Problemas com Script |
Date: |
Thu, 12 Jul 2007 17:45:58 -0300 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20070403) |
Boa tarde nobres colegas....
Com a ajuda do Tiago e de algumas "googladas" cheguei a esse script
1 #!/bin/bash
2 ARQ_RES='teste.txt'
3 ARQ_RES2='teste2.txt'
4 ARQ_RES3='teste3.txt'
5 ARQ_LOG='XXX.XXX.XXX.XX_YY.log'
6 PERC='5'
7 cat $ARQ_LOG|awk '{print $1 " " strftime("%d/%m/%Y",$1) " " $2 " "
$3 " " $4 " " $5}'|sort -rn >$ARQ_RES
8 TOTAL=`cat $ARQ_RES|wc -l`
9 TPORC=$(($TOTAL*$PERC/100))
10 TTAIL=$(($TOTAL-$TPORC))
11 tail -n $TTAIL $ARQ_RES > $ARQ_RES2
12 head -n $TPORC $ARQ_RES > $ARQ_RES3
13 DAT1=`date -d '05/26/2005' +'%s'`
14 DAT2=`date -d '05/26/2007' +'%s'`
15 awk '{if ($1 >= "$DAT1" && $1 <= "$DAT2") print $0}' $ARQ_RES2
>resultado.txt
16 cat resultado.txt
Ele pega o arquivo de log de um dos meus servidores e verifica uma serie
de taxas entre duas datas diferentes, o problema é que a instrução na
linha 15 que serviria para verificar isso não funciona. Será algum erro
de logica da minha parte???
Abaixo segue como o arquivo de log esta formatada apos passar pelo
script na linha 7.
TimeStamp Data Tx1 Tx2 Tx3 Tx4
1147910400 17/05/2006 12179 12153 170024 88069
1147824000 16/05/2006 12064 12870 108607 115685
1147737600 15/05/2006 11187 12280 136655 78502
1147651200 14/05/2006 7873 9569 54172 57997
1147564800 13/05/2006 3533 4838 44923 32611
1147478400 12/05/2006 12115 13982 113932 174692
1147392000 11/05/2006 15227 16378 97502 105814
1147305600 10/05/2006 13111 14166 95345 83108
1147219200 09/05/2006 11674 13130 92191 137556
1147132800 08/05/2006 12109 12354 210254 99317
1147046400 07/05/2006 3270 3716 30422 33747
1146960000 06/05/2006 3710 4198 35379 35185
1146873600 05/05/2006 13568 13839 132962 126936
Obrigado,
Michel
- Problemas com Script,
Michel I. Moreira <=