Check DBs
Publicado por Iuri Carraro 13/04/2005
[ Hits: 4.453 ]
Esse script faz uma varedura em todos os bandos e bases do MySQL e dando um check em cada tabela pra verificar se está tudo ok.
Script interessante pra quem gosta de cuidar de perto de suas bases.
É necessário mexer apenas no CSS senão vai ficar muito estranho a cara da tabela
<?
$tempo = time();
include "../nead/conex.inc.php";
include "../comum/lib/funcoes_bd.inc.php";
$i=0;
?>
<html>
<head>
<title>Estatística</title>
<link href=styles.css rel=stylesheet type=text/css>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
</head>
<body style="background:#D2E4FC">
<div align=right id=divInfo></div>
<table width=50% align=center border=1 cellspacing=0 cellpadding=0>
<tr>
<td align=center width=3%>Nº</td>
<td align=center width=30%>Tabela</td>
<td align=center width=3%>Operação</td>
<td align=center width=3%>Tipo</td>
<td align=center width=3%>Avaliação</td>
</tr>
<?
$res_dbs = mysql_list_dbs();
while($row_dbs = mysql_fetch_array($res_dbs)){
?>
<?
$bancos = mysql_num_rows($res_dbs);
mysql_select_db($row_dbs['0']);
$res_tables = mysql_list_tables($row_dbs['0']);
while ($row_tables = mysql_fetch_row($res_tables)) {
$tables = mysql_num_rows($res_tables);
$query = "CHECK TABLE ".$row_tables['0'];
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$i++;
if($i < 10) $i = '000'.$i;
if($i >= 10 && $i < 100) $i = '00'.$i;
if($i >= 100 && $i < 1000) $i = '0'.$i;
//if($row['Msg_type'] != 'error'){
?>
<tr <?=$row['Msg_type'] == 'error'? 'class=erro':''?> class=<?= $i % 2 ? 'claro':'medio';?>>
<td align=center ><?=$i?></td>
<td><?=$row['Table'] ?></td>
<td align=center><?=$row['Op']?></td>
<td align=center><?=$row['Msg_type']?></td>
<td align=center><?=$row['Msg_text']?></td>
</tr>
<?
//}
}
?>
<?
}
$time_dif = (time() - $tempo);
$tempo = (floor($time_dif-(floor($time_dif/60))*60)/1000);
$str = "DBs: <b>".$bancos."</b> - Tables:<b> ".$tables."</b> (<b>".$tempo."</b> seg)";
?>
</table>
<script language=javascript> document.getElementById("divInfo").innerHTML = '<?=$str?>'; </script>
</body>
</html>
Nenhum comentário foi encontrado.
KDE Plasma - porque pode ser a melhor opção de interface gráfica
Gentoo: detectando impressoras de rede e como fixar uma impressora por IP
Como o GNOME conseguiu o feito de ser preterido por outras interfaces gráficas
Por que sua empresa precisa de uma PKI (e como automatizar EMISSÕES de certificados via Web API)
Instalando NoMachine no Gentoo com Systemd (acesso Remoto em LAN)
Instalar Linux em notebook Sony Vaio VPCEG13EB (13)
Vou destruir sua infância:) (7)
Interface gráfica com problema (0)









