Posted By

NyX on 08/17/09


Tagged

mysql


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

irishsk
Vordreller
umang_nine
farondomenicgmailcom


Get MySQL stats


 / Published in: PHP
 

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

  1. <?php
  2. $db_host = "";
  3. $db_user = "";
  4. $db_pass = "";
  5. $db_name = "";
  6.  
  7. ##
  8. ## sqlstats()
  9. ## -> Get mysql stats and display them
  10. ##
  11.  
  12. function sqlstats() {
  13. ## Connect to mysql and gather data
  14. $link = mysql_connect($db_host,$db_user,$db_pass) or die("Unable to connect to MySQL");
  15.  
  16. $stats = explode(' ', mysql_stat($link));
  17.  
  18. foreach($stats as $key => $value) {
  19. echo $value."<br/>";
  20. }
  21.  
  22. ## Data gather complete, close MySQL connection
  23. }
  24. ?>

Report this snippet  

You need to login to post a comment.