shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Res: [shell-script] (unknown)


From: ikami
Subject: Res: [shell-script] (unknown)
Date: Fri, 17 Aug 2007 10:22:11 -0700 (PDT)

Muito obrigado Tiago!
Os dois comandos funcionaram perfeitamente!
Eu só gostaria agora de entende-lô campo a campo! ehehhe
Voce pode me indicar um site, tutorial, livro ou qualquer outra coisa para 
aprender sed e awk?

Muito obrigado

Íkami

----- Mensagem original ----
De: Tiago Barcellos Peczenyj <address@hidden>
Para: address@hidden
Enviadas: Sexta-feira, 17 de Agosto de 2007 11:32:16
Assunto: Re: [shell-script] (unknown)









  


    
            podes usar sed + awk



sed -n '/^---/,/^$/ p' sql.txt | LC_ALL=pt_BR awk '$NF >= 90 {print $1,$NF}'

SYSAUX 96,28

SYSTEM 92,71



o que eu fiz? com o sed eu seleciono tudo entre ---- e aquela linha em

branco.



com o awk eu imprimo o primeiro e o ultimo campo caso o ultimo seja maior ou

igual à 90.



o LC_ALL=pt_BR serve para que o awk entenda que , é o separador decimal



se nao funcionar use



sed -n '/^---/,/^$/ {y/,/./;p} ' sql.txt |  awk '$NF >= 90 {print $1,$NF}'



On 8/17/07, ikami <ikamig@yahoo. com.br> wrote:

>

>   Ola pessoal!

> Estou precisando fazer um script para tratar um arquivo. Estou tentando

> fazer isso para terminar um plugin para o nagios.

> Seguinte, preciso pegar um arquivo (lista de tabelas de banco) que meu

> banco de dados gera e verificar se alguma tabela esta estourando ou nao (tem

> alguma esta com a utilizacao acima de 90%).

> O aquivo ter algumas sujeiras no comeco e no final e no meio tem as

> informacoes que tenho q tratar.

> Estou mandando um exemplo do arquivo em anexo porque colando aqui a

> formatacao dele muda.

> Na ultima coluna ele mostra a % ocupada da tabela. São estes campos que

> quero pegar.

> A idéia eh ler essa coluna e quando achar um valor maior ou igual a 90 ele

> me retornar a linha inteira

>

> Tentei ler somente essa coluna com o comando cut mas nao tive sucesso.

> Acho q pq ele nao está reconhecendo as colunas. Entao, lendo alguns posts

> passados da lista descobri o comando expand e unexpand e tentei colocar

> algumas tabulacoes entre as linhas para depois fazer o cut na coluna. Nao

> consegui tb.

>

> Resumindo. Estou travado ainda na ideia de ler essa ultima coluna!

>

> Grato.

>

> Flickr agora em português. Você clica, todo mundo vê.

> http://www.flickr. com.br/

> ----------

>

>

> SQL*Plus: Release 10.1.0.4.0 - Production on Tue Aug 14 16:42:33 2007

>

> Copyright (c) 1982, 2005, Oracle. All rights reserved.

>

> Enter user-name:

> Connected to:

> Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production

> With the Partitioning, OLAP and Data Mining options

>

> SQL> SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15

> TABLESPACE TOTAL KB LIVRE KB OCUPADO KB % LIVRE % OCUPADO

> ------------ --------- --------- ------------ - ------------ - ------------ -

> ---------- ----------

> ADMINISTRATI_ DAT_01 102400.00 101760.00 640.00 99,38 ,63

> ADMINISTRATI_ IDX_01 102400.00 102336.00 64.00 99,94 ,06

> AUDITORIA_DAT_ 01 102400.00 100608.00 1792.00 98,25 1,75

> CONFIGURACAO_ DAT_01 102400.00 102272.00 128.00 99,88 ,13

> CONFIGURACAO_ IDX_01 102400.00 102336.00 64.00 99,94 ,06

> FRAMEWORK_DAT_ 01 102400.00 102272.00 128.00 99,88 ,13

> FRAMEWORK_IDX_ 01 102400.00 102336.00 64.00 99,94 ,06

> HELP_DAT_01 102400.00 98304.00 4096.00 96 4

> HELP_IDX_01 102400.00 102336.00 64.00 99,94 ,06

> INTERACAO_USR_ DAT_01 102400.00 99840.00 2560.00 97,5 2,5

> INTERACAO_USR_ IDX_01 102400.00 102336.00 64.00 99,94 ,06

> SEGURANCA_DAT_ 01 102400.00 102272.00 128.00 99,88 ,13

> SEGURANCA_IDX_ 01 102400.00 102336.00 64.00 99,94 ,06

> TREINAMENTO 102400.00 35584.00 66816.00 34,75 65,25

> SYSAUX 225280.00 8384.00 216896.00 3,72 96,28

> SYSTEM 307200.00 22400.00 284800.00 7,29 92,71

> UNDOTBS1 204800.00 195072.00 9728.00 95,25 4,75

> USERS 124160.00 47616.00 76544.00 38,35 61,65

>

> 18 rows selected.

>

> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release

> 10.2.0.3.0 - Production

> With the Partitioning, OLAP and Data Mining options

>

> [As partes desta mensagem que não continham texto foram removidas]

>

>  

>



-- 

Tiago B Peczenyj

Linux User #405772



http://peczenyj. blogspot. com/



[As partes desta mensagem que não continham texto foram removidas]





    
  

    
    




<!--

#ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
#ygrp-mlmsg table {font-size:inherit;font:100%;}
#ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, 
sans-serif;}
#ygrp-mlmsg pre, code {font:115% monospace;}
#ygrp-mlmsg * {line-height:1.22em;}
#ygrp-text{
font-family:Georgia;
}
#ygrp-text p{
margin:0 0 1em 0;}
#ygrp-tpmsgs{
font-family:Arial;
clear:both;}
#ygrp-vitnav{
padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
#ygrp-vitnav a{
padding:0 1px;}
#ygrp-actbar{
clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
#ygrp-actbar .left{
float:left;white-space:nowrap;}
.bld{font-weight:bold;}
#ygrp-grft{
font-family:Verdana;font-size:77%;padding:15px 0;}
#ygrp-ft{
font-family:verdana;font-size:77%;border-top:1px solid #666;
padding:5px 0;
}
#ygrp-mlmsg #logo{
padding-bottom:10px;}

#ygrp-vital{
background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
#ygrp-vital #vithd{
font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
#ygrp-vital ul{
padding:0;margin:2px 0;}
#ygrp-vital ul li{
list-style-type:none;clear:both;border:1px solid #e0ecee;
}
#ygrp-vital ul li .ct{
font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
#ygrp-vital ul li .cat{
font-weight:bold;}
#ygrp-vital a {
text-decoration:none;}

#ygrp-vital a:hover{
text-decoration:underline;}

#ygrp-sponsor #hd{
color:#999;font-size:77%;}
#ygrp-sponsor #ov{
padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
#ygrp-sponsor #ov ul{
padding:0 0 0 8px;margin:0;}
#ygrp-sponsor #ov li{
list-style-type:square;padding:6px 0;font-size:77%;}
#ygrp-sponsor #ov li a{
text-decoration:none;font-size:130%;}
#ygrp-sponsor #nc {
background-color:#eee;margin-bottom:20px;padding:0 8px;}
#ygrp-sponsor .ad{
padding:8px 0;}
#ygrp-sponsor .ad #hd1{
font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
#ygrp-sponsor .ad a{
text-decoration:none;}
#ygrp-sponsor .ad a:hover{
text-decoration:underline;}
#ygrp-sponsor .ad p{
margin:0;}
o {font-size:0;}
.MsoNormal {
margin:0 0 0 0;}
#ygrp-text tt{
font-size:120%;}
blockquote{margin:0 0 0 4px;}
.replbq {margin:4;}
-->








      Flickr agora em português. Você clica, todo mundo vê.
http://www.flickr.com.br/

[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]