+ Responder ao Tópico



  1. #1

    Padrão ajuda para passar para PHP?

    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. #2

    Padrão

    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 13:20.



  3. #3

    Padrão

    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
    [email protected] signal-to-noise=35dB
    [email protected] 2s180ms,[email protected] 14s550ms,[email protected]
    40ms,[email protected] 7s290ms,[email protected] 4s170ms,-
    [email protected] 470ms,[email protected] 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
    ###################################
    [email protected]=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. #4

    Padrão

    ja ta instalado o modulo php no seu apache?



  5. #5

    Padrão

    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.