+ Responder ao Tópico



  1. Alguem pode me agudar com esse script que peguei aqui em uns os topicos?
    Está funcionado ok no linux. Mais presciso que funcione em php. (WEB).
    Quando estiver funcionado ok, coloco aki para nos usarmos. é para pegar as informaçoes do cliente no mikrotik filtrar só o que eu quero e mostrar na web.



    #GERA HORA
    dia=`date +%d`
    mes=`date +%m`
    ano=`date +%Y`
    hora=`date +%H`
    minuto=`date +%M`
    segundo=`date +%S`

    # ZERA TODAS A VARIAVES E ARQUIVOS
    ARQUIVO=0
    ARQUIVO=0
    FTP_HOST=0
    FTP_USER=0
    FTP_PASS=0
    NOMEAP=0
    PAGINA=0
    PASTAFILES=0
    PASTAPAGINA=0
    echo > sinal2
    echo > sinal3
    echo > sinal4

    #######################################################################################################
    ## CONFIGURACOES GERAIS ###############################################################################
    #######################################################################################################
    ACK_ALARME="110"
    SNR_ALARME="28"
    ARQUIVO="sinal.txt"
    FTP_HOST="ip aki"
    FTP_USER="login"
    FTP_PASS="senhaki"
    NOMEAP="mikrotik"
    PAGINA="teste_soares.html"
    PASTAFILES="/var/www/htdocs/apteste/"
    PASTAPAGINA="/var/www/htdocs/apteste/"
    cd $PASTAFILES
    # ZERA ARQUIVOS
    echo > $PAGINA
    echo > $PAGINAFILES/$PAGINA
    echo > $PASTAPAGINA/$PAGINA

    # ROTINA FTP DE DOWNLOAD DO ARQUIVO (SINAL.TX) DO MIKROTIK
    cd $PASTAFILES
    ftp -in $FTP_HOST << fim
    user $FTP_USER $FTP_PASS
    get $ARQUIVO
    bye
    EOF
    fim

    #ROTINA DE TRATAMENTO DO ARQUIVO PRA GERACAO DO HTML
    cat sinal.txt | fmt -w 1 | grep mac-address > mac
    cat sinal.txt | fmt -w 1 | grep interface > interface
    cat sinal.txt | fmt -w 1 | grep tx-rate > sinaltx
    cat sinal.txt | fmt -w 1 | grep rx-rate > sinalrx
    cat sinal.txt | fmt -w 1 | grep uptime > sinaluptime
    cat sinal.txt | fmt -w 1 | grep last-activity > sinallast
    cat sinal.txt | fmt -w 1 | grep signal-strength | grep -v tx-signal > sinalstrength
    cat sinal.txt | fmt -w 1 | grep signal-to-noise > sinalnoise
    cat sinal.txt | fmt -w 1 | grep tx-ccq > sinaltxccq
    cat sinal.txt | fmt -w 1 | grep p-throughput > sinaltrough
    cat sinal.txt | fmt -w 1 | grep ack-timeout > sinalack
    cat sinal.txt | fmt -w 1 | grep distance > sinaldistance
    cat sinal.txt | fmt -w 1 | grep last-ip > ipadress


    paste sinalstrength mac sinalrx sinaltx sinalnoise sinaltxccq sinaltrough sinalack sinaldistance sinaluptime interface ipadres
    s> sinal2.txt

    cat sinal2.txt | sed -e 's/rx-rate/ /g' | sed -e 's/mac-address/ /g' | sed -e 's/tx-rate/ /g' | sed -e 's/uptime/ /g' | sed -e
    's/signal-strength/ /g' | sed -e 's/signal-to-noise/ /g' | sed -e 's/tx-ccq/ /g' | sed -e 's/ack-timeout/ /g' | sed -e 's/p-t
    hroughput/ /g' | sed -e 's/last-ip/ /g' | sed -e 's/distance/ /g' | sed -e 's/interface/ /g' | sort -n > sinal3.txt
    cat sinal3.txt | sed 's/[\x09]//g' | sed 's/ //g' | sed 's/ /=/g' > sinal4.txt
    cat sinal4.txt | sed 's/===/=/g' > sinal5.txt
    #cat sinal5.txt | grep tx-ccq > sinal6.txt

    TOTAL=`cat $PASTAFILES/sinal4.txt | wc -l`



    #ROTINA DE ORGANIZACAO DOS DADOS
    for i in `cat $PASTAFILES/sinal5.txt`; do
    IP=`echo $i | cut -d "=" -f13`
    MAC=`echo $i | cut -d "=" -f3`
    INTERFACE=`echo $i | cut -d "=" -f12`
    TX=`echo $i | cut -d "=" -f5`
    RX=`echo $i | cut -d "=" -f4`
    THROUGPUT=`echo $i | cut -d "=" -f8`
    UPTIME=`echo $i | cut -d "=" -f11`
    ACK=`echo $i | cut -d "=" -f9`
    TXCCQ=`echo $i | cut -d "=" -f7`
    SNR=`echo $i | cut -d "=" -f6 | sed 's/dB//g'`
    SINAL=`echo $i | cut -d "=" -f2`
    SNRGRAFICO=`expr $SNR \* 5`

    #ROTINA DE VERIFICACAO DE SNR E ACK PARA ALARME VISUAL

    if [ $SNR -lt $SNR_ALARME ]
    then
    GRAFICO='pixelvermelho.png'
    else
    GRAFICO='pixelverde.png'
    fi

    if [ $ACK -gt $ACK_ALARME ]
    then
    GRAFICO2='pixelvermelho.png'
    else
    GRAFICO2='pixelverde.png'
    fi

    #ROTINA DE INSERCAO DE DADOS NO HTML
    echo \ " <tr>" >> $PAGINA
    echo \ " <td><span class='style1'>"$IP"</span></td>"
    echo \ " <td><span class='style1'>"$MAC"</span></td>"
    echo \ " <td><span class='style1'>"$INTERFACE"</span></td>"
    echo \ " <td><span class='style1'>"$TX"</span></td>"
    echo \ " <td><span class='style1'>"$RX"</span></td>"
    echo \ " <td><span class='style1'>"$THROUGPUT"</span></td>" A
    echo \ " <td><span class='style1'>"$UPTIME"</span></td>"
    echo \ " <td><span class='style1'>"$ACK "<img src='"$GRAFICO2"' height='10px' width='10'></span></td> "
    echo \ " <td><span class='style1'>"$TXCCQ"</span></td>"
    echo \ " <td><span class='style1'>"$SNR"</td> " >> $PAGINA
    echo \ " <td><span class='style1'><img src='"$GRAFICO"' height='10px' width='"$SNRGRAFICO"'>$SINAL</td>"
    echo \ " </tr>"


    done

  2. Vo tentar te ajudar mas sem estress o codigo nao ta pronto vai demorar, preciso entender mais seu codigo para rescrever para vc e tbm preciso acesso, instale o teamspeak no seu pc e pegue um mic apos entre neste servidor ts.vipnetsul.com.br

    Código :
    <?php
    #GERA HORA
    $dia=`date +%d`;
    $mes=`date +%m`;
    $ano=`date +%Y`;
    $hora=`date +%H`;
    $minuto=`date +%M`;
    $segundo=`date +%S`;
     
    # ZERA TODAS A VARIAVES E ARQUIVOS
    $ARQUIVO=0;
    $ARQUIVO=0;
    $FTP_HOST=0;
    $FTP_USER=0;
    $FTP_PASS=0;
    $NOMEAP=0;
    $PAGINA=0;
    $PASTAFILES=0;
    $PASTAPAGINA=0;
    echo > sinal2;
    echo > sinal3;
    echo > sinal4;
     
     //CONFIGURACOES GERAIS
    $ACK_ALARME="110";
    $SNR_ALARME="28";
    $ARQUIVO="sinal.txt";
    $FTP_HOST="ip aki";
    $FTP_USER="login";
    $FTP_PASS="senhaki";
    $NOMEAP="mikrotik";
    $PAGINA="teste_soares.html";
    $PASTAFILES="/var/www/htdocs/apteste/";
    $PASTAPAGINA="/var/www/htdocs/apteste/";
    //cd $PASTAFILES
    //ZERA ARQUIVOS
    //O QUE VC QUER FAZER AQUI NESTES ECHO? LIMPAR?
    echo > $PAGINA
    echo > $PAGINAFILES/$PAGINA
    echo > $PASTAPAGINA/$PAGINA
     
    //ROTINA FTP DE DOWNLOAD DO  ARQUIVO (SINAL.TX) DO MIKROTIK
    //cd $PASTAFILES
    ftp -in $FTP_HOST << fim
                       user $FTP_USER $FTP_PASS
                       get $ARQUIVO
                       bye
                       EOF
    fim
     
    //ROTINA DE TRATAMENTO DO ARQUIVO PRA GERACAO DO HTML
    cat sinal.txt | fmt -w 1 | grep mac-address > mac
    cat sinal.txt | fmt -w 1 | grep interface > interface
    cat sinal.txt | fmt -w 1 | grep tx-rate > sinaltx
    cat sinal.txt | fmt -w 1 | grep rx-rate > sinalrx
    cat sinal.txt | fmt -w 1 | grep uptime > sinaluptime
    cat sinal.txt | fmt -w 1 | grep last-activity > sinallast
    cat sinal.txt | fmt -w 1 | grep signal-strength | grep -v tx-signal > sinalstrength
    cat sinal.txt | fmt -w 1 | grep signal-to-noise > sinalnoise
    cat sinal.txt | fmt -w 1 | grep tx-ccq > sinaltxccq
    cat sinal.txt | fmt -w 1 | grep p-throughput > sinaltrough
    cat sinal.txt | fmt -w 1 | grep ack-timeout > sinalack
    cat sinal.txt | fmt -w 1 | grep distance > sinaldistance
    cat sinal.txt | fmt -w 1 | grep last-ip > ipadress
     
     
    paste sinalstrength mac sinalrx sinaltx sinalnoise sinaltxccq sinaltrough sinalack sinaldistance sinaluptime interface ipadres
    s> sinal2.txt
     
    cat sinal2.txt | sed -e 's/rx-rate/ /g' | sed -e 's/mac-address/ /g' | sed -e 's/tx-rate/ /g' | sed -e 's/uptime/ /g' | sed -e
     's/signal-strength/ /g' | sed -e 's/signal-to-noise/ /g' | sed -e 's/tx-ccq/ /g' | sed -e 's/ack-timeout/ /g' | sed -e 's/p-t
    hroughput/ /g' | sed -e 's/last-ip/ /g' | sed -e 's/distance/ /g' | sed -e 's/interface/ /g' | sort -n > sinal3.txt
    cat sinal3.txt | sed 's/[\x09]//g' | sed 's/ //g' | sed 's/  /=/g' > sinal4.txt
    cat sinal4.txt | sed 's/===/=/g' > sinal5.txt
    #cat sinal5.txt | grep tx-ccq > sinal6.txt
     
    TOTAL=`cat $PASTAFILES/sinal4.txt | wc -l`
     
     
     
    #ROTINA DE ORGANIZACAO DOS DADOS
    for i in `cat $PASTAFILES/sinal5.txt`; do
     IP=`echo $i | cut -d "=" -f13`
     MAC=`echo $i | cut -d "=" -f3`
     INTERFACE=`echo $i | cut -d "=" -f12`
     TX=`echo $i | cut -d "=" -f5`
     RX=`echo $i | cut -d "=" -f4`
     THROUGPUT=`echo $i | cut -d "=" -f8`
     UPTIME=`echo $i | cut -d "=" -f11`
     ACK=`echo $i | cut -d "=" -f9`
     TXCCQ=`echo $i | cut -d "=" -f7`
     SNR=`echo $i | cut -d "=" -f6 | sed 's/dB//g'`
     SINAL=`echo $i | cut -d "=" -f2`
     SNRGRAFICO=`expr $SNR \* 5`
     
    #ROTINA DE VERIFICACAO DE SNR E ACK PARA ALARME VISUAL
     
    if [ $SNR -lt $SNR_ALARME ]
     then
        GRAFICO='pixelvermelho.png'
     else
        GRAFICO='pixelverde.png'
     fi
     
    if [ $ACK -gt $ACK_ALARME ]
     then
        GRAFICO2='pixelvermelho.png'
     else
        GRAFICO2='pixelverde.png'
     fi
    ?>
    //#ROTINA DE INSERCAO DE DADOS NO HTML
    echo \ "  <tr>" >> $PAGINA
    echo \ "    <td><span class='style1'>"$IP"</span></td>" 
    echo \ "    <td><span class='style1'>"$MAC"</span></td>" 
    echo \ "    <td><span class='style1'>"$INTERFACE"</span></td>" 
    echo \ "    <td><span class='style1'>"$TX"</span></td>"
    echo \ "    <td><span class='style1'>"$RX"</span></td>" 
    echo \ "    <td><span class='style1'>"$THROUGPUT"</span></td>" A
    echo \ "    <td><span class='style1'>"$UPTIME"</span></td>" 
    echo \ " <td><span class='style1'>"$ACK "<img src='"$GRAFICO2"' height='10px' width='10'></span></td> " 
    echo \ "    <td><span class='style1'>"$TXCCQ"</span></td>" 
    echo \ "    <td><span class='style1'>"$SNR"</td> " >> $PAGINA
    echo \ " <td><span class='style1'><img src='"$GRAFICO"' height='10px' width='"$SNRGRAFICO"'>$SINAL</td>" 
    echo \ "  </tr>" 
     
     
    done
    Última edição por Pirigoso; 24-10-2009 às 12:20.



  3. Citação Postado originalmente por Pirigoso Ver Post
    Vo tentar te ajudar mas sem estress o codigo nao ta pronto vai demorar, preciso entender mais seu codigo para rescrever para vc e tbm preciso acesso, instale o teamspeak no seu pc e pegue um mic apos entre neste servidor ts.vipnetsul.com.br

    Código :
    <?php
    #GERA HORA
    $dia=`date +%d`;
    $mes=`date +%m`;
    $ano=`date +%Y`;
    $hora=`date +%H`;
    $minuto=`date +%M`;
    $segundo=`date +%S`;
     
    # ZERA TODAS A VARIAVES E ARQUIVOS
    $ARQUIVO=0;
    $ARQUIVO=0;
    $FTP_HOST=0;
    $FTP_USER=0;
    $FTP_PASS=0;
    $NOMEAP=0;
    $PAGINA=0;
    $PASTAFILES=0;
    $PASTAPAGINA=0;
    echo > sinal2;
    echo > sinal3;
    echo > sinal4;
     
     //CONFIGURACOES GERAIS
    $ACK_ALARME="110";
    $SNR_ALARME="28";
    $ARQUIVO="sinal.txt";
    $FTP_HOST="ip aki";
    $FTP_USER="login";
    $FTP_PASS="senhaki";
    $NOMEAP="mikrotik";
    $PAGINA="teste_soares.html";
    $PASTAFILES="/var/www/htdocs/apteste/";
    $PASTAPAGINA="/var/www/htdocs/apteste/";
    //cd $PASTAFILES
    //ZERA ARQUIVOS
    //O QUE VC QUER FAZER AQUI NESTES ECHO? LIMPAR?
    echo > $PAGINA
    echo > $PAGINAFILES/$PAGINA
    echo > $PASTAPAGINA/$PAGINA
     
    //ROTINA FTP DE DOWNLOAD DO  ARQUIVO (SINAL.TX) DO MIKROTIK
    //cd $PASTAFILES
    ftp -in $FTP_HOST << fim
                       user $FTP_USER $FTP_PASS
                       get $ARQUIVO
                       bye
                       EOF
    fim
     
    //ROTINA DE TRATAMENTO DO ARQUIVO PRA GERACAO DO HTML
    cat sinal.txt | fmt -w 1 | grep mac-address > mac
    cat sinal.txt | fmt -w 1 | grep interface > interface
    cat sinal.txt | fmt -w 1 | grep tx-rate > sinaltx
    cat sinal.txt | fmt -w 1 | grep rx-rate > sinalrx
    cat sinal.txt | fmt -w 1 | grep uptime > sinaluptime
    cat sinal.txt | fmt -w 1 | grep last-activity > sinallast
    cat sinal.txt | fmt -w 1 | grep signal-strength | grep -v tx-signal > sinalstrength
    cat sinal.txt | fmt -w 1 | grep signal-to-noise > sinalnoise
    cat sinal.txt | fmt -w 1 | grep tx-ccq > sinaltxccq
    cat sinal.txt | fmt -w 1 | grep p-throughput > sinaltrough
    cat sinal.txt | fmt -w 1 | grep ack-timeout > sinalack
    cat sinal.txt | fmt -w 1 | grep distance > sinaldistance
    cat sinal.txt | fmt -w 1 | grep last-ip > ipadress
     
     
    paste sinalstrength mac sinalrx sinaltx sinalnoise sinaltxccq sinaltrough sinalack sinaldistance sinaluptime interface ipadres
    s> sinal2.txt
     
    cat sinal2.txt | sed -e 's/rx-rate/ /g' | sed -e 's/mac-address/ /g' | sed -e 's/tx-rate/ /g' | sed -e 's/uptime/ /g' | sed -e
     's/signal-strength/ /g' | sed -e 's/signal-to-noise/ /g' | sed -e 's/tx-ccq/ /g' | sed -e 's/ack-timeout/ /g' | sed -e 's/p-t
    hroughput/ /g' | sed -e 's/last-ip/ /g' | sed -e 's/distance/ /g' | sed -e 's/interface/ /g' | sort -n > sinal3.txt
    cat sinal3.txt | sed 's/[\x09]//g' | sed 's/ //g' | sed 's/  /=/g' > sinal4.txt
    cat sinal4.txt | sed 's/===/=/g' > sinal5.txt
    #cat sinal5.txt | grep tx-ccq > sinal6.txt
     
    TOTAL=`cat $PASTAFILES/sinal4.txt | wc -l`
     
     
     
    #ROTINA DE ORGANIZACAO DOS DADOS
    for i in `cat $PASTAFILES/sinal5.txt`; do
     IP=`echo $i | cut -d "=" -f13`
     MAC=`echo $i | cut -d "=" -f3`
     INTERFACE=`echo $i | cut -d "=" -f12`
     TX=`echo $i | cut -d "=" -f5`
     RX=`echo $i | cut -d "=" -f4`
     THROUGPUT=`echo $i | cut -d "=" -f8`
     UPTIME=`echo $i | cut -d "=" -f11`
     ACK=`echo $i | cut -d "=" -f9`
     TXCCQ=`echo $i | cut -d "=" -f7`
     SNR=`echo $i | cut -d "=" -f6 | sed 's/dB//g'`
     SINAL=`echo $i | cut -d "=" -f2`
     SNRGRAFICO=`expr $SNR \* 5`
     
    #ROTINA DE VERIFICACAO DE SNR E ACK PARA ALARME VISUAL
     
    if [ $SNR -lt $SNR_ALARME ]
     then
        GRAFICO='pixelvermelho.png'
     else
        GRAFICO='pixelverde.png'
     fi
     
    if [ $ACK -gt $ACK_ALARME ]
     then
        GRAFICO2='pixelvermelho.png'
     else
        GRAFICO2='pixelverde.png'
     fi
    ?>
    //#ROTINA DE INSERCAO DE DADOS NO HTML
    echo \ "  <tr>" >> $PAGINA
    echo \ "    <td><span class='style1'>"$IP"</span></td>" 
    echo \ "    <td><span class='style1'>"$MAC"</span></td>" 
    echo \ "    <td><span class='style1'>"$INTERFACE"</span></td>" 
    echo \ "    <td><span class='style1'>"$TX"</span></td>"
    echo \ "    <td><span class='style1'>"$RX"</span></td>" 
    echo \ "    <td><span class='style1'>"$THROUGPUT"</span></td>" A
    echo \ "    <td><span class='style1'>"$UPTIME"</span></td>" 
    echo \ " <td><span class='style1'>"$ACK "<img src='"$GRAFICO2"' height='10px' width='10'></span></td> " 
    echo \ "    <td><span class='style1'>"$TXCCQ"</span></td>" 
    echo \ "    <td><span class='style1'>"$SNR"</td> " >> $PAGINA
    echo \ " <td><span class='style1'><img src='"$GRAFICO"' height='10px' width='"$SNRGRAFICO"'>$SINAL</td>" 
    echo \ "  </tr>" 
     
     
    done

    obrigado perigosso pela ajuda...

    esse script pega um arquivo (sinal.txt) via FTP no mikrotik,

    # sinal.txt
    ##################################
    0 interface=Enlace_flores radio-name="arena" mac-address=00:15:6D:B6:2F:C6
    ap=no wds=yes rx-rate=18Mbps tx-rate=48Mbps packets=8201476,3447629
    bytes=2862633161,518664084 frames=8201476,3447629
    frame-bytes=2814247655,497978310 hw-frames=8201499,3595590
    hw-frame-bytes=3011110945,587548803 uptime=1w22h58m14s last-activity=0s
    signal-strength=-60dBm@18Mbps signal-to-noise=35dB
    strength-at-rates=-55dBm@6Mbps 2s180ms,-53dBm@12Mbps 14s550ms,-60dBm@18Mbps
    40ms,-53dBm@24Mbps 7s290ms,-52dBm@36Mbps 4s170ms,-
    62dBm@48Mbps 470ms,-62dBm@54Mbps 140ms
    tx-ccq=88% p-throughput=37008 ack-timeout=28 distance=28 nstreme=no
    framing-mode=none routeros-version="2.9.31" last-ip=10.110.193.2
    802.1x-port-enabled=yes authentication-type=none encryption=none
    compression=no
    ###################################

    Faz um filtro e organiza só o que eu quero.

    #sinal5.txt
    ###################################
    =-42dBm@11Mbps=00:12:0E:B2:EE:34=11Mbps=11Mbps=52dB=100%=8208=30=30=1w22h57m20s=flores2.4=10.110.193.2

    ##################################

    #jaga para web (apache) teste.soares.html

    #O topico completo se encontra aqui. Mas, esse acima citado, foi feitos uns ajustes.

    https://under-linux.org/f113071-scri...ecisar-de-snmp

  4. ja ta instalado o modulo php no seu apache?



  5. Citação Postado originalmente por Pirigoso Ver Post
    ja ta instalado o modulo php no seu apache?
    Temos um sistema funcionado e em php.

    Queremos colocar um pagina para o suporte saber com está o sinal do cliente, se estiver em "vermelho" nao=aprovado, verde=aprovado.






Tópicos Similares

  1. Ajuda para passar Site por fora do proxy
    Por Pedroh no fórum Redes
    Respostas: 3
    Último Post: 30-10-2014, 13:22
  2. Ajuda- Regra para passar fora do Cache
    Por Pedroh no fórum Redes
    Respostas: 1
    Último Post: 21-10-2013, 16:44
  3. Ajuda com script para travar programa
    Por gamefe no fórum Linguagens de Programação
    Respostas: 1
    Último Post: 10-02-2005, 16:13
  4. Respostas: 0
    Último Post: 16-10-2003, 08:08
  5. Respostas: 0
    Último Post: 16-10-2003, 08:08

Visite: BR-Linux ·  VivaOLinux ·  Dicas-L