Get MySQL stats


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.