Advertisement
Guest User

Server load bar

a guest
Feb 19th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. print('<h2>Server load</h2>');
  2. print("<table class='main' border='0' width='420'><tr><td style='padding: 0px; background-repeat: repeat-x'>");
  3.  
  4. $percent = min(100, round(exec('ps ax | grep -c lighttpd') / 256 * 30 )); // Apache or lighttpd
  5.  
  6. // System tracker load
  7. echo "<center><br />Tracker load: ($percent %)
  8. <table class='main' border='0' width='400'><tr>
  9. <td style='padding: 0px; background-image: url({$images}loadbarbg.gif); background-repeat: repeat-x'>";
  10.  
  11. if ($percent <= 70) $pic = "{$images}loadbargreen.gif";
  12.  
  13. elseif ($percent <= 90) $pic = "{$images}loadbaryellow.gif";
  14.  
  15. else $pic = "{$images}loadbarred.gif";
  16.  
  17. $width = $percent * 8;
  18.  
  19. echo "<img height=15 width=$width src='".$pic."' alt='$percent%'></td></tr></table>";
  20. echo "Uptime: ".trim(exec('uptime'))."<br />";
  21.  
  22. $percent = min(100, round(exec('ps ax | grep -c lighttpd') / 256 * 150));
  23.  
  24. // Server load
  25. echo "<br />Server load: ($percent %)
  26. <table class='main' border='0' width='400'><tr>
  27. <td style='padding: 0px; background-image: url({$images}loadbarbg.gif); background-repeat: repeat-x'>";
  28.  
  29. if ($percent <= 70) $pic = "{$images}loadbargreen.gif";
  30.  
  31. elseif ($percent <= 90) $pic = "{$images}loadbaryellow.gif";
  32. else
  33.  
  34. $pic = '{$images}loadbarred.gif';
  35. $width = $percent * 8;
  36.  
  37. echo "<img height='15' width=$width src='".$pic."' alt='$percent%'></td></tr></table><br />";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement