Return to Snippet

Revision: 16823
at August 17, 2009 11:32 by NyX


Initial Code
<?php
$db_host = "";
$db_user = "";
$db_pass = "";
$db_name = "";

##
##	sqlstats()
##	-> Get mysql stats and display them
##

function sqlstats() {		
	## Connect to mysql and gather data
	$link = mysql_connect($db_host,$db_user,$db_pass) or die("Unable to connect to MySQL");
	
	$stats = explode('  ', mysql_stat($link));
	
	foreach($stats as $key => $value) {
		echo $value."<br/>";
	}
	
	## Data gather complete, close MySQL connection
	mysql_close();
}
?>

Initial URL

                                

Initial Description
Outputs MySQL server stats : uptime, threads, questions, slow queries, opens, flush tables, open tables, queries per sec (avg).

Initial Title
Get MySQL stats

Initial Tags
mysql

Initial Language
PHP