Forum und email

mysql_stat

(PHP 4 >= 4.3.0, PHP 5, PECL mysql:1.0)

mysql_stat — Obtener el status actual del sistema

Descripción

string mysql_stat ([ resource $id_enlace ] )

mysql_stat() devuelve el status actual del servidor.

Lista de parámetros

link_identifier

The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.

Valores retornados

Devuelve una cadena con el status de uptime, hilos, consultas, tablas abiertas, tablas de vaciado y consultas por segundo. Para una lista completa de variables de status, es necesario usar el comando SQL SHOW STATUS. Si id_enlace es inválido, se devuelve NULL.

Ejemplos

Example#1 Ejemplo de mysql_stat()

<?php
$enlace 
mysql_connect('localhost''usuario_mysql''contrasenya_mysql');
$status explode('  'mysql_stat($enlace));
print_r($status);
?>

El resultado del ejemplo seria algo similar a:

Array
(
    [0] => Uptime: 5380
    [1] => Threads: 2
    [2] => Questions: 1321299
    [3] => Slow queries: 0
    [4] => Opens: 26
    [5] => Flush tables: 1
    [6] => Open tables: 17
    [7] => Queries per second avg: 245.595
)

Example#2 Ejemplo alternativo de mysql_stat()

<?php
$enlace    
mysql_connect('localhost''usuario_mysql''contrasenya_mysql');
$resultado mysql_query('SHOW VARIABLES'$enlace);
while (
$fila mysql_fetch_assoc($result)) {
    echo 
$fila['Variable_name'] . ' = ' $fila['Value'] . "\n";
}
?>

El resultado del ejemplo seria algo similar a:

back_log = 50
basedir = /usr/local/
bdb_cache_size = 8388600
bdb_log_buffer_size = 32768
bdb_home = /var/db/mysql/
bdb_max_lock = 10000
bdb_logdir = 
bdb_shared_data = OFF
bdb_tmpdir = /var/tmp/
...