login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Handige scripts > Status van je site

Status van je site

Auteur: Frederic - 24 december 2005 - 22:06 - Gekeurd door: nemesiskoen - Hits: 5617 - Aantal punten: 2.50 (3 stemmen)





Ik heb enkele functies zelf geschreven om zo mijn website te kunnen moniteren. De meeste functies returnen TRUE of FALSE, dus daar kan je dan een afbeelding aanhangen, of gewoon tekst. Enkele functies geven waardes terug. Natuurlijk kan je desgewenste functies wissen die niet van toepassing/onnodig zijn.
Werkt iets niet? Laat het me dan weten!

De output is voor de gebruiker zelf aan te maken, dit is enkel de functiedeclarering

Code:
  1. <?php
  2. function server_online(){
  3. $verbinden = @fsockopen ("www.jesite.be", 80, $errno, $errstr, 10);
  4. if ($verbinden){
  5. return TRUE;
  6. }
  7. else{
  8. return FALSE;
  9. }
  10. }
  11.  
  12. function server_antwoord(){
  13. $aantal = 20;
  14. for ($i=0;$i<=$aantal;$i++){
  15. $ping1 = substr(microtime(),11,9) + substr(microtime(),0,10);
  16. $sock = @fsockopen("www.jesite.be", 80, $errno, $errstr, 10);
  17. $ping2 = substr(microtime(),11,9) + substr(microtime(),0,10);
  18.  
  19. $ping = $ping + round(($ping2 - $ping1) * 1000);
  20. @fclose($sock);
  21. }
  22. $ping = ($ping/$aantal) . " ms";
  23. return $ping;
  24. }
  25.  
  26.  
  27. function mysql_online_1(){
  28. $verbinden = @fsockopen ("www.jesite.be", 3306, $errno, $errstr, 10);
  29. if ($verbinden){
  30. return TRUE;
  31. }
  32. else{
  33. return FALSE;
  34. }
  35. }
  36.  
  37. function mysql_online_2(){
  38. if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
  39. return FALSE;
  40. }
  41. else{
  42. return TRUE;
  43. }
  44. }
  45.  
  46. function mysql_online_3(){
  47. if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
  48. return FALSE;
  49. }
  50. else{
  51. return mysql_ping($sql);
  52. }
  53. }
  54.  
  55. function mysql_queries(){
  56. if( (!@mysql_connect ('localhost','****','****')) || (!@mysql_select_db ('online')) ){
  57. return FALSE;
  58. }
  59. else{
  60. $aantal = explode(' ', mysql_stat($sql));
  61. $aantal = explode(': ',$aantal[7]);
  62. echo $aantal[1] . " queries per seconde";
  63. }
  64. }
  65.  
  66. function mysql_antwoord(){
  67. $aantal = 20;
  68. for ($i=0;$i<=$aantal;$i++){
  69. $ping1 = substr(microtime(),11,9) + substr(microtime(),0,10);
  70. $sock = @fsockopen("www.jesite.be", 3306, $errno, $errstr, 10);
  71. $ping2 = substr(microtime(),11,9) + substr(microtime(),0,10);
  72.  
  73. $ping = $ping + round(($ping2 - $ping1) * 1000);
  74. @fclose($sock);
  75. }
  76. $ping = ($ping/$aantal) . " ms";
  77. return $ping;
  78. }
  79.  
  80. function mysql_grootte(){
  81. $tabellen = mysql_list_tables("JE DB NAAM");
  82. $grootte = 0;
  83. while (list($tabelnaam) = mysql_fetch_array($tabellen)) {
  84. $sql = mysql_query("SHOW TABLE STATUS LIKE '" . $tabelnaam . "'");
  85. $rij = mysql_fetch_assoc($sql);
  86.  
  87. $grootte = $grootte + $rij['Data_length'];
  88. }
  89. $grootte = round($grootte / (1024 * 1024), 2) . " mB";
  90.  
  91. return $grootte;
  92. }
  93. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (6)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.027s