<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Daviramos,<br>
    <br>
    Segue o c&oacute;digo:<br>
    <br>
    <br>
    <b>&lt;?php</b><b><br>
    </b><b>exec('sudo /usr/sbin/asterisk -rx "sip show peers"',
      $result);</b><b><br>
    </b><b><br>
    </b><b>$count = count($result);</b><b><br>
    </b><b><br>
    </b><b>for ($x = 0; $x &lt; $count -1; ++$x) {</b><b><br>
    </b><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo
      "&lt;pre&gt;".$result[$x]."&lt;/pre&gt;";</b><b><br>
    </b><b>}</b><b><br>
    </b><b><br>
    </b><b>?&gt;</b><br>
    <br>
    No caso exclui a &uacute;ltima linha e com o "&lt;pre&gt;" tenho a mesma
    saida do cli, mas pra jogar em uma tabela para dar um tratamento
    melhor realmente n&atilde;o to conseguindo. Se tiver alguma dica agrade&ccedil;o.<br>
    <br>
    Valeu,<br>
    Patrick<br>
    <br>
    <div class="moz-cite-prefix">Em 01-11-2012 17:12, Daviramos Roussenq
      Fortunato escreveu:<br>
    </div>
    <blockquote
cite="mid:CABFgOvoVvDFmH4qBDu0z58bgROGqA_q=4OB21UpCBUF1a3mhzw@mail.gmail.com"
      type="cite">Patrick,&nbsp;
      <div><br>
      </div>
      <div>&nbsp; Posso ajudar sim, mas mandei o e-mail direto para Lista
        para Ficar documentado.</div>
      <div><br>
      </div>
      <div>&nbsp; Mande o seu&nbsp;c&oacute;digo&nbsp;para que possamos opinar
        sobre&nbsp;poss&iacute;veis&nbsp;solu&ccedil;&otilde;es.<br>
        <br>
        <div class="gmail_quote">
          Em 1 de novembro de 2012 13:16, Patrick EL Youssef <span
            dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:wushumasters@gmail.com" target="_blank">wushumasters@gmail.com</a>&gt;</span>
          escreveu:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"> Daviramos,<br>
              <br>
              Consegue me ajudar com isso se n&atilde;o for pedir.<br>
              <br>
              Seu c&oacute;digo eu mudei um pouco e consegui a sa&iacute;da que queria
              por&eacute;m queria jogar para uma tabela, pensei em usar o
              explode mas alguns campos n&atilde;o s&atilde;o preenchidos dos peers
              como por exemplo ACL, ai pensei aqui e n&atilde;o achei um jeito
              de resolver.<br>
              <br>
              Voc&ecirc; chegou a fazer isso?<br>
              <br>
              Valeu,<br>
              Patrick<br>
              <div>Em 01-11-2012 10:24, Daviramos Roussenq Fortunato
                escreveu:<br>
              </div>
              <blockquote type="cite">Patrick,
                <div><br>
                </div>
                <div>&nbsp; De uma olhada em&nbsp;<a moz-do-not-send="true"
href="http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+SIPpeers"
                    target="_blank">http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+SIPpeers</a></div>
                <div><br>
                </div>
                <div>&nbsp; Eu quando uso comando direto como est&aacute; fazendo:
                  sip show peers, eu n&atilde;o uso o MANAGER, uso direto do
                  console mesmo, segue exemplo:</div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>&lt;?</div>
                <div>
                  <div>exec('/usr/sbin/asterisk -rx "sip show peers"',
                    $result);</div>
                  <div>reset($result);</div>
                  <div>while (key($result) !== null) {</div>
                </div>
                <div>&nbsp; printf("%s-%s",key($result),current($result));</div>
                <div>&nbsp; next($result);</div>
                <div>}</div>
                <div><br>
                </div>
                <div>?&gt;</div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div><br>
                  <div class="gmail_quote">Em 1 de novembro de 2012
                    10:14, Sylvio Jollenbeck <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:sylvio.jollenbeck@gmail.com"
                        target="_blank">sylvio.jollenbeck@gmail.com</a>&gt;</span>
                    escreveu:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">Patrick,<br>
                      <br>
                      Dentro do while, use a fun&ccedil;&atilde;o strpos do php.<br>
                      <br>
                      Abs<br>
                      <br>
                      Sylvio Jollenbeck<br>
                      <br>
                      <div class="gmail_quote">
                        <div>
                          <div>2012/11/1 Patrick EL Youssef <span
                              dir="ltr">&lt;<a moz-do-not-send="true"
                                href="mailto:wushumasters@gmail.com"
                                target="_blank">wushumasters@gmail.com</a>&gt;</span><br>
                          </div>
                        </div>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div>
                            <div>
                              <div text="#000000" bgcolor="#FFFFFF">
                                Pessoal,<br>
                                <br>
                                Quem mexe bem com o manager e puder me
                                ajudar. Estou executando comando "sip
                                show peers" via php por&eacute;m ele me retorna
                                sempre as mensagens do proprio manager
                                junto do comando:<br>
                                <br>
                                <span>Asterisk Call Manager/1.2<span>&nbsp;</span></span><br>
                                <span>Response: Success<span>&nbsp;</span></span><br>
                                <span>Message: Authentication accepted<span>&nbsp;</span></span><br>
                                <br>
                                <span>Event: FullyBooted<span>&nbsp;</span></span><br>
                                <span>Privilege: system,all<span>&nbsp;</span></span><br>
                                <span>Status: Fully Booted<span>&nbsp;</span></span><br>
                                <br>
                                <span>Response: Follows<span>&nbsp;</span></span><br>
                                <span>Privilege: Command<span>&nbsp;</span></span><br>
                                <span>Name/username Host Dyn Forcerport
                                  ACL Port Status Description Realtime<span>&nbsp;</span></span><br>
                                <span>2000/2000 (Unspecified) D N A 0
                                  UNKNOWN<span>&nbsp;</span></span><br>
                                <span>2001/2001 <a
                                    moz-do-not-send="true"
                                    href="tel:192.168.1.131"
                                    value="+551921681131"
                                    target="_blank">192.168.1.131</a> D
                                  N 5060 UNREACHABLE<span>&nbsp;</span></span><br>
                                <span>2</span><span> sip peers
                                  [Monitored: 0 online, 2 offline
                                  Unmonitored: 0 online, 0 offline]<span>&nbsp;</span></span><br>
                                <span>--END COMMAND--<span>&nbsp;</span></span><br>
                                <br>
                                <span>Response: Goodbye<span>&nbsp;</span></span><br>
                                <span>Message: Thanks for all the fish.<span>
                                  </span></span><br>
                                <br>
                                Tem como eu s&oacute; pegar a sa&iacute;da do comando
                                mesmo. Meu c&oacute;digo php &eacute; esse:<br>
                                <br>
                                $socket = fsockopen("127.0.0.1","5038",
                                $errno, $errstr, 10);<br>
                                &nbsp;&nbsp;&nbsp; if (!$socket) {<br>
                                &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo "$errstr ($errno)\n";<br>
                                &nbsp;&nbsp;&nbsp; } else {<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket, "Action:
                                Login\r\n");<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket,
                                "UserName: usuario\r\n");<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket, "Secret:
                                senha\r\n\r\n");<br>
                                <br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket, "Action:
                                Command\r\n");<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket, "Command:
                                sip show peers\r\n\r\n");<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fputs($socket, "Action:
                                Logoff\r\n\r\n");<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                                &nbsp;&nbsp;&nbsp; while (!feof($socket)) {<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo
                                fgets($socket),'&lt;br&gt;';<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                                &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fclose($socket);<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
                                <br>
                                Obrigado,<br>
                                Patrick<br>
                              </div>
                              <br>
                            </div>
                          </div>
_______________________________________________<br>
                          KHOMP Inova&ccedil;&atilde;o: External Board Series<br>
                          M&oacute;dulos de 1/2 rack e 1U para todas as
                          interfaces e solu&ccedil;&otilde;es Asterisk e FreeSWITCH.<br>
                          Tenha a External Series Experience na sua
                          aplica&ccedil;&atilde;o. Visite <a moz-do-not-send="true"
                            href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
_______________________________________________<br>
                          DIGIVOICE &nbsp;Fabricante de Placas de Voz e
                          Channel Bank<br>
                          20 anos de experi&ecirc;ncia com E1(R2/ISDN), FXS,
                          FXO e GSM<br>
                          Centro Treinamento - Curso de PABX IP -
                          &nbsp;Asterisk &nbsp;- Site &nbsp;<a moz-do-not-send="true"
                            href="http://www.digivoice.com.br"
                            target="_blank">www.digivoice.com.br</a><br>
                          ________<br>
                          YEALINK: Telefones IP e V&iacute;deoPhones IP com o
                          melhor custo/benef&iacute;cio do mercado.<br>
                          email: <a moz-do-not-send="true"
                            href="mailto:yealink@commlogik.com.br"
                            target="_blank">yealink@commlogik.com.br</a>
                          | <a moz-do-not-send="true"
                            href="http://www.commlogik.com.br"
                            target="_blank">www.commlogik.com.br</a> | <a
                            moz-do-not-send="true"
                            href="tel:%2811%29%205503-1011"
                            value="+551155031011" target="_blank">(11)
                            5503-1011</a><br>
                          ______________________________________________<br>
                          Para remover seu email desta lista, basta
                          enviar um email em branco para <a
                            moz-do-not-send="true"
                            href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org"
                            target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
                        </blockquote>
                      </div>
                      <br>
                      <br>
                      _______________________________________________<br>
                      KHOMP Inova&ccedil;&atilde;o: External Board Series<br>
                      M&oacute;dulos de 1/2 rack e 1U para todas as interfaces
                      e solu&ccedil;&otilde;es Asterisk e FreeSWITCH.<br>
                      Tenha a External Series Experience na sua
                      aplica&ccedil;&atilde;o. Visite <a moz-do-not-send="true"
                        href="http://www.khomp.com" target="_blank">www.khomp.com</a><br>
                      _______________________________________________<br>
                      DIGIVOICE &nbsp;Fabricante de Placas de Voz e Channel
                      Bank<br>
                      20 anos de experi&ecirc;ncia com E1(R2/ISDN), FXS, FXO e
                      GSM<br>
                      Centro Treinamento - Curso de PABX IP - &nbsp;Asterisk
                      &nbsp;- Site &nbsp;<a moz-do-not-send="true"
                        href="http://www.digivoice.com.br"
                        target="_blank">www.digivoice.com.br</a><br>
                      ________<br>
                      YEALINK: Telefones IP e V&iacute;deoPhones IP com o
                      melhor custo/benef&iacute;cio do mercado.<br>
                      email: <a moz-do-not-send="true"
                        href="mailto:yealink@commlogik.com.br"
                        target="_blank">yealink@commlogik.com.br</a> | <a
                        moz-do-not-send="true"
                        href="http://www.commlogik.com.br"
                        target="_blank">www.commlogik.com.br</a> | <a
                        moz-do-not-send="true"
                        href="tel:%2811%29%205503-1011"
                        value="+551155031011" target="_blank">(11)
                        5503-1011</a><br>
                      ______________________________________________<br>
                      Para remover seu email desta lista, basta enviar
                      um email em branco para <a moz-do-not-send="true"
href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org"
                        target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a><br>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  Atenciosamente<br>
                  Daviramos Roussenq Fortunato<br>
                </div>
                <br>
                <fieldset></fieldset>
                <br>
                <pre>_______________________________________________
KHOMP Inova&ccedil;&atilde;o: External Board Series
M&oacute;dulos de 1/2 rack e 1U para todas as interfaces e solu&ccedil;&otilde;es Asterisk e FreeSWITCH.
Tenha a External Series Experience na sua aplica&ccedil;&atilde;o. Visite <a moz-do-not-send="true" href="http://www.khomp.com" target="_blank">www.khomp.com</a>
_______________________________________________
DIGIVOICE  Fabricante de Placas de Voz e Channel Bank
20 anos de experi&ecirc;ncia com E1(R2/ISDN), FXS, FXO e GSM
Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  <a moz-do-not-send="true" href="http://www.digivoice.com.br" target="_blank">www.digivoice.com.br</a>
________
YEALINK: Telefones IP e V&iacute;deoPhones IP com o melhor custo/benef&iacute;cio do mercado.
email: <a moz-do-not-send="true" href="mailto:yealink@commlogik.com.br" target="_blank">yealink@commlogik.com.br</a> | <a moz-do-not-send="true" href="http://www.commlogik.com.br" target="_blank">www.commlogik.com.br</a> | <a moz-do-not-send="true" href="tel:%2811%29%205503-1011" value="+551155031011" target="_blank">(11) 5503-1011</a>
______________________________________________
Para remover seu email desta lista, basta enviar um email em branco para <a moz-do-not-send="true" href="mailto:asteriskbrasil-unsubscribe@listas.asteriskbrasil.org" target="_blank">asteriskbrasil-unsubscribe@listas.asteriskbrasil.org</a></pre>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        Atenciosamente<br>
        Daviramos Roussenq Fortunato<br>
      </div>
    </blockquote>
    <br>
  </body>
</html>