Commit 95e8362da1f66e714ed434e065e9690bc7a80e5e
1 parent
06531db0
Exists in
master
and in
1 other branch
Indicador 28 - Enviando quantidade de erro por semana
Showing
3 changed files
with
624 additions
and
627 deletions
Show diff stats
rn/MdEstatisticasAgendamentoRN.php
| 1 | 1 | <? |
| 2 | -require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 2 | +require_once dirname(__FILE__) . '/../../../SEI.php'; | |
| 3 | 3 | |
| 4 | +class MdEstatisticasAgendamentoRN extends InfraRN | |
| 5 | +{ | |
| 4 | 6 | |
| 5 | -class MdEstatisticasAgendamentoRN extends InfraRN { | |
| 7 | + protected function inicializarObjInfraIBanco() { | |
| 8 | + return BancoSEI::getInstance(); | |
| 9 | + } | |
| 6 | 10 | |
| 7 | - protected function inicializarObjInfraIBanco(){ | |
| 8 | - return BancoSEI::getInstance(); | |
| 9 | - } | |
| 11 | + public function coletarIndicadores() { | |
| 12 | + InfraDebug::getInstance()->setBolLigado(true); | |
| 13 | + InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 14 | + InfraDebug::getInstance()->setBolEcho(false); | |
| 15 | + InfraDebug::getInstance()->limpar(); | |
| 10 | 16 | |
| 11 | - public function coletarIndicadores() { | |
| 17 | + try { | |
| 18 | + $coletor = new MdEstatisticasColetarRN(); | |
| 19 | + $indicadores = $coletor->coletarIndicadores(); | |
| 20 | + InfraDebug::getInstance()->gravar('JSON: ' . json_encode($indicadores), InfraLog::$INFORMACAO); | |
| 12 | 21 | |
| 13 | - InfraDebug::getInstance()->setBolLigado(true); | |
| 14 | - InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 15 | - InfraDebug::getInstance()->setBolEcho(false); | |
| 16 | - InfraDebug::getInstance()->limpar(); | |
| 22 | + $enviar = new MdEstatisticasEnviarRN(); | |
| 17 | 23 | |
| 18 | - try { | |
| 19 | - $coletor = new MdEstatisticasColetarRN(); | |
| 20 | - $indicadores = $coletor->coletarIndicadores(); | |
| 21 | - InfraDebug::getInstance()->gravar('JSON: ' . json_encode($indicadores), InfraLog::$INFORMACAO); | |
| 24 | + $saida = $enviar->enviarIndicadores($indicadores); | |
| 25 | + InfraDebug::getInstance()->gravar('Retorno: ' . json_encode($saida), InfraLog::$INFORMACAO); | |
| 22 | 26 | |
| 23 | - $enviar = new MdEstatisticasEnviarRN(); | |
| 27 | + $id = $saida['id']; | |
| 24 | 28 | |
| 25 | - $saida = $enviar->enviarIndicadores($indicadores); | |
| 26 | - InfraDebug::getInstance()->gravar('Retorno: ' . json_encode($saida), InfraLog::$INFORMACAO); | |
| 29 | + if ($id) { | |
| 30 | + $data = $enviar->obterUltimoAcesso(); | |
| 31 | + InfraDebug::getInstance()->gravar('Data: ' . $data, InfraLog::$INFORMACAO); | |
| 27 | 32 | |
| 28 | - $id = $saida['id']; | |
| 33 | + $acessos = $coletor->obterAcessosUsuarios($data); | |
| 34 | + $enviar->enviarAcessos($acessos, $id); | |
| 29 | 35 | |
| 30 | - $data = $enviar->obterUltimoAcesso(); | |
| 31 | - InfraDebug::getInstance()->gravar('Data: ' . $data, InfraLog::$INFORMACAO); | |
| 36 | + $velocidades = $coletor->obterVelocidadePorCidade(); | |
| 37 | + $enviar->enviarVelocidades($velocidades, $id); | |
| 32 | 38 | |
| 33 | - $acessos = $coletor->obterAcessosUsuarios($data); | |
| 34 | - $enviar->enviarAcessos($acessos, $id); | |
| 35 | - | |
| 36 | - $velocidades = $coletor->obterVelocidadePorCidade(); | |
| 37 | - $enviar->enviarVelocidades($velocidades, $id); | |
| 38 | - | |
| 39 | - $sistemasOperacionaisUsuarios = $coletor->obterSistemasOperacionaisUsuarios(); | |
| 40 | - $enviar->enviarSistemasUsuarios($sistemasOperacionaisUsuarios, $id); | |
| 41 | - | |
| 42 | - $navegadores = $coletor->obterNavegadores(); | |
| 43 | - $enviar->enviarNavegadores($navegadores, $id); | |
| 39 | + $sistemasOperacionaisUsuarios = $coletor->obterSistemasOperacionaisUsuarios(); | |
| 40 | + $enviar->enviarSistemasUsuarios($sistemasOperacionaisUsuarios, $id); | |
| 44 | 41 | |
| 45 | - LogSEI::getInstance()->gravar(InfraDebug::getInstance()->getStrDebug(),InfraLog::$INFORMACAO); | |
| 42 | + $navegadores = $coletor->obterNavegadores(); | |
| 43 | + $enviar->enviarNavegadores($navegadores, $id); | |
| 46 | 44 | |
| 47 | - } catch(Exception $e) { | |
| 48 | - InfraDebug::getInstance()->setBolLigado(false); | |
| 49 | - InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 50 | - InfraDebug::getInstance()->setBolEcho(false); | |
| 51 | - throw new InfraException('Erro processando estatísticas do sistema.',$e); | |
| 52 | - } | |
| 53 | - } | |
| 45 | + $logs = $coletor->obterQuantidadeLogErro(); | |
| 46 | + $enviar->enviarLogsErro($logs, $id); | |
| 47 | + } | |
| 54 | 48 | |
| 49 | + LogSEI::getInstance()->gravar(InfraDebug::getInstance()->getStrDebug(), InfraLog::$INFORMACAO); | |
| 50 | + } catch (Exception $e) { | |
| 51 | + InfraDebug::getInstance()->setBolLigado(false); | |
| 52 | + InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 53 | + InfraDebug::getInstance()->setBolEcho(false); | |
| 54 | + throw new InfraException('Erro processando estatísticas do sistema.', $e); | |
| 55 | + } | |
| 56 | + } | |
| 55 | 57 | } |
| 56 | 58 | ?> | ... | ... |
rn/MdEstatisticasColetarRN.php
| 1 | 1 | <? |
| 2 | -require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | - | |
| 4 | - | |
| 5 | -class MdEstatisticasColetarRN extends InfraRN { | |
| 6 | - | |
| 7 | - public function __construct(){ | |
| 8 | - parent::__construct(); | |
| 9 | - } | |
| 10 | - | |
| 11 | - protected function inicializarObjInfraIBanco(){ | |
| 12 | - return BancoSEI::getInstance(); | |
| 13 | - } | |
| 14 | - | |
| 15 | - public function coletarIndicadores() { | |
| 16 | - | |
| 17 | - try { | |
| 18 | - | |
| 19 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 20 | - $orgaoSigla = $objConfiguracaoSEI->getValor('MdEstatisticas','sigla', false, ''); | |
| 21 | - | |
| 22 | - $ind = array(); | |
| 23 | - | |
| 24 | - $ind['dataColeta'] = $this->obterDataColeta(); | |
| 25 | - $ind['orgaoSigla'] = $orgaoSigla; | |
| 26 | - $ind['seiVersao'] = $this->obterVersaoSEI(); | |
| 27 | - $ind['phpVersao'] = $this->obterVersaoPHP(); | |
| 28 | - $ind['memcachedVersao'] = $this->obterVersaoMemcached(); | |
| 29 | - $ind['solrVersao'] = $this->obterVersaoSolr(); | |
| 30 | - $ind['protocolo'] = $this->obterProtocolo(); | |
| 31 | - $ind['quantidadeUnidades'] = $this->obterQuantidadeUnidades(); | |
| 32 | - $ind['quantidadeProcedimentos'] = $this->obterQuantidadeProcessosAdministrativos(); | |
| 33 | - $ind['quantidadeUsuarios'] = $this->obterQuantidadeUsuarios(); | |
| 34 | - $ind['quantidadeDocumentosInternos'] = $this->obterQuantidadeDocumentosInternos(); | |
| 35 | - $ind['quantidadeDocumentosExternos'] = $this->obterQuantidadeDocumentosExternos(); | |
| 36 | - $ind['quantidadeMemoria'] = $this->obterUsoMemoria(); | |
| 37 | - $ind['porcentagemCPU'] = $this->obterUsoCPU(); | |
| 38 | - $ind['espacoDiscoUsado'] = $this->obterEspacoDisco(); | |
| 39 | - $ind['estrategiaCessao'] = $this->obterEstrategiaCessao(); | |
| 40 | - $ind['tamanhoDatabase'] = $this->obterTamanhoDataBase(); | |
| 41 | - $ind['bancoSei'] = $this->obterTipoSGBD(); | |
| 42 | - $ind['bancoVersao'] = $this->obterBancoVersao(); | |
| 43 | - $ind['servidorAplicacao'] = $this->obterServidorAplicacao(); | |
| 44 | - $ind['sistemaOperacional'] = $this->obterSistemaOperacional(); | |
| 45 | - $ind['sistemaOperacionalDetalhado'] = $this->obterSistemaOperacionalDetalhado(); | |
| 46 | - $ind['tamanhoFilesystem'] = $this->obterTamanhoFileSystem(); | |
| 47 | - $ind['tabelasTamanhos'] = $this->obterTamanhoTabelas(); | |
| 48 | - $ind['modulos'] = $this->obterPlugins(); | |
| 49 | - $ind['extensoes'] = $this->obterQuantidadeDocumentosExternosPorExtensao(); | |
| 50 | - $ind['anexosTamanhos'] = $this->obterTamanhoDocumentosExternos(); | |
| 51 | - | |
| 52 | - InfraDebug::getInstance()->gravar('Ind: ' . json_encode($ind), InfraLog::$INFORMACAO); | |
| 53 | - | |
| 54 | - return $ind; | |
| 55 | - | |
| 56 | - } catch(Exception $e) { | |
| 57 | - InfraDebug::getInstance()->setBolLigado(false); | |
| 58 | - InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 59 | - InfraDebug::getInstance()->setBolEcho(false); | |
| 60 | - throw new InfraException('Erro processando estatísticas do sistema.',$e); | |
| 61 | - } | |
| 62 | - } | |
| 63 | - | |
| 64 | - private function obterVersaoSEI(){ | |
| 65 | - InfraDebug::getInstance()->gravar('SEI01 - Versão SEI: ' . SEI_VERSAO, InfraLog::$INFORMACAO); | |
| 66 | - return SEI_VERSAO; | |
| 67 | - } | |
| 68 | - | |
| 69 | - private function obterVersaoPHP(){ | |
| 70 | - InfraDebug::getInstance()->gravar('SEI21 - Versão PHP: ' . phpversion(), InfraLog::$INFORMACAO); | |
| 71 | - return phpversion(); | |
| 72 | - } | |
| 73 | - | |
| 74 | - private function getDirectorySize($path){ | |
| 75 | - $bytestotal = 0; | |
| 76 | - $path = realpath($path); | |
| 77 | - if($path!==false){ | |
| 78 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object){ | |
| 79 | - $bytestotal += $object->getSize(); | |
| 80 | - } | |
| 81 | - } | |
| 82 | - return $bytestotal; | |
| 83 | - } | |
| 84 | - | |
| 85 | - private function obterTamanhoFileSystem(){ | |
| 86 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 87 | - if ($objConfiguracaoSEI->isSetValor('SEI', 'RepositorioArquivos')){ | |
| 88 | - $diretorio = $objConfiguracaoSEI->getValor('SEI','RepositorioArquivos'); | |
| 89 | - $tamanho = $this->getDirectorySize($diretorio); | |
| 90 | - | |
| 91 | - InfraDebug::getInstance()->gravar('SEI02 - Diretorio: ' . $diretorio, InfraLog::$INFORMACAO); | |
| 92 | - InfraDebug::getInstance()->gravar('SEI02 - Tamanho File System: ' . $tamanho, InfraLog::$INFORMACAO); | |
| 93 | - } | |
| 94 | - return $tamanho; | |
| 95 | - } | |
| 96 | - | |
| 97 | - private function obterPlugins(){ | |
| 98 | - global $SEI_MODULOS; | |
| 99 | - $lista = array(); | |
| 100 | - foreach($SEI_MODULOS as $strModulo => $seiModulo){ | |
| 101 | - $result = array( | |
| 102 | - 'nome' => $strModulo, | |
| 103 | - 'versao' => $seiModulo->getVersao() | |
| 104 | - ); | |
| 105 | - array_push($lista, $result); | |
| 106 | - } | |
| 107 | - | |
| 108 | - InfraDebug::getInstance()->gravar('SEI03 - Plugins: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 109 | - return $lista; | |
| 110 | - } | |
| 111 | - | |
| 112 | - private function obterQuantidadeUnidades(){ | |
| 113 | - | |
| 114 | - $objUnidadeRN = new UnidadeRN(); | |
| 115 | - $numQuantidadeUnidades = $objUnidadeRN->contarRN0128(new UnidadeDTO()); | |
| 116 | - | |
| 117 | - InfraDebug::getInstance()->gravar('SEI11 - Quantidade Unidades: ' . $numQuantidadeUnidades, InfraLog::$INFORMACAO); | |
| 118 | - return $numQuantidadeUnidades; | |
| 119 | - } | |
| 120 | - | |
| 121 | - private function obterTamanhoTotalDocumentosExternos(){ | |
| 122 | - | |
| 123 | - $query = "select sum(tamanho) as tamanho from anexo where sin_ativo = 'S'"; | |
| 124 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 125 | - $tamanho = (count($rs) && isset($rs[0]['tamanho'])) ? $rs[0]['tamanho'] : 0; | |
| 126 | - | |
| 127 | - InfraDebug::getInstance()->gravar('SEI12 - Tamanho Documentos Externos: ' . $tamanho, InfraLog::$INFORMACAO); | |
| 128 | - return $tamanho; | |
| 129 | - } | |
| 130 | - | |
| 131 | - private function obterQuantidadeUsuarios(){ | |
| 132 | - | |
| 133 | - $query = "SELECT COUNT(*) as quantidade FROM usuario WHERE sin_ativo = 'S'"; | |
| 134 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 135 | - $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 136 | - | |
| 137 | - InfraDebug::getInstance()->gravar('SEI09 - Quantidade de usuários: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 138 | - return $quantidade; | |
| 139 | - } | |
| 140 | - | |
| 141 | - private function obterProtocolo(){ | |
| 142 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 143 | - if ($objConfiguracaoSEI->isSetValor('SessaoSEI', 'https')){ | |
| 144 | - $temHTTPS = $objConfiguracaoSEI->getValor('SessaoSEI', 'https'); | |
| 145 | - $protocolo = 'HTTP'; | |
| 146 | - if ($temHTTPS) { | |
| 147 | - $protocolo = 'HTTPS'; | |
| 148 | - } | |
| 149 | - InfraDebug::getInstance()->gravar('SEI12 - Protocolo: ' . $protocolo, InfraLog::$INFORMACAO); | |
| 150 | - return $protocolo; | |
| 151 | - } | |
| 152 | - } | |
| 153 | - | |
| 154 | - private function obterQuantidadeProcessosAdministrativos(){ | |
| 155 | - $query = "select count(*) as quantidade from procedimento"; | |
| 156 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 157 | - $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 158 | - | |
| 159 | - InfraDebug::getInstance()->gravar('SEI06 - Quantidade de Processos Administrativos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 160 | - return $quantidade; | |
| 161 | - } | |
| 162 | - | |
| 163 | - private function obterTipoSGBD(){ | |
| 164 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 165 | - $sgbd = $objConfiguracaoSEI->getValor('BancoSEI','Tipo', false, ''); | |
| 166 | - InfraDebug::getInstance()->gravar('SEI02 - SGBD: ' . $sgbd, InfraLog::$INFORMACAO); | |
| 167 | - return $sgbd; | |
| 168 | - } | |
| 169 | - | |
| 170 | - private function obterQuantidadeDocumentosInternos(){ | |
| 171 | - $query = "SELECT COUNT(*) as quantidade FROM documento WHERE STA_DOCUMENTO = 'I'"; | |
| 172 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 173 | - $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 174 | - | |
| 175 | - InfraDebug::getInstance()->gravar('SEI05 - Quantidade de documentos internos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 176 | - return $quantidade; | |
| 177 | - } | |
| 178 | - | |
| 179 | - private function obterQuantidadeDocumentosExternos(){ | |
| 180 | - $query = "SELECT COUNT(*) as quantidade FROM documento WHERE STA_DOCUMENTO = 'X'"; | |
| 181 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 182 | - $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 183 | - | |
| 184 | - InfraDebug::getInstance()->gravar('SEI05 - Quantidade de documentos externos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 185 | - return $quantidade; | |
| 186 | - } | |
| 187 | - | |
| 188 | - private function obterQuantidadeDocumentosExternosPorExtensao(){ | |
| 189 | - $query = "SELECT nome FROM anexo WHERE sin_ativo = 'S'"; | |
| 190 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 191 | - $extensoes = array(); | |
| 192 | - # Calculando na aplicacao para funcionar independente do banco | |
| 193 | - foreach($rs as $r) { | |
| 194 | - $extensao =pathinfo($r['nome'], PATHINFO_EXTENSION); | |
| 195 | - $qtd = $extensoes[$extensao]; | |
| 196 | - if (!$qtd) { | |
| 197 | - $qtd = 0; | |
| 198 | - } | |
| 199 | - $extensoes[$extensao] = $qtd + 1; | |
| 200 | - } | |
| 201 | - $lista = array(); | |
| 202 | - foreach($extensoes as $key => $value) { | |
| 203 | - $result = array( | |
| 204 | - 'extensao' => $key, | |
| 205 | - 'quantidade' => $value | |
| 206 | - ); | |
| 207 | - array_push($lista, $result); | |
| 208 | - } | |
| 209 | - | |
| 210 | - InfraDebug::getInstance()->gravar('SEI07 - Quantidade de extensoes de documentos externos: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 211 | - return $lista; | |
| 212 | - } | |
| 213 | - | |
| 214 | - private function obterEstrategiaCessao(){ | |
| 215 | - InfraDebug::getInstance()->gravar('SEI24 - Estrategia de armazenamento de cessao: ' . ini_get('session.save_handler'), InfraLog::$INFORMACAO); | |
| 216 | - return ini_get('session.save_handler'); | |
| 217 | - } | |
| 218 | - | |
| 219 | - private function obterVersaoMemcached(){ | |
| 220 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 221 | - $host = $objConfiguracaoSEI->getValor('CacheSEI','Servidor', false, ''); | |
| 222 | - $porta = $objConfiguracaoSEI->getValor('CacheSEI','Porta', false, ''); | |
| 223 | - | |
| 224 | - $memcache = new Memcache; | |
| 225 | - $memcache->connect($host, $porta); | |
| 226 | - $versao = $memcache->getVersion(); | |
| 227 | - | |
| 228 | - InfraDebug::getInstance()->gravar('SEI23 - Versão memcached: ' . $versao, InfraLog::$INFORMACAO); | |
| 229 | - return $versao; | |
| 230 | - } | |
| 231 | - | |
| 232 | - private function obterTamanhoDatabase(){ | |
| 233 | - $sgbd = $this->obterTipoSGBD(); | |
| 234 | - $query = ''; | |
| 235 | - if ($sgbd == 'MySql') { | |
| 236 | - $query = "SELECT table_schema, SUM(data_length + index_length) as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei' GROUP BY table_schema"; | |
| 237 | - } elseif ($sgbd == 'SqlServer') { | |
| 238 | - $query = "SELECT SUM(Total_Pages * 8 * 1000) As tamanho FROM sys.partitions As P INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id INNER JOIN sys.tables t on t.object_id = p.object_id"; | |
| 239 | - } elseif ($sgbd == 'Oracle') { | |
| 240 | - $query = ""; | |
| 241 | - } | |
| 242 | - $rs = array(); | |
| 243 | - if($query) { | |
| 244 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 245 | - } | |
| 246 | - $tamanho = (count($rs) && isset($rs[0]['tamanho'])) ? $rs[0]['tamanho'] : 0; | |
| 247 | - | |
| 248 | - InfraDebug::getInstance()->gravar('SEI03 - Tamanho do SGBD: ' . $tamanho, InfraLog::$INFORMACAO); | |
| 249 | - return $tamanho; | |
| 250 | - } | |
| 251 | - | |
| 252 | - private function obterTamanhoTabelas(){ | |
| 253 | - $sgbd = $this->obterTipoSGBD(); | |
| 254 | - $query = ''; | |
| 255 | - if ($sgbd == 'MySql') { | |
| 256 | - $query = "SELECT table_name as tabela, data_length + index_length as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei'"; | |
| 257 | - } elseif ($sgbd == 'SqlServer') { | |
| 258 | - $query = "" . | |
| 259 | - " SELECT t.name as tabela, SUM(Total_Pages * 8 * 1000) As tamanho " . | |
| 260 | - " FROM sys.partitions As P " . | |
| 261 | - " INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id " . | |
| 262 | - " INNER JOIN sys.tables t on t.object_id = p.object_id " . | |
| 263 | - " GROUP BY t.name ORDER BY t.name"; | |
| 264 | - } elseif ($sgbd == 'Oracle') { | |
| 265 | - $query = ""; | |
| 266 | - } | |
| 267 | - $tabelas = array(); | |
| 268 | - if($query) { | |
| 269 | - $tabelas = BancoSEI::getInstance()->consultarSql($query); | |
| 270 | - } | |
| 271 | - | |
| 272 | - InfraDebug::getInstance()->gravar('SEI15 - Tamanho das tabelas: ' . json_encode($tabelas), InfraLog::$INFORMACAO); | |
| 273 | - return $tabelas; | |
| 274 | - } | |
| 275 | - | |
| 276 | - | |
| 277 | - private function obterVersaoSolr(){ | |
| 278 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 279 | - $url = $objConfiguracaoSEI->getValor('Solr','Servidor', false, 'http://localhost:8983/solr'); | |
| 280 | - $url = $url . '/admin/info/system?wt=json'; | |
| 281 | - | |
| 282 | - $ch = curl_init(); | |
| 283 | - curl_setopt($ch, CURLOPT_URL, $url); | |
| 284 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 285 | - $output = curl_exec($ch); | |
| 286 | - $json = json_decode($output, true); | |
| 287 | - $versao = $json['lucene']['lucene-spec-version']; | |
| 288 | - InfraDebug::getInstance()->gravar('SEI22 - Versao Solr: ' . $versao, InfraLog::$INFORMACAO); | |
| 289 | - return $versao; | |
| 290 | - } | |
| 291 | - | |
| 292 | - private function obterServidorAplicacao(){ | |
| 293 | - $versao = $_SERVER['SERVER_SOFTWARE']; | |
| 294 | - InfraDebug::getInstance()->gravar('SEI20 - Quantidade de servidores de aplicação e suas versões: ' . $versao, InfraLog::$INFORMACAO); | |
| 295 | - return $versao; | |
| 296 | - } | |
| 297 | - | |
| 298 | - private function obterSistemaOperacional(){ | |
| 299 | - $so = PHP_OS; | |
| 300 | - $versao = $_SERVER['SERVER_SOFTWARE']; | |
| 301 | - InfraDebug::getInstance()->gravar('SEI17 - Quantidade de Sistemas Operacionais: ' . $so, InfraLog::$INFORMACAO); | |
| 302 | - return $so; | |
| 303 | - } | |
| 304 | - | |
| 305 | - private function obterSistemaOperacionalDetalhado(){ | |
| 306 | - $so = php_uname(); | |
| 307 | - $versao = $_SERVER['SERVER_SOFTWARE']; | |
| 308 | - InfraDebug::getInstance()->gravar('SEI17 - Quantidade de Sistemas Operacionais (Detalhado): ' . $so, InfraLog::$INFORMACAO); | |
| 309 | - return $so; | |
| 310 | - } | |
| 311 | - | |
| 312 | - private function obterDataColeta(){ | |
| 313 | - $dataColeta = date (DATE_ATOM); | |
| 314 | - InfraDebug::getInstance()->gravar('SEI29 - Periodicidade do envio - Data da coleta: ' . $dataColeta, InfraLog::$INFORMACAO); | |
| 315 | - return $dataColeta; | |
| 316 | - } | |
| 317 | - | |
| 318 | - private function obterTamanhoDocumentosExternos(){ | |
| 319 | - $resultado = array(); | |
| 320 | - # 0MB - !MB | |
| 321 | - $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 0 AND tamanho < 1000"; | |
| 322 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 323 | - $resultado[0] = array( | |
| 324 | - 'tamanho' => '0MB - 1MB', | |
| 325 | - 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 326 | - ); | |
| 327 | - | |
| 328 | - # 1MB - 10MB | |
| 329 | - $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 1000 AND tamanho < 10000"; | |
| 330 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 331 | - $resultado[1] = array( | |
| 332 | - 'tamanho' => '1MB - 10MB', | |
| 333 | - 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 334 | - ); | |
| 335 | - | |
| 336 | - # 10MB - 100MB | |
| 337 | - $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 10000 AND tamanho < 100000"; | |
| 338 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 339 | - $resultado[2] = array( | |
| 340 | - 'tamanho' => '10MB - 100MB', | |
| 341 | - 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 342 | - ); | |
| 343 | - | |
| 344 | - # > 100MB | |
| 345 | - $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 100000"; | |
| 346 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 347 | - $resultado[3] = array( | |
| 348 | - 'tamanho' => 'Maior que 100MB', | |
| 349 | - 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 350 | - ); | |
| 351 | - | |
| 352 | - InfraDebug::getInstance()->gravar('SEI11 - Tamanho dos documentos externos: ' . json_encode($resultado), InfraLog::$INFORMACAO); | |
| 353 | - return $resultado; | |
| 354 | - } | |
| 355 | - | |
| 356 | - private function obterUsoMemoria(){ | |
| 357 | - $memoria = memory_get_usage(); | |
| 358 | - InfraDebug::getInstance()->gravar('SEI18 - Quantidade de byte de uso de memoria: ' . json_encode($memoria), InfraLog::$INFORMACAO); | |
| 359 | - return $memoria; | |
| 360 | - } | |
| 361 | - | |
| 362 | - private function obterUsoCPU(){ | |
| 363 | - $load = sys_getloadavg(); | |
| 364 | - $uso = null; | |
| 365 | - if ($load) { | |
| 366 | - $uso = $load[0]; | |
| 367 | - } | |
| 368 | - InfraDebug::getInstance()->gravar('SEI18 - Porcentagem de uso de CPU: ' . json_encode($uso), InfraLog::$INFORMACAO); | |
| 369 | - return $uso; | |
| 370 | - } | |
| 371 | - | |
| 372 | - private function obterEspacoDisco() { | |
| 373 | - $ds = null; | |
| 374 | - if(php_uname('s')=='Windows NT') { | |
| 375 | - $unidade = substr($_SERVER['DOCUMENT_ROOT'], 0, 2); | |
| 376 | - if (!$unidade) { | |
| 377 | - $unidade = 'C:'; | |
| 378 | - } | |
| 379 | - } else { | |
| 380 | - $unidade = "/"; | |
| 381 | - } | |
| 382 | - $total = disk_total_space($unidade); | |
| 383 | - $free = disk_free_space($unidade); | |
| 384 | - $ds = $total - $free; | |
| 385 | - InfraDebug::getInstance()->gravar('SEI18 - Espaco utilizado do disco: ' . json_encode($ds), InfraLog::$INFORMACAO); | |
| 386 | - return $ds; | |
| 387 | - } | |
| 388 | - | |
| 389 | - private function obterBancoVersao(){ | |
| 390 | - $sgbd = $this->obterTipoSGBD(); | |
| 391 | - $query = ''; | |
| 392 | - if ($sgbd == 'MySql') { | |
| 393 | - $query = "SELECT version() as versao"; | |
| 394 | - } elseif ($sgbd == 'SqlServer') { | |
| 395 | - $query = "SELECT SERVERPROPERTY('productversion') as versao"; | |
| 396 | - } elseif ($sgbd == 'Oracle') { | |
| 397 | - $query = "select version AS versao from product_component_version WHERE product LIKE 'Oracle%'"; | |
| 398 | - } | |
| 399 | - $rs = array(); | |
| 400 | - if ($query) { | |
| 401 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 402 | - } | |
| 403 | - $versao = (count($rs) && isset($rs[0]['versao'])) ? $rs[0]['versao'] : null; | |
| 404 | - InfraDebug::getInstance()->gravar('SEI02 - Versao do SGBD: ' . $versao, InfraLog::$INFORMACAO); | |
| 405 | - return $versao; | |
| 406 | - } | |
| 407 | - | |
| 408 | - public function obterVelocidadePorCidade(){ | |
| 409 | - $query = " | |
| 2 | +require_once dirname(__FILE__) . '/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdEstatisticasColetarRN extends InfraRN | |
| 5 | +{ | |
| 6 | + | |
| 7 | + public function __construct() { | |
| 8 | + parent::__construct(); | |
| 9 | + } | |
| 10 | + | |
| 11 | + protected function inicializarObjInfraIBanco() { | |
| 12 | + return BancoSEI::getInstance(); | |
| 13 | + } | |
| 14 | + | |
| 15 | + public function coletarIndicadores() { | |
| 16 | + try { | |
| 17 | + | |
| 18 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 19 | + $orgaoSigla = $objConfiguracaoSEI->getValor('MdEstatisticas', 'sigla', false, ''); | |
| 20 | + | |
| 21 | + $ind = array(); | |
| 22 | + | |
| 23 | + $ind['dataColeta'] = $this->obterDataColeta(); | |
| 24 | + $ind['orgaoSigla'] = $orgaoSigla; | |
| 25 | + $ind['seiVersao'] = $this->obterVersaoSEI(); | |
| 26 | + $ind['phpVersao'] = $this->obterVersaoPHP(); | |
| 27 | + $ind['memcachedVersao'] = $this->obterVersaoMemcached(); | |
| 28 | + $ind['solrVersao'] = $this->obterVersaoSolr(); | |
| 29 | + $ind['protocolo'] = $this->obterProtocolo(); | |
| 30 | + $ind['quantidadeUnidades'] = $this->obterQuantidadeUnidades(); | |
| 31 | + $ind['quantidadeProcedimentos'] = $this->obterQuantidadeProcessosAdministrativos(); | |
| 32 | + $ind['quantidadeUsuarios'] = $this->obterQuantidadeUsuarios(); | |
| 33 | + $ind['quantidadeDocumentosInternos'] = $this->obterQuantidadeDocumentosInternos(); | |
| 34 | + $ind['quantidadeDocumentosExternos'] = $this->obterQuantidadeDocumentosExternos(); | |
| 35 | + $ind['quantidadeMemoria'] = $this->obterUsoMemoria(); | |
| 36 | + $ind['porcentagemCPU'] = $this->obterUsoCPU(); | |
| 37 | + $ind['espacoDiscoUsado'] = $this->obterEspacoDisco(); | |
| 38 | + $ind['estrategiaCessao'] = $this->obterEstrategiaCessao(); | |
| 39 | + $ind['tamanhoDatabase'] = $this->obterTamanhoDataBase(); | |
| 40 | + $ind['bancoSei'] = $this->obterTipoSGBD(); | |
| 41 | + $ind['bancoVersao'] = $this->obterBancoVersao(); | |
| 42 | + $ind['servidorAplicacao'] = $this->obterServidorAplicacao(); | |
| 43 | + $ind['sistemaOperacional'] = $this->obterSistemaOperacional(); | |
| 44 | + $ind['sistemaOperacionalDetalhado'] = $this->obterSistemaOperacionalDetalhado(); | |
| 45 | + $ind['tamanhoFilesystem'] = $this->obterTamanhoFileSystem(); | |
| 46 | + $ind['tabelasTamanhos'] = $this->obterTamanhoTabelas(); | |
| 47 | + $ind['modulos'] = $this->obterPlugins(); | |
| 48 | + $ind['extensoes'] = $this->obterQuantidadeDocumentosExternosPorExtensao(); | |
| 49 | + $ind['anexosTamanhos'] = $this->obterTamanhoDocumentosExternos(); | |
| 50 | + | |
| 51 | + InfraDebug::getInstance()->gravar('Ind: ' . json_encode($ind), InfraLog::$INFORMACAO); | |
| 52 | + | |
| 53 | + return $ind; | |
| 54 | + } catch (Exception $e) { | |
| 55 | + InfraDebug::getInstance()->setBolLigado(false); | |
| 56 | + InfraDebug::getInstance()->setBolDebugInfra(false); | |
| 57 | + InfraDebug::getInstance()->setBolEcho(false); | |
| 58 | + throw new InfraException('Erro processando estatísticas do sistema.', $e); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + private function obterVersaoSEI() { | |
| 63 | + return SEI_VERSAO; | |
| 64 | + } | |
| 65 | + | |
| 66 | + private function obterVersaoPHP() { | |
| 67 | + return phpversion(); | |
| 68 | + } | |
| 69 | + | |
| 70 | + private function getDirectorySize($path) { | |
| 71 | + $bytestotal = 0; | |
| 72 | + $path = realpath($path); | |
| 73 | + if ($path !== false) { | |
| 74 | + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) { | |
| 75 | + $bytestotal += $object->getSize(); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + return $bytestotal; | |
| 79 | + } | |
| 80 | + | |
| 81 | + private function obterTamanhoFileSystem() { | |
| 82 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 83 | + if ($objConfiguracaoSEI->isSetValor('SEI', 'RepositorioArquivos')) { | |
| 84 | + $diretorio = $objConfiguracaoSEI->getValor('SEI', 'RepositorioArquivos'); | |
| 85 | + $tamanho = $this->getDirectorySize($diretorio); | |
| 86 | + } | |
| 87 | + return $tamanho; | |
| 88 | + } | |
| 89 | + | |
| 90 | + private function obterPlugins() { | |
| 91 | + global $SEI_MODULOS; | |
| 92 | + $lista = array(); | |
| 93 | + foreach ($SEI_MODULOS as $strModulo => $seiModulo) { | |
| 94 | + $result = array( | |
| 95 | + 'nome' => $strModulo, | |
| 96 | + 'versao' => $seiModulo->getVersao() | |
| 97 | + ); | |
| 98 | + array_push($lista, $result); | |
| 99 | + } | |
| 100 | + | |
| 101 | + InfraDebug::getInstance()->gravar('SEI03 - Plugins: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 102 | + return $lista; | |
| 103 | + } | |
| 104 | + | |
| 105 | + private function obterQuantidadeUnidades() { | |
| 106 | + $objUnidadeRN = new UnidadeRN(); | |
| 107 | + $numQuantidadeUnidades = $objUnidadeRN->contarRN0128(new UnidadeDTO()); | |
| 108 | + | |
| 109 | + InfraDebug::getInstance()->gravar('SEI11 - Quantidade Unidades: ' . $numQuantidadeUnidades, InfraLog::$INFORMACAO); | |
| 110 | + return $numQuantidadeUnidades; | |
| 111 | + } | |
| 112 | + | |
| 113 | + private function obterTamanhoTotalDocumentosExternos() { | |
| 114 | + $query = "select sum(tamanho) as tamanho from anexo where sin_ativo = 'S'"; | |
| 115 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 116 | + $tamanho = (count($rs) && isset($rs[0]['tamanho'])) ? $rs[0]['tamanho'] : 0; | |
| 117 | + | |
| 118 | + InfraDebug::getInstance()->gravar('SEI12 - Tamanho Documentos Externos: ' . $tamanho, InfraLog::$INFORMACAO); | |
| 119 | + return $tamanho; | |
| 120 | + } | |
| 121 | + | |
| 122 | + private function obterQuantidadeUsuarios() { | |
| 123 | + $query = "SELECT COUNT(*) as quantidade FROM usuario WHERE sin_ativo = 'S'"; | |
| 124 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 125 | + $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 126 | + | |
| 127 | + InfraDebug::getInstance()->gravar('SEI09 - Quantidade de usuários: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 128 | + return $quantidade; | |
| 129 | + } | |
| 130 | + | |
| 131 | + private function obterProtocolo() { | |
| 132 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 133 | + if ($objConfiguracaoSEI->isSetValor('SessaoSEI', 'https')) { | |
| 134 | + $temHTTPS = $objConfiguracaoSEI->getValor('SessaoSEI', 'https'); | |
| 135 | + $protocolo = 'HTTP'; | |
| 136 | + if ($temHTTPS) { | |
| 137 | + $protocolo = 'HTTPS'; | |
| 138 | + } | |
| 139 | + InfraDebug::getInstance()->gravar('SEI12 - Protocolo: ' . $protocolo, InfraLog::$INFORMACAO); | |
| 140 | + return $protocolo; | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 144 | + private function obterQuantidadeProcessosAdministrativos() { | |
| 145 | + $query = "select count(*) as quantidade from procedimento"; | |
| 146 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 147 | + $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 148 | + | |
| 149 | + InfraDebug::getInstance()->gravar('SEI06 - Quantidade de Processos Administrativos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 150 | + return $quantidade; | |
| 151 | + } | |
| 152 | + | |
| 153 | + private function obterTipoSGBD() { | |
| 154 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 155 | + $sgbd = $objConfiguracaoSEI->getValor('BancoSEI', 'Tipo', false, ''); | |
| 156 | + InfraDebug::getInstance()->gravar('SEI02 - SGBD: ' . $sgbd, InfraLog::$INFORMACAO); | |
| 157 | + return $sgbd; | |
| 158 | + } | |
| 159 | + | |
| 160 | + private function obterQuantidadeDocumentosInternos() { | |
| 161 | + $query = "SELECT COUNT(*) as quantidade FROM documento WHERE STA_DOCUMENTO = 'I'"; | |
| 162 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 163 | + $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 164 | + | |
| 165 | + InfraDebug::getInstance()->gravar('SEI05 - Quantidade de documentos internos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 166 | + return $quantidade; | |
| 167 | + } | |
| 168 | + | |
| 169 | + private function obterQuantidadeDocumentosExternos() { | |
| 170 | + $query = "SELECT COUNT(*) as quantidade FROM documento WHERE STA_DOCUMENTO = 'X'"; | |
| 171 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 172 | + $quantidade = (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0; | |
| 173 | + | |
| 174 | + InfraDebug::getInstance()->gravar('SEI05 - Quantidade de documentos externos: ' . $quantidade, InfraLog::$INFORMACAO); | |
| 175 | + return $quantidade; | |
| 176 | + } | |
| 177 | + | |
| 178 | + private function obterQuantidadeDocumentosExternosPorExtensao() { | |
| 179 | + $query = "SELECT nome FROM anexo WHERE sin_ativo = 'S'"; | |
| 180 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 181 | + $extensoes = array(); | |
| 182 | + // Calculando na aplicacao para funcionar independente do banco | |
| 183 | + foreach ($rs as $r) { | |
| 184 | + $extensao = pathinfo($r['nome'], PATHINFO_EXTENSION); | |
| 185 | + $qtd = $extensoes[$extensao]; | |
| 186 | + if (! $qtd) { | |
| 187 | + $qtd = 0; | |
| 188 | + } | |
| 189 | + $extensoes[$extensao] = $qtd + 1; | |
| 190 | + } | |
| 191 | + $lista = array(); | |
| 192 | + foreach ($extensoes as $key => $value) { | |
| 193 | + $result = array( | |
| 194 | + 'extensao' => $key, | |
| 195 | + 'quantidade' => $value | |
| 196 | + ); | |
| 197 | + array_push($lista, $result); | |
| 198 | + } | |
| 199 | + | |
| 200 | + InfraDebug::getInstance()->gravar('SEI07 - Quantidade de extensoes de documentos externos: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 201 | + return $lista; | |
| 202 | + } | |
| 203 | + | |
| 204 | + private function obterEstrategiaCessao() { | |
| 205 | + InfraDebug::getInstance()->gravar('SEI24 - Estrategia de armazenamento de cessao: ' . ini_get('session.save_handler'), InfraLog::$INFORMACAO); | |
| 206 | + return ini_get('session.save_handler'); | |
| 207 | + } | |
| 208 | + | |
| 209 | + private function obterVersaoMemcached() { | |
| 210 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 211 | + $host = $objConfiguracaoSEI->getValor('CacheSEI', 'Servidor', false, ''); | |
| 212 | + $porta = $objConfiguracaoSEI->getValor('CacheSEI', 'Porta', false, ''); | |
| 213 | + | |
| 214 | + $memcache = new Memcache(); | |
| 215 | + $memcache->connect($host, $porta); | |
| 216 | + $versao = $memcache->getVersion(); | |
| 217 | + | |
| 218 | + InfraDebug::getInstance()->gravar('SEI23 - Versão memcached: ' . $versao, InfraLog::$INFORMACAO); | |
| 219 | + return $versao; | |
| 220 | + } | |
| 221 | + | |
| 222 | + private function obterTamanhoDatabase() { | |
| 223 | + $sgbd = $this->obterTipoSGBD(); | |
| 224 | + $query = ''; | |
| 225 | + if ($sgbd == 'MySql') { | |
| 226 | + $query = "SELECT table_schema, SUM(data_length + index_length) as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei' GROUP BY table_schema"; | |
| 227 | + } elseif ($sgbd == 'SqlServer') { | |
| 228 | + $query = "SELECT SUM(Total_Pages * 8 * 1000) As tamanho FROM sys.partitions As P INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id INNER JOIN sys.tables t on t.object_id = p.object_id"; | |
| 229 | + } elseif ($sgbd == 'Oracle') { | |
| 230 | + $query = ""; | |
| 231 | + } | |
| 232 | + $rs = array(); | |
| 233 | + if ($query) { | |
| 234 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 235 | + } | |
| 236 | + $tamanho = (count($rs) && isset($rs[0]['tamanho'])) ? $rs[0]['tamanho'] : 0; | |
| 237 | + | |
| 238 | + InfraDebug::getInstance()->gravar('SEI03 - Tamanho do SGBD: ' . $tamanho, InfraLog::$INFORMACAO); | |
| 239 | + return $tamanho; | |
| 240 | + } | |
| 241 | + | |
| 242 | + private function obterTamanhoTabelas() { | |
| 243 | + $sgbd = $this->obterTipoSGBD(); | |
| 244 | + $query = ''; | |
| 245 | + if ($sgbd == 'MySql') { | |
| 246 | + $query = "SELECT table_name as tabela, data_length + index_length as tamanho FROM information_schema.TABLES WHERE table_schema = 'sei'"; | |
| 247 | + } elseif ($sgbd == 'SqlServer') { | |
| 248 | + $query = "" . " SELECT t.name as tabela, SUM(Total_Pages * 8 * 1000) As tamanho " . " FROM sys.partitions As P " . " INNER JOIN sys.allocation_units As A ON P.hobt_id = A.container_id " . " INNER JOIN sys.tables t on t.object_id = p.object_id " . " GROUP BY t.name ORDER BY t.name"; | |
| 249 | + } elseif ($sgbd == 'Oracle') { | |
| 250 | + $query = ""; | |
| 251 | + } | |
| 252 | + $tabelas = array(); | |
| 253 | + if ($query) { | |
| 254 | + $tabelas = BancoSEI::getInstance()->consultarSql($query); | |
| 255 | + } | |
| 256 | + | |
| 257 | + InfraDebug::getInstance()->gravar('SEI15 - Tamanho das tabelas: ' . json_encode($tabelas), InfraLog::$INFORMACAO); | |
| 258 | + return $tabelas; | |
| 259 | + } | |
| 260 | + | |
| 261 | + private function obterVersaoSolr() { | |
| 262 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 263 | + $url = $objConfiguracaoSEI->getValor('Solr', 'Servidor', false, 'http://localhost:8983/solr'); | |
| 264 | + $url = $url . '/admin/info/system?wt=json'; | |
| 265 | + | |
| 266 | + $ch = curl_init(); | |
| 267 | + curl_setopt($ch, CURLOPT_URL, $url); | |
| 268 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 269 | + $output = curl_exec($ch); | |
| 270 | + $json = json_decode($output, true); | |
| 271 | + $versao = $json['lucene']['lucene-spec-version']; | |
| 272 | + InfraDebug::getInstance()->gravar('SEI22 - Versao Solr: ' . $versao, InfraLog::$INFORMACAO); | |
| 273 | + return $versao; | |
| 274 | + } | |
| 275 | + | |
| 276 | + private function obterServidorAplicacao() { | |
| 277 | + $versao = $_SERVER['SERVER_SOFTWARE']; | |
| 278 | + InfraDebug::getInstance()->gravar('SEI20 - Quantidade de servidores de aplicação e suas versões: ' . $versao, InfraLog::$INFORMACAO); | |
| 279 | + return $versao; | |
| 280 | + } | |
| 281 | + | |
| 282 | + private function obterSistemaOperacional() { | |
| 283 | + $so = PHP_OS; | |
| 284 | + InfraDebug::getInstance()->gravar('SEI17 - Quantidade de Sistemas Operacionais: ' . $so, InfraLog::$INFORMACAO); | |
| 285 | + return $so; | |
| 286 | + } | |
| 287 | + | |
| 288 | + private function obterSistemaOperacionalDetalhado() { | |
| 289 | + $so = php_uname(); | |
| 290 | + InfraDebug::getInstance()->gravar('SEI17 - Quantidade de Sistemas Operacionais (Detalhado): ' . $so, InfraLog::$INFORMACAO); | |
| 291 | + return $so; | |
| 292 | + } | |
| 293 | + | |
| 294 | + private function obterDataColeta() { | |
| 295 | + $dataColeta = date(DATE_ATOM); | |
| 296 | + InfraDebug::getInstance()->gravar('SEI29 - Periodicidade do envio - Data da coleta: ' . $dataColeta, InfraLog::$INFORMACAO); | |
| 297 | + return $dataColeta; | |
| 298 | + } | |
| 299 | + | |
| 300 | + private function obterTamanhoDocumentosExternos() { | |
| 301 | + $resultado = array(); | |
| 302 | + // 0MB - !MB | |
| 303 | + $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 0 AND tamanho < 1000"; | |
| 304 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 305 | + $resultado[0] = array( | |
| 306 | + 'tamanho' => '0MB - 1MB', | |
| 307 | + 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 308 | + ); | |
| 309 | + | |
| 310 | + // 1MB - 10MB | |
| 311 | + $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 1000 AND tamanho < 10000"; | |
| 312 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 313 | + $resultado[1] = array( | |
| 314 | + 'tamanho' => '1MB - 10MB', | |
| 315 | + 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 316 | + ); | |
| 317 | + | |
| 318 | + // 10MB - 100MB | |
| 319 | + $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 10000 AND tamanho < 100000"; | |
| 320 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 321 | + $resultado[2] = array( | |
| 322 | + 'tamanho' => '10MB - 100MB', | |
| 323 | + 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 324 | + ); | |
| 325 | + | |
| 326 | + // > 100MB | |
| 327 | + $query = "SELECT count(*) as quantidade FROM anexo WHERE sin_ativo = 'S' AND tamanho >= 100000"; | |
| 328 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 329 | + $resultado[3] = array( | |
| 330 | + 'tamanho' => 'Maior que 100MB', | |
| 331 | + 'quantidade' => (count($rs) && isset($rs[0]['quantidade'])) ? $rs[0]['quantidade'] : 0 | |
| 332 | + ); | |
| 333 | + | |
| 334 | + InfraDebug::getInstance()->gravar('SEI11 - Tamanho dos documentos externos: ' . json_encode($resultado), InfraLog::$INFORMACAO); | |
| 335 | + return $resultado; | |
| 336 | + } | |
| 337 | + | |
| 338 | + private function obterUsoMemoria() { | |
| 339 | + $memoria = memory_get_usage(); | |
| 340 | + InfraDebug::getInstance()->gravar('SEI18 - Quantidade de byte de uso de memoria: ' . json_encode($memoria), InfraLog::$INFORMACAO); | |
| 341 | + return $memoria; | |
| 342 | + } | |
| 343 | + | |
| 344 | + private function obterUsoCPU() { | |
| 345 | + $load = sys_getloadavg(); | |
| 346 | + $uso = null; | |
| 347 | + if ($load) { | |
| 348 | + $uso = $load[0]; | |
| 349 | + } | |
| 350 | + InfraDebug::getInstance()->gravar('SEI18 - Porcentagem de uso de CPU: ' . json_encode($uso), InfraLog::$INFORMACAO); | |
| 351 | + return $uso; | |
| 352 | + } | |
| 353 | + | |
| 354 | + private function obterEspacoDisco() { | |
| 355 | + $ds = null; | |
| 356 | + if (php_uname('s') == 'Windows NT') { | |
| 357 | + $unidade = substr($_SERVER['DOCUMENT_ROOT'], 0, 2); | |
| 358 | + if (! $unidade) { | |
| 359 | + $unidade = 'C:'; | |
| 360 | + } | |
| 361 | + } else { | |
| 362 | + $unidade = "/"; | |
| 363 | + } | |
| 364 | + $total = disk_total_space($unidade); | |
| 365 | + $free = disk_free_space($unidade); | |
| 366 | + $ds = $total - $free; | |
| 367 | + InfraDebug::getInstance()->gravar('SEI18 - Espaco utilizado do disco: ' . json_encode($ds), InfraLog::$INFORMACAO); | |
| 368 | + return $ds; | |
| 369 | + } | |
| 370 | + | |
| 371 | + private function obterBancoVersao() { | |
| 372 | + $sgbd = $this->obterTipoSGBD(); | |
| 373 | + $query = ''; | |
| 374 | + if ($sgbd == 'MySql') { | |
| 375 | + $query = "SELECT version() as versao"; | |
| 376 | + } elseif ($sgbd == 'SqlServer') { | |
| 377 | + $query = "SELECT SERVERPROPERTY('productversion') as versao"; | |
| 378 | + } elseif ($sgbd == 'Oracle') { | |
| 379 | + $query = "select version AS versao from product_component_version WHERE product LIKE 'Oracle%'"; | |
| 380 | + } | |
| 381 | + $rs = array(); | |
| 382 | + if ($query) { | |
| 383 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 384 | + } | |
| 385 | + $versao = (count($rs) && isset($rs[0]['versao'])) ? $rs[0]['versao'] : null; | |
| 386 | + InfraDebug::getInstance()->gravar('SEI02 - Versao do SGBD: ' . $versao, InfraLog::$INFORMACAO); | |
| 387 | + return $versao; | |
| 388 | + } | |
| 389 | + | |
| 390 | + public function obterVelocidadePorCidade() { | |
| 391 | + $query = " | |
| 410 | 392 | select d.nome as cidade, e.nome as uf, avg(velocidade) as velocidade |
| 411 | 393 | from velocidade_transferencia a |
| 412 | 394 | join unidade b on b.id_unidade = a.id_unidade |
| ... | ... | @@ -416,100 +398,101 @@ class MdEstatisticasColetarRN extends InfraRN { |
| 416 | 398 | group by |
| 417 | 399 | d.nome, e.nome |
| 418 | 400 | "; |
| 419 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 420 | - $lista = array(); | |
| 421 | - foreach($rs as $r) { | |
| 422 | - $result = array( | |
| 423 | - 'cidade' => utf8_encode($r['cidade']), | |
| 424 | - 'uf' => utf8_encode($r['uf']), | |
| 425 | - 'velocidade' => $r['velocidade'] | |
| 426 | - ); | |
| 427 | - | |
| 428 | - array_push($lista, $result); | |
| 429 | - } | |
| 430 | - InfraDebug::getInstance()->gravar('SEI14 - Quantidade de bytes de transferência: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 431 | - return $lista; | |
| 432 | - } | |
| 433 | - | |
| 434 | - public function obterAcessosUsuarios($ultimadata=null){ | |
| 435 | - if ($ultimadata == null) { | |
| 436 | - $ultimadata = '1900-01-01'; | |
| 437 | - } | |
| 438 | - $sgbd = $this->obterTipoSGBD(); | |
| 439 | - $query = ''; | |
| 440 | - if ($sgbd == 'MySql') { | |
| 441 | - $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador where date(dth_acesso) > " . $ultimadata . " group by date(dth_acesso)"; | |
| 442 | - } elseif ($sgbd == 'SqlServer') { | |
| 443 | - $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador where dth_acesso >= " . $ultimadata . " group by CONVERT(date, dth_acesso)"; | |
| 444 | - } elseif ($sgbd == 'Oracle') { | |
| 445 | - $query = "select count(*) as quantidade, to_char(dth_acesso,'YYYY-MM-DD') AS data from infra_navegador where dth_acesso >= date " . $ultimadata . " group by to_char(dth_acesso,'YYYY-MM-DD')"; | |
| 446 | - } | |
| 447 | - | |
| 448 | - $rs = array(); | |
| 449 | - if($query) { | |
| 450 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 451 | - } | |
| 452 | - InfraDebug::getInstance()->gravar('SEI27 - Quantidade de acessos por dia: ' . json_encode($rs), InfraLog::$INFORMACAO); | |
| 453 | - return $rs; | |
| 454 | - } | |
| 455 | - | |
| 456 | - public function obterSistemasOperacionaisUsuarios(){ | |
| 457 | - $sgbd = $this->obterTipoSGBD(); | |
| 458 | - if ($sgbd == 'Oracle') { | |
| 459 | - $query = "select distinct to_char(user_agent) as nome from infra_auditoria where user_agent is not null"; | |
| 460 | - } else { | |
| 461 | - $query = "select distinct user_agent as nome from infra_auditoria where user_agent is not null"; | |
| 462 | - } | |
| 463 | - $sistemas = BancoSEI::getInstance()->consultarSql($query); | |
| 464 | - | |
| 465 | - $lista = array(); | |
| 466 | - foreach($sistemas as $r) { | |
| 467 | - $texto = $r['nome']; | |
| 468 | - $inicio = strpos($texto, '('); | |
| 469 | - if ($inicio !== false) { | |
| 470 | - $fim = strpos($texto, ')', $inicio); | |
| 471 | - $nome = substr($texto, $inicio + 1, $fim - $inicio -1); | |
| 472 | - array_push($lista, $nome); | |
| 473 | - } | |
| 474 | - } | |
| 475 | - $lista = array_unique($lista); | |
| 476 | - | |
| 477 | - $sistemas = array(); | |
| 478 | - foreach($lista as $n) { | |
| 479 | - $result = array('nome'=>$n); | |
| 480 | - array_push($sistemas, $result); | |
| 481 | - } | |
| 482 | - | |
| 483 | - InfraDebug::getInstance()->gravar('SEI26 - Sistemas Operacionais dos Clientes: ' . json_encode($sistemas), InfraLog::$INFORMACAO); | |
| 484 | - return $sistemas; | |
| 485 | - } | |
| 486 | - | |
| 487 | - public function obterNavegadores(){ | |
| 488 | - $query = "select count(*) as quantidade, identificacao as nome, versao from infra_navegador group by identificacao,versao"; | |
| 489 | - $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 490 | - $lista = array(); | |
| 491 | - foreach ($rs as $r) { | |
| 492 | - $result = array( | |
| 493 | - 'nome' => utf8_encode($r['nome']), | |
| 494 | - 'quantidade' => $r['quantidade'], | |
| 495 | - 'versao' => $r['versao'] | |
| 496 | - ); | |
| 497 | - array_push($lista, $result); | |
| 498 | - } | |
| 499 | - | |
| 500 | - InfraDebug::getInstance()->gravar('SEI13 - Quantidade de Navegadores: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 501 | - return $lista; | |
| 502 | - } | |
| 503 | - | |
| 504 | - public function obterQuantidadeRecurso() { | |
| 505 | - $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM sei.infra_auditoria group by 1, 2, 3 order by 1, 2, 3"; | |
| 506 | - return BancoSEI::getInstance()->consultarSql($query); | |
| 507 | - } | |
| 508 | - | |
| 509 | - public function obterQuantidadeLogErro() { | |
| 510 | - $query = "select year(dth_log) ano, month(dth_log) mes, week(dth_log) semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' group by 1, 2, 3"; | |
| 511 | - return BancoSEI::getInstance()->consultarSql($query); | |
| 512 | - } | |
| 513 | - | |
| 401 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 402 | + $lista = array(); | |
| 403 | + foreach ($rs as $r) { | |
| 404 | + $result = array( | |
| 405 | + 'cidade' => utf8_encode($r['cidade']), | |
| 406 | + 'uf' => utf8_encode($r['uf']), | |
| 407 | + 'velocidade' => $r['velocidade'] | |
| 408 | + ); | |
| 409 | + | |
| 410 | + array_push($lista, $result); | |
| 411 | + } | |
| 412 | + InfraDebug::getInstance()->gravar('SEI14 - Quantidade de bytes de transferência: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 413 | + return $lista; | |
| 414 | + } | |
| 415 | + | |
| 416 | + public function obterAcessosUsuarios($ultimadata = null) { | |
| 417 | + if ($ultimadata == null) { | |
| 418 | + $ultimadata = '1900-01-01'; | |
| 419 | + } | |
| 420 | + $sgbd = $this->obterTipoSGBD(); | |
| 421 | + $query = ''; | |
| 422 | + if ($sgbd == 'MySql') { | |
| 423 | + $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador where date(dth_acesso) > " . $ultimadata . " group by date(dth_acesso)"; | |
| 424 | + } elseif ($sgbd == 'SqlServer') { | |
| 425 | + $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador where dth_acesso >= " . $ultimadata . " group by CONVERT(date, dth_acesso)"; | |
| 426 | + } elseif ($sgbd == 'Oracle') { | |
| 427 | + $query = "select count(*) as quantidade, to_char(dth_acesso,'YYYY-MM-DD') AS data from infra_navegador where dth_acesso >= date " . $ultimadata . " group by to_char(dth_acesso,'YYYY-MM-DD')"; | |
| 428 | + } | |
| 429 | + | |
| 430 | + $rs = array(); | |
| 431 | + if ($query) { | |
| 432 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 433 | + } | |
| 434 | + InfraDebug::getInstance()->gravar('SEI27 - Quantidade de acessos por dia: ' . json_encode($rs), InfraLog::$INFORMACAO); | |
| 435 | + return $rs; | |
| 436 | + } | |
| 437 | + | |
| 438 | + public function obterSistemasOperacionaisUsuarios() { | |
| 439 | + $sgbd = $this->obterTipoSGBD(); | |
| 440 | + if ($sgbd == 'Oracle') { | |
| 441 | + $query = "select distinct to_char(user_agent) as nome from infra_auditoria where user_agent is not null"; | |
| 442 | + } else { | |
| 443 | + $query = "select distinct user_agent as nome from infra_auditoria where user_agent is not null"; | |
| 444 | + } | |
| 445 | + $sistemas = BancoSEI::getInstance()->consultarSql($query); | |
| 446 | + | |
| 447 | + $lista = array(); | |
| 448 | + foreach ($sistemas as $r) { | |
| 449 | + $texto = $r['nome']; | |
| 450 | + $inicio = strpos($texto, '('); | |
| 451 | + if ($inicio !== false) { | |
| 452 | + $fim = strpos($texto, ')', $inicio); | |
| 453 | + $nome = substr($texto, $inicio + 1, $fim - $inicio - 1); | |
| 454 | + array_push($lista, $nome); | |
| 455 | + } | |
| 456 | + } | |
| 457 | + $lista = array_unique($lista); | |
| 458 | + | |
| 459 | + $sistemas = array(); | |
| 460 | + foreach ($lista as $n) { | |
| 461 | + $result = array( | |
| 462 | + 'nome' => $n | |
| 463 | + ); | |
| 464 | + array_push($sistemas, $result); | |
| 465 | + } | |
| 466 | + | |
| 467 | + InfraDebug::getInstance()->gravar('SEI26 - Sistemas Operacionais dos Clientes: ' . json_encode($sistemas), InfraLog::$INFORMACAO); | |
| 468 | + return $sistemas; | |
| 469 | + } | |
| 470 | + | |
| 471 | + public function obterNavegadores() { | |
| 472 | + $query = "select count(*) as quantidade, identificacao as nome, versao from infra_navegador group by identificacao,versao"; | |
| 473 | + $rs = BancoSEI::getInstance()->consultarSql($query); | |
| 474 | + $lista = array(); | |
| 475 | + foreach ($rs as $r) { | |
| 476 | + $result = array( | |
| 477 | + 'nome' => utf8_encode($r['nome']), | |
| 478 | + 'quantidade' => $r['quantidade'], | |
| 479 | + 'versao' => $r['versao'] | |
| 480 | + ); | |
| 481 | + array_push($lista, $result); | |
| 482 | + } | |
| 483 | + | |
| 484 | + InfraDebug::getInstance()->gravar('SEI13 - Quantidade de Navegadores: ' . json_encode($lista), InfraLog::$INFORMACAO); | |
| 485 | + return $lista; | |
| 486 | + } | |
| 487 | + | |
| 488 | + public function obterQuantidadeRecurso() { | |
| 489 | + $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM sei.infra_auditoria group by 1, 2, 3 order by 1, 2, 3"; | |
| 490 | + return BancoSEI::getInstance()->consultarSql($query); | |
| 491 | + } | |
| 492 | + | |
| 493 | + public function obterQuantidadeLogErro() { | |
| 494 | + $query = "select year(dth_log) ano, month(dth_log) mes, week(dth_log) semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' group by 1, 2, 3"; | |
| 495 | + return BancoSEI::getInstance()->consultarSql($query); | |
| 496 | + } | |
| 514 | 497 | } |
| 515 | 498 | ?> | ... | ... |
rn/MdEstatisticasEnviarRN.php
| 1 | 1 | <? |
| 2 | -require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 2 | +require_once dirname(__FILE__) . '/../../../SEI.php'; | |
| 3 | 3 | |
| 4 | +class MdEstatisticasEnviarRN extends InfraRN | |
| 5 | +{ | |
| 4 | 6 | |
| 5 | -class MdEstatisticasEnviarRN extends InfraRN { | |
| 7 | + public function __construct() { | |
| 8 | + parent::__construct(); | |
| 6 | 9 | |
| 7 | - public function __construct(){ | |
| 8 | - parent::__construct(); | |
| 10 | + $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 11 | + $this->url = $objConfiguracaoSEI->getValor('MdEstatisticas', 'url', false, 'http://estatisticas.planejamento.gov.br'); | |
| 12 | + $this->orgaoSigla = $objConfiguracaoSEI->getValor('MdEstatisticas', 'sigla', false, ''); | |
| 13 | + } | |
| 9 | 14 | |
| 10 | - $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); | |
| 11 | - $this->url = $objConfiguracaoSEI->getValor('MdEstatisticas','url', false, 'http://estatisticas.planejamento.gov.br'); | |
| 12 | - $this->orgaoSigla = $objConfiguracaoSEI->getValor('MdEstatisticas','sigla', false, ''); | |
| 13 | - } | |
| 15 | + protected function inicializarObjInfraIBanco() { | |
| 16 | + return BancoSEI::getInstance(); | |
| 17 | + } | |
| 14 | 18 | |
| 15 | - protected function inicializarObjInfraIBanco(){ | |
| 16 | - return BancoSEI::getInstance(); | |
| 17 | - } | |
| 19 | + public function enviarIndicadores($indicadores) { | |
| 20 | + return $this->doPost($this->url, $indicadores); | |
| 21 | + } | |
| 18 | 22 | |
| 19 | - public function enviarIndicadores($indicadores) { | |
| 20 | - return $this->doPost($this->url, $indicadores); | |
| 21 | - } | |
| 23 | + public function obterUltimoAcesso() { | |
| 24 | + $data = $this->doGet($this->url . '/ultimoacesso?sigla=' . $this->orgaoSigla, false); | |
| 25 | + return date($data); | |
| 26 | + } | |
| 22 | 27 | |
| 23 | - public function obterUltimoAcesso() { | |
| 24 | - $data = $this->doGet($this->url . '/ultimoacesso?sigla=' . $this->orgaoSigla, false); | |
| 25 | - return date($data); | |
| 26 | - } | |
| 28 | + public function enviarAcessos($acessos, $id) { | |
| 29 | + $url = $this->url . '/acessos'; | |
| 30 | + InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 31 | + $obj = array( | |
| 32 | + id => $id, | |
| 33 | + acessosUsuarios => $acessos | |
| 34 | + ); | |
| 35 | + InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 36 | + return $this->doPost($url, $obj, false); | |
| 37 | + } | |
| 27 | 38 | |
| 28 | - public function enviarAcessos($acessos, $id) { | |
| 29 | - $url = $this->url . '/acessos'; | |
| 30 | - InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 31 | - $obj = array( | |
| 32 | - id => $id, | |
| 33 | - acessosUsuarios => $acessos | |
| 34 | - ); | |
| 35 | - InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 36 | - return $this->doPost($url, $obj, false); | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function enviarVelocidades($velocidades, $id) { | |
| 40 | - $url = $this->url . '/velocidades'; | |
| 41 | - InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 42 | - $obj = array( | |
| 43 | - id => $id, | |
| 44 | - velocidades => $velocidades | |
| 45 | - ); | |
| 46 | - InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 47 | - return $this->doPost($url, $obj, false); | |
| 48 | - } | |
| 49 | - | |
| 50 | - public function enviarSistemasUsuarios($sistemasOperacionaisUsuarios, $id) { | |
| 51 | - $url = $this->url . '/sistemasoperacionais'; | |
| 52 | - InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 53 | - $obj = array( | |
| 54 | - id => $id, | |
| 55 | - sistemasOperacionaisUsuarios => $sistemasOperacionaisUsuarios | |
| 56 | - ); | |
| 57 | - InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 58 | - return $this->doPost($url, $obj, false); | |
| 59 | - } | |
| 60 | - | |
| 61 | - public function enviarNavegadores($navegadores, $id) { | |
| 62 | - $url = $this->url . '/navegadores'; | |
| 63 | - InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 64 | - $obj = array( | |
| 65 | - id => $id, | |
| 66 | - navegadores => $navegadores | |
| 67 | - ); | |
| 68 | - InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 69 | - return $this->doPost($url, $obj, false); | |
| 70 | - } | |
| 39 | + public function enviarVelocidades($velocidades, $id) { | |
| 40 | + $url = $this->url . '/velocidades'; | |
| 41 | + InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 42 | + $obj = array( | |
| 43 | + id => $id, | |
| 44 | + velocidades => $velocidades | |
| 45 | + ); | |
| 46 | + InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 47 | + return $this->doPost($url, $obj, false); | |
| 48 | + } | |
| 71 | 49 | |
| 72 | - private function doPost($url, $json, $isjson=true) { | |
| 73 | - $data = json_encode($json); | |
| 74 | - $ch = curl_init(); | |
| 75 | - curl_setopt($ch, CURLOPT_URL, $url); | |
| 76 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 77 | - curl_setopt($ch, CURLOPT_POST, true); | |
| 78 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
| 79 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
| 80 | - $output = curl_exec($ch); | |
| 81 | - curl_close($ch); | |
| 50 | + public function enviarSistemasUsuarios($sistemasOperacionaisUsuarios, $id) { | |
| 51 | + $url = $this->url . '/sistemasoperacionais'; | |
| 52 | + InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 53 | + $obj = array( | |
| 54 | + id => $id, | |
| 55 | + sistemasOperacionaisUsuarios => $sistemasOperacionaisUsuarios | |
| 56 | + ); | |
| 57 | + InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 58 | + return $this->doPost($url, $obj, false); | |
| 59 | + } | |
| 60 | + | |
| 61 | + public function enviarNavegadores($navegadores, $id) { | |
| 62 | + $url = $this->url . '/navegadores'; | |
| 63 | + InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 64 | + $obj = array( | |
| 65 | + id => $id, | |
| 66 | + navegadores => $navegadores | |
| 67 | + ); | |
| 68 | + InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 69 | + return $this->doPost($url, $obj, false); | |
| 70 | + } | |
| 82 | 71 | |
| 83 | - if ($isjson) { | |
| 84 | - return json_decode($output, true); | |
| 72 | + public function enviarLogsErro($logs, $id) { | |
| 73 | + $url = $this->url . '/logserro'; | |
| 74 | + InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
| 75 | + $obj = array( | |
| 76 | + id => $id, | |
| 77 | + logsErro => $logs | |
| 78 | + ); | |
| 79 | + InfraDebug::getInstance()->gravar('URL: ' . json_encode($obj), InfraLog::$INFORMACAO); | |
| 80 | + return $this->doPost($url, $obj, false); | |
| 85 | 81 | } |
| 86 | - return $output; | |
| 87 | - } | |
| 88 | 82 | |
| 89 | - private function doGet($url, $isjson=true) { | |
| 90 | - $ch = curl_init(); | |
| 91 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 92 | - curl_setopt($ch, CURLOPT_URL, $url); | |
| 93 | - $output = curl_exec($ch); | |
| 94 | - curl_close($ch); | |
| 83 | + private function doPost($url, $json, $isjson = true) { | |
| 84 | + $data = json_encode($json); | |
| 85 | + $ch = curl_init(); | |
| 86 | + curl_setopt($ch, CURLOPT_URL, $url); | |
| 87 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 88 | + curl_setopt($ch, CURLOPT_POST, true); | |
| 89 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
| 90 | + 'Content-Type: application/json' | |
| 91 | + )); | |
| 92 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
| 93 | + $output = curl_exec($ch); | |
| 94 | + curl_close($ch); | |
| 95 | 95 | |
| 96 | - if ($isjson) { | |
| 97 | - return json_decode($output, true); | |
| 96 | + if ($isjson) { | |
| 97 | + return json_decode($output, true); | |
| 98 | + } | |
| 99 | + return $output; | |
| 98 | 100 | } |
| 99 | - return $output; | |
| 100 | - } | |
| 101 | 101 | |
| 102 | + private function doGet($url, $isjson = true) { | |
| 103 | + $ch = curl_init(); | |
| 104 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| 105 | + curl_setopt($ch, CURLOPT_URL, $url); | |
| 106 | + $output = curl_exec($ch); | |
| 107 | + curl_close($ch); | |
| 108 | + | |
| 109 | + if ($isjson) { | |
| 110 | + return json_decode($output, true); | |
| 111 | + } | |
| 112 | + return $output; | |
| 113 | + } | |
| 102 | 114 | } |
| 103 | 115 | ?> | ... | ... |