Advertisement
Guest User

Untitled

a guest
Jan 26th, 2012
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 39.16 KB | None | 0 0
  1. <?php
  2. // vpsinfo by Douglas Robbins
  3. // Email: drobbins [at] labradordata.ca
  4. // Website: http://www.labradordata.ca/vpsinfo/
  5. $version = '2.3.2 (16 June 2006)';
  6.  
  7. // This script is intended as a general information/monitoring page for a Linux
  8. // Virtuozza or OpenVZ VPS (Virtual Private Server). It also runs fine on a
  9. // dedicated Linux machine.
  10.  
  11. // Acknowledgements:
  12. //
  13. // 'vpsstat' output is based on a perl script by the same name developed by
  14. // ServInt technical staff.
  15. //
  16. // This script may utilize third party software if installed:
  17. // * MyTop by Jeremy D. Zawodny, GNU General Public License.
  18. //   http://jeremy.zawodny.com/mysql/mytop/
  19. // * mysqlreport by ?
  20. //   http://hackmysql.com/mysqlreport
  21. // * vnstat by Teemu Toivola, GNU General Public License.
  22. //   http://humdi.net/vnstat/
  23.  
  24. // Thanks to the ServInt VPS forum members & staff for testing and suggestions.
  25.  
  26. // Terms & Conditions:
  27. //
  28. // * This script is an original work and is copyright Douglas T. Robbins;
  29. // * This script is provided to you for use free of charge;
  30. // * You are permitted to modify the script for your own use;
  31. // * You may redistribute the script in its original form;
  32. // * You may not modify the script and publicly redistribute it, unless you
  33. //   make fundamental changes to the script to the extent that it may be
  34. //   considered a new work. In that case you should give your script a new name
  35. //   (i.e., do not use "vpsinfo" in the script name). An acknowledgement of the
  36. //   original vpsinfo in your release would be appreciated.
  37.  
  38. // Liability:
  39. //
  40. // The author assumes no liability for damage or loss that might be associated
  41. // with the use of this script.
  42.  
  43.  
  44. // == START CONFIGURATION =====================================================
  45.  
  46. // Mysql monitoring: 0 = none; 1 = mytop; 2 = mysqlreport
  47. $mysql_mon = 0;
  48.  
  49. // Enable or disable vnstat. 0 = disable 1 = enable:
  50. $vnstat = 0;
  51.  
  52. // MyTop/mysqlreport needs MySQL access to read the processlist.
  53. // You may use any MySQL database.
  54. // If you don't use MyTop or mysqlreport just ignore this.
  55. $my_db   = "database_name";
  56. $my_user = "database_user";
  57. $my_pass = "database_password";
  58.  
  59. // The account home directory for this mysql user:
  60. $userhome = "/home/username";
  61.  
  62. // Processes to monitor. Include any process that should normally appear in the
  63. // COMMAND column of the 'top' output. You can match a partial name, eg. 'ftpd'
  64. // matches 'pure-ftpd' or 'proftpd'. Possible additions include: 'cppop',
  65. // 'cpsrvd', 'exim', 'named'. This is a space-delimited list:
  66. $processes = "ftpd mysqld sshd";
  67.  
  68. // Width of the left column in page display. You can adjust this if the
  69. // leftside boxes are too wide or too narrow:
  70. $leftcol = 590;
  71.  
  72. // Difference in hours between your local time and server time:
  73. $timeoffset = 0;
  74.  
  75. // Auto-refresh of the main page.
  76. // Set to 0 to disable, or specify a number of minutes:
  77. $refresh = 1;
  78.  
  79. // Auto-refresh of command windows.
  80. // Set to 0 to disable, or specify a number of minutes:
  81. $top_refresh     = 5;
  82. $vpsstat_refresh = 5;
  83. $netstat_refresh = 5;
  84. $mysql_refresh   = 5;
  85. $vnstat_refresh  = 15;
  86.  
  87. // Bandwidth alert. When the daily data transfer is greater than this, it is
  88. // highlighted in red. In MB:
  89. $bw_alert = 1000;
  90.  
  91. // Enable gzip compression for page output. 0 = disabled  1 = enabled
  92. $gzip = 0;
  93.  
  94. // == END CONFIGURATION =======================================================
  95.  
  96.  
  97. $mtime = explode (" ", microtime());
  98. $tstart = $mtime[0] + $mtime[1];
  99.  
  100. $scriptname = $_SERVER['SCRIPT_NAME'];
  101. $timestamp = time() + ($timeoffset * 3600);
  102. $localtime = date("g:i a, M j", $timestamp);
  103. $shorttime = date("g:i a", $timestamp);
  104.  
  105. // Shell commands for main windows display ------------------------------------
  106.  
  107. $netstat_com = "netstat -nt";
  108. $vnstat_com  = "vnstat";
  109. $top_com     = "top -n 1 -b";
  110. $pstree_com  = "env LANG=C pstree -c";
  111. $df_com      = "df -h --exclude-type=tmpfs";
  112. $tmp_com     = "ls -a --ignore=sess_* /tmp";
  113.  
  114. if ($mysql_mon == 1)
  115.     $mysql_com   = "env HOME=$userhome env TERM=xterm mytop -u $my_user -p $my_pass -d $my_db -b --nocolor";
  116. elseif ($mysql_mon == 2) {
  117.     $mysql_com  = "./mysqlreport --user $my_user --password $my_pass --no-mycnf 2>&1";
  118.     $mysql_com2 = "./mysqlreport --all --tab --user $my_user --password $my_pass --no-mycnf";
  119.  
  120. }
  121. $allps_com   = "ps -e | awk '{ print $4;}' | uniq";
  122.  
  123. // GET and POST requests to this page -----------------------------------------
  124.  
  125. // 'Sample current traffic' (vnstat):
  126.  
  127. if ($_GET["traffic"]) {
  128.     $io = trim(`vnstat -tr | grep --after-context=3 Traffic`);
  129.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 4px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$io</pre>\n</body>\n</html>";
  130.     exit;
  131. }
  132.  
  133. // 'Ports List':
  134.  
  135. if ($_GET["showports"]) {
  136.     $porttext = "Port   What Is It?
  137. ----   -----------------------
  138.  21   FTP server
  139.  25   Exim - SMTP
  140.  53   Bind nameserver
  141.  80   Apache webserver
  142. 110   POP mail server
  143. 143   IMAP mail server
  144. 443   Secure Apache webserver
  145. 465   Secure SMTP
  146. 993   Secure IMAP
  147. 2082   cPanel
  148. 2083   Secure cPanel (https)
  149. 2086   WHM
  150. 2087   Secure WHM (https)
  151. 2095   Webmail
  152. 2096   Secure webmail (https)
  153. 3306   MySQL
  154. 8888   Secure shell - SSHD";
  155.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 30px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$porttext</pre>\n</body>\n</html>";
  156.     exit;
  157. }
  158.  
  159. // Show logged-in shell users:
  160.  
  161. if ($_GET["users"]) {
  162.     $users = trim(`w`);
  163.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 6px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>Logged-in Users\n---------------\n$users</pre>\n</body>\n</html>";
  164.     exit;
  165. }
  166.  
  167. // Whois lookup:
  168.  
  169. if ($_POST['whois']) {
  170.         $whois = trim($_POST['whois']);
  171. }
  172. elseif ($_GET['whois']) {
  173.         $whois = trim($_GET['whois']);
  174. }
  175. if (stristr($whois,';')) {
  176.         $parts = explode(';',$whois);
  177.         $whois = $parts[0];
  178. }
  179.  
  180. if ($whois) {
  181.     if (stristr($whois, ":")) {
  182.         $parts = explode(":",$whois);
  183.         $whois = $parts[0];
  184.     }
  185.     $lookup = `whois $whois`;
  186.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 30px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$lookup</pre>\n</body>\n</html>";
  187.     exit;
  188. }
  189.  
  190. // ls -al /tmp:
  191.  
  192. if ($_GET['lsal']) {
  193.     $lsout  = "Command: ls -al /tmp\n\n";
  194.     $lsout .= `ls -al /tmp`;
  195.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 6px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$lsout</pre>\n</body>\n</html>";
  196.     exit;
  197. }
  198.  
  199. // ps -aux (and mem):
  200.  
  201. if ($_GET['psaux']) {
  202.     $psout  = "Command: ps -aux\n\n";
  203.     $psout .= `ps -aux`;
  204.     $psout = str_replace("<","&lt;",$psout);
  205.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 6px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$psout</pre>\n</body>\n</html>";
  206.     exit;
  207. }
  208.  
  209. if ($_GET['psmem']) {
  210.     $psout  = "Command: ps -auxh --sort=size | tac\n\n";
  211.     $psout .= "USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND\n";
  212.     $psout .= `ps -auxh --sort=size | tac`;
  213.     $psout = str_replace("<","&lt;",$psout);
  214.     echo "<html>\n<body bgcolor='#000000' text='#CCCCCC' style='margin:10px 0 0 6px;padding:0'>\n<pre style='font-family:vt7X13,\"Courier New\";font-size:11px;line-height:14px'>$psout</pre>\n</body>\n</html>";
  215.     exit;
  216. }
  217.  
  218. // Command windows:
  219.  
  220. if ($_GET['cmd']) {
  221.     $cmd = $_GET['cmd'];
  222.     if ($cmd == "top") {
  223.         $out = trim(`top -n 1 -b`);
  224.         $meta = "<meta http-equiv=\"refresh\" content=\"".($top_refresh*60)."\">";
  225.     }
  226.     elseif ($cmd == "vpsstat") {
  227.         list($out,$opages,$ppages) = vpsstat();
  228.         $meta = "<meta http-equiv=\"refresh\" content=\"".($vpsstat_refresh*60)."\">";
  229.     }
  230.     elseif ($cmd == "netstat") {
  231.         $out = netstat($netstat_com);
  232.         $meta = "<meta http-equiv=\"refresh\" content=\"".($netstat_refresh*60)."\">";
  233.         $buttons = "<input type='button' value='Listening' onClick=\"window.location.replace('$scriptname?cmd=netstat2');\" class='button' title='show listening ports'>\n";
  234.         $title = "netstat -nt (TCP connections)";
  235.     }
  236.     elseif ($cmd == "netstat2") {
  237.         $out = trim(`netstat -ntl`);
  238.         $meta = "<meta http-equiv=\"refresh\" content=\"".($netstat_refresh*60)."\">";
  239.         $buttons = "<input type='button' value='Active' onClick=\"window.location.replace('$scriptname?cmd=netstat');\" class='button' title='show active connections'>\n";
  240.         $title = "netstat -ntl (listening TCP ports)";
  241.     }
  242.     elseif ($cmd == "mytop") {
  243.         $out = trim(`$mysql_com`);
  244.         $meta = "<meta http-equiv=\"refresh\" content=\"".($mysql_refresh*60)."\">";
  245.     }
  246.     elseif ($cmd == "mysqlreport") {
  247.         $out = trim(`$mysql_com2`);
  248.         $out = str_replace('_','-',$out);
  249.         $meta = "<meta http-equiv=\"refresh\" content=\"".($mysql_refresh*60)."\">";
  250.     }
  251.     elseif ($cmd == "vnstat") {
  252.         $out = trim(`vnstat`);
  253.         $meta = "<meta http-equiv=\"refresh\" content=\"".($vnstat_refresh*60)."\">";
  254.     }
  255.     elseif ($cmd == "vnstat2") {
  256.         $out = trim(`vnstat -d`);
  257.         $meta = "<meta http-equiv=\"refresh\" content=\"".($vnstat_refresh*60)."\">";
  258.         $title = "vnstat -d";
  259.     }
  260.     elseif ($cmd == "vnstat3") {
  261.         $out = trim(`vnstat -m`);
  262.         $meta = "<meta http-equiv=\"refresh\" content=\"".($vnstat_refresh*60)."\">";
  263.         $title = "vnstat -m";
  264.     }
  265.     elseif ($cmd == "vnstat4") {
  266.         $out = trim(`vnstat -tr | grep --after-context=3 Traffic`);
  267.         $meta = "";
  268.         $title = "vnstat -tr";
  269.     }
  270.    
  271.     $reload = "$scriptname?cmd=$cmd";
  272.     if (stristr($cmd,"vnstat")) {
  273.         $buttons = "<input type='button' value='Sample' onClick=\"window.location.replace('$scriptname?cmd=vnstat4');\" class='button' title='sample current traffic - 5 second delay'>
  274. <input type='button' value='Today' onClick=\"window.location.replace('$scriptname?cmd=vnstat');\" class='button' title='today & yesterday'>
  275. <input type='button' value='Days' onClick=\"window.location.replace('$scriptname?cmd=vnstat2');\" class='button' title='daily totals'>
  276. <input type='button' value='Months' onClick=\"window.location.replace('$scriptname?cmd=vnstat3');\" class='button' title='monthly totals'>
  277. <input type='button' value='Close' onClick='javascript:window.close();' class='button' title='close window'>";
  278.     }
  279.     else {
  280.         $buttons .= "<input type='button' value='Reload' onClick='javascript:window.location.reload();' class='button' title='reload $cmd'> <input type='button' value='Close' onClick='javascript:window.close();' class='button' title='close window'>";
  281.     }
  282.     if (!$title) {
  283.         $title = $cmd;
  284.     }
  285.     poppage($cmd,$out,$meta,$reload,$shorttime,$buttons,$title);
  286.     exit;
  287. }
  288.  
  289. // Run the commands now (except vnstat & mysql) -------------------------------
  290.  
  291. $top = trim(`$top_com`);
  292. $hostname = trim(`hostname`);
  293. $netstat = netstat($netstat_com);
  294. $pstree = trim(`$pstree_com`);
  295. $df_full = trim(`$df_com`);
  296. $tmp_full = trim(`$tmp_com`);
  297. $allps = trim(`$allps_com`);
  298.  
  299. // Clean up / prep output -----------------------------------------------------
  300.  
  301. $netstat = preg_replace("/ {1,99}\n/", "\n", $netstat);
  302. $tmp_full = preg_replace("/ {1,99}/", "\n", $tmp_full);
  303.  
  304. // df - Disk Usage:
  305.  
  306. $lines = explode("\n", $df_full);
  307. for ($i=0; $i<count($lines); $i++) {
  308.     $line = preg_replace("/ {1,99}/", "|", $lines[$i]);
  309.     $parts = explode("|",$line);
  310.     if ($parts[0] !== $prev) {
  311.         $mnt = $parts[5];
  312.         $actual = " ($parts[2])";
  313.         if (!stristr($line,"Filesystem")) {
  314.             $per = substr($parts[4],0,-1);
  315.             if ($per > 90) {
  316.                 $allfs .= "<span class='warn'>$mnt $parts[4]$actual</span>,&nbsp;";
  317.             }
  318.             else {
  319.                 $allfs .= "$mnt $parts[4]$actual,&nbsp;";
  320.             }
  321.         }
  322.     }
  323.     $prev = $parts[0];;
  324. }
  325. if (substr($allfs, -7) == ",&nbsp;") {
  326.     $allfs = substr($allfs, 0, -7);
  327. }
  328.  
  329. // Other summary stats:
  330.  
  331. $num_mysql = substr_count($pstree,'mysqld');
  332. $num_httpd = substr_count($pstree,'httpd');
  333. $num_tcp = substr_count($netstat,'tcp');
  334.  
  335. //Main page buttons:
  336.  
  337. // Box buttons to command windows:
  338. $topcmdlink = "<a href='$scriptname?cmd=top' onClick=\"window.open('$scriptname?cmd=top', 'top', 'width=600, height=480, resizable'); return false\" title='open a top window' class='open'>&nbsp;+&nbsp;</a>";
  339. $vpscmdlink = "<a href='$scriptname?cmd=vpsstat' onClick=\"window.open('$scriptname?cmd=vpsstat', 'vpsstat', 'width=540, height=180, resizable'); return false\" title='open a vpsstat window' class='open'>&nbsp;+&nbsp;</a>";
  340. $netcmdlink = "<a href='$scriptname?cmd=netstat' onClick=\"window.open('$scriptname?cmd=netstat', 'netstat', 'width=600, height=480, resizable'); return false\" title='open a netstat window' class='open'>&nbsp;+&nbsp;</a>";
  341.  
  342. if ($mysql_mon == 1)
  343.     $mycmdlink  = "<a href='$scriptname?cmd=mytop' onClick=\"window.open('$scriptname?cmd=mytop', 'mytop', 'width=600, height=345, resizable'); return false\" title='open a mytop window' class='open'>&nbsp;+&nbsp;</a>";
  344. elseif ($mysql_mon == 2)
  345.     $mycmdlink  = "<a href='$scriptname?cmd=mysqlreport' onClick=\"window.open('$scriptname?cmd=mysqlreport', 'mysqlreport', 'width=600, height=480, resizable'); return false\" title='open a mysqlreport window' class='open'>&nbsp;+&nbsp;</a>";
  346.    
  347. $vncmdlink  = "<a href='$scriptname?cmd=vnstat' onClick=\"window.open('$scriptname?cmd=vnstat', 'vnstat', 'width=525, height=345, resizable'); return false\" title='open a vnstat window' class='open'>&nbsp;+&nbsp;</a>";
  348.  
  349. // Button for 'ls -al /tmp':
  350. $lsal = "<input type='button' value='ls -al /tmp' onClick=\"window.open('$scriptname?lsal=1', 'lsal', 'width=730, height=400, scrollbars, resizable'); return false\" title='show detailed list' class='button' style='width:75px'>\n";
  351.  
  352. // Button for 'ps -aux':
  353. $psaux = "<input type='button' value='ps -aux' onClick=\"window.open('$scriptname?psaux=1', 'psaux', 'width=730, height=480, scrollbars, resizable'); return false\" title='show process list' class='button' style='width:85px;'>\n";
  354.  
  355. // Button for 'ps -aux --sort=size | tac' :)
  356. $psmem = "<input type='button' value='ps -aux (mem)' onClick=\"window.open('$scriptname?psmem=1', 'psmem', 'width=730, height=480, scrollbars, resizable'); return false\" title='show process list, sorted by memory usage' class='button' style='width:85px;'>\n";
  357.  
  358. // Buttons for vnstat:
  359. $vn_sampl = "<input type='button' value='Sample' onClick=\"window.open('$scriptname?cmd=vnstat4', 'vnstat', 'width=525, height=380, resizable'); return false\" class='button' title='sample current traffic - 5 second delay'>";
  360. $vn_days  = "<input type='button' value='Days'   onClick=\"window.open('$scriptname?cmd=vnstat2', 'vnstat', 'width=525, height=380, resizable'); return false\" class='button' title='show daily totals'>";
  361. $vn_mons  = "<input type='button' value='Months' onClick=\"window.open('$scriptname?cmd=vnstat3', 'vnstat', 'width=525, height=380, resizable'); return false\" class='button' title='show monthly totals'>";
  362.  
  363. // Buttons for netstat:
  364. $netstat_ntl = "<input type='button' value='Listening' onClick=\"window.open('$scriptname?cmd=netstat2', 'netstat', 'width=600, height=480, resizable'); return false\" class='button' title='show listening ports'>";
  365. $portslink   = "<input type='button' value='Port List' onClick=\"window.open('$scriptname?showports=1', 'portlist', 'width=300, height=330'); return false\" class='button' title='show explanatory list of ports'>";
  366.  
  367. // Button for mysqlreport:
  368. $mysqlrep_det = "<input type='button' value='Full Report' onClick=\"window.open('$scriptname?cmd=mysqlreport', 'mysqlreport', 'width=600, height=480, resizable'); return false\" class='button' title='show detailed mysqlreport'>";
  369.  
  370. // Auto-refresh meta tag:
  371.  
  372. if ($refresh) {
  373.     if ($refresh < 1) {
  374.         $refresh = 1;
  375.     }
  376.     $refresh = ($refresh * 60);
  377.     $meta_refresh = "<meta http-equiv=\"refresh\" content=\"$refresh\">\n";
  378. }
  379.  
  380. // Load bar indicators:
  381.  
  382. $pattern = "/^.*\b(average)\b.*$/mi";
  383. preg_match($pattern, $top, $hits);
  384. $loadline = $hits[0];
  385.  
  386. $load_bits = explode("average:",$loadline);
  387. $load_parts = explode(",",$load_bits[1]);
  388. $load1 = trim($load_parts[0]);
  389. $loadlabel1 = $load1;
  390. $load5 = trim($load_parts[1]);
  391. $loadlabel5 = $load5;
  392. $load15 = trim($load_parts[2]);
  393. $loadlabel15 = $load15;
  394.  
  395. if ($load1 > 10) {
  396.     $load1 = 10;
  397. }
  398. if ($load5 > 10) {
  399.     $load5 = 10;
  400. }
  401. if ($load15 > 10) {
  402.     $load15 = 10;
  403. }
  404.  
  405. if ($load1 > 1) {
  406.     $load1_width = round(($load1 - 1) * 22.22);
  407.     $bgcolor1 = "#82826E";
  408.     $fgcolor1 = "#CC0000";
  409. }
  410. else {
  411.     $load1_width = round($load1 * 200);
  412.     $bgcolor1 = "#222222";
  413.     $fgcolor1 = "#82826E";
  414. }
  415. if ($load5 > 1) {
  416.     $load5_width = round(($load5 - 1) * 22.22);
  417.     $bgcolor5 = "#82826E";
  418.     $fgcolor5 = "#CC0000";
  419. }
  420. else {
  421.     $load5_width = round($load5 * 200);
  422.     $bgcolor5 = "#222222";
  423.     $fgcolor5 = "#82826E";
  424. }
  425. if ($load15 > 1) {
  426.     $load15_width = round(($load15 - 1) * 22.22);
  427.     $bgcolor15 = "#82826E";
  428.     $fgcolor15 = "#CC0000";
  429. }
  430. else {
  431.     $load15_width = round($load15 * 200);
  432.     $bgcolor15 = "#222222";
  433.     $fgcolor15 = "#82826E";
  434. }
  435.  
  436. // If users, hyperlink 'User(s)' in top display:
  437.  
  438. if (!stristr($top,"0 users,")) {
  439.     $top = preg_replace("/(user|users),/", "<a href='$scriptname?users=1' onClick=\"window.open('$scriptname?users=1', 'users', 'width=625, height=300, scrollbars'); return false\" title='show users'>$1</a>,", $top);
  440. }
  441.  
  442. // Mytop/mysqlreport and vnstat ------------------------------------------------
  443. // Run or produce a useful message if not installed.
  444.  
  445. if ($mysql_mon == 1) {
  446.     exec("which mytop",$output,$return);
  447.     if ($return == 1) {
  448.      $mysql = "\n\nMytop is not installed. See the <a href='http://jeremy.zawodny.com/mysql/mytop/'>mytop website</a> for information.\n\n";
  449.      $mycmdlink = "";
  450.      $mysql_head = "";
  451.     }
  452.     elseif ($return == 0) {
  453.         $mysql = trim(`$mysql_com`);
  454.         $pattern = "/^.*\bQueries\b.*$/mi";
  455.         preg_match($pattern, $mysql, $hits);
  456.         $queryline = trim($hits[0]);
  457.         $my_parts = explode(" ",$queryline);
  458.     }
  459.     $mysql_div = "<div class='subleftcmd'>$mycmdlink</div><div class='subleft'>mytop</div><div class='left'><pre>$mysql</pre></div>\n";
  460. }
  461. elseif ($mysql_mon == 2) {
  462.     if (file_exists('mysqlreport') && is_executable('mysqlreport')) {
  463.         $mysql = trim(`$mysql_com`);
  464.         if (stristr($mysql,'uptime')) {
  465.             // Get total queries for topbar display
  466.             $parts = explode("_\n",$mysql);
  467.             $parts = explode("\n",$parts[2]);
  468.             $qline = preg_replace("/ {1,99}/", "|", $parts[0]);
  469.             $my_parts = explode('|',$qline);
  470.             // The 'Full report' button
  471.             $full_report = "\n<div class='toolbar'>$mysqlrep_det</div>";
  472.             // Change underscores to dashes for readability
  473.             $mysql = str_replace('_','-',$mysql);
  474.         }
  475.         elseif (stristr($mysql,'Access denied for user')) {
  476.             $mysql = "\n\nThe mysqlreport script was denied access to mysql. Check that the mysql username
  477. &amp; password (in the vpsinfo configuration) are valid.\n\n";
  478.             $mycmdlink = '';
  479.         }
  480.         elseif (stristr($mysql,'bad interpreter')) {
  481.             $mysql = "\n\nThe mysqlreport script encountered a problem -- the first line does not have the
  482. correct path for perl on your system.\n\n";
  483.             $mycmdlink = '';
  484.         }
  485.         else {
  486.             $mysql = "\n\nAn unknown error occurred with the mysqlreport script.\n\n";
  487.             $mycmdlink = '';
  488.         }
  489.     }
  490.     elseif (file_exists('mysqlreport')) {
  491.         $mysql = "\n\nThe mysqlreport script could not be executed. Check the file ownership &amp; permissions.\n\n";
  492.         $mycmdlink = '';
  493.     }
  494.     else {
  495.         $mysql = "\n\nThe mysqlreport script was not found.\n      
  496. You need to get it from <a href='http://hackmysql.com/mysqlreport'>http://hackmysql.com/mysqlreport</a>, store it in the same
  497. directory as vpsinfo, and set correct ownership &amp; permissions.\n\n";
  498.         $mycmdlink = '';
  499.     }
  500.     $mysql_div = "<div class='subleftcmd'>$mycmdlink</div><div class='subleft'>mysqlreport</div>
  501.     <div class='left'><pre>$mysql</pre></div>$full_report\n";
  502. }
  503.    
  504. if ($my_parts) {
  505.     if (is_numeric($my_parts[1])) {
  506.         $mysql_queries = round($my_parts[1]);
  507.         $mysql_units = "";
  508.     }
  509.     else {
  510.         $mysql_units = strtoupper(substr($my_parts[1],-1));
  511.         if ($mysql_units == "M") {
  512.             $mysql_queries = round(substr($my_parts[1],0,-1),2);
  513.         }
  514.         if ($mysql_units == "K") {
  515.             $mysql_queries = round(substr($my_parts[1],0,-1));
  516.         }
  517.     }
  518.     $mysql_head = "<td valign='top' nowrap><div class='head_label' style='padding-right:5px' title='number of mysql queries'>mysql queries</div><div class='head_num2' style='padding-right:5px'>$mysql_queries<span class='head_units'> $mysql_units</span></div></td>";
  519. }
  520.  
  521. if ($vnstat) {
  522.     exec("which vnstat",$output,$return);
  523.     if ($return == 1) {
  524.      $vnstat = "\n\nVnstat is not installed. See the <a href='http://humdi.net/vnstat/'>vnstat website</a> for information.\n\n";
  525.         $vncmdlink=''; $vn_sampl=''; $vn_days=''; $vn_mons='';
  526.         $vnstat_div = "<div class='subleft'>vnstat</div><div class='left'><pre>$vnstat</pre></div>";
  527.     }
  528.     elseif ($return == 0) {
  529.         $vnstat = trim(`$vnstat_com`);
  530.         $pattern = "/^.*\btoday\b.*$/mi";
  531.         preg_match_all($pattern, $vnstat, $hits);
  532.         $todayline = $hits[0][0];
  533.         $today = explode("|",$todayline);
  534.         $today_mb = str_replace(" MB","",$today[2]);
  535.         $today_mb = trim($today_mb);
  536.         if (stristr($today_mb,",")) {
  537.             $today_mb = str_replace(",","",$today_mb);
  538.         }
  539.         $today_mb = round($today_mb);
  540.         if ($today_mb > 999) {
  541.             $bw_today = round(($today_mb / 1024),1);
  542.             $bw_units = "GB";
  543.         }
  544.         else {
  545.             $bw_today = $today_mb;
  546.             $bw_units = "MB";
  547.         }
  548.         if ($today_mb > $bw_alert) {
  549.             $bw_today = "<span class='warn'>$bw_today</span>";
  550.         }
  551.         $vnstat_head = "<td valign='top' nowrap><div class='head_label' title='amount of data transferred today'>transfer today</div><div class='head_num'>$bw_today<span class='head_units'> $bw_units</span></div></td>
  552.     ";
  553.         $vnstat_div = "<div class='subleftcmd'>$vncmdlink</div><div class='subleft'>vnstat</div><div class='leftscroll'><pre>$vnstat</pre></div>
  554.         <div class='toolbar'>$vn_sampl $vn_days $vn_mons</div>";
  555.     }
  556. }
  557. // vpsstat-like processing of user_beancounters or RAM & swap -----------------
  558.  
  559. list($vpsstat,$mem1,$mem1_units,$mem1_label,$mem1_tip,$mem2,$mem2_units,$mem2_label,$mem2_tip) = vpsstat();
  560. if ($vpsstat) {
  561.     $vpsstat_div = "<div class='subleftcmd'>$vpscmdlink</div><div class='subleft'>vpsstat</div><div class='left'><pre>$vpsstat</pre></div>\n";
  562. }
  563.  
  564. // Process/daemon monitor -----------------------------------------------------
  565.  
  566. $allprocs = explode(" ", $processes);
  567. foreach ($allprocs as $proc) {
  568.     $proc = trim($proc);
  569.     if (stristr($allps,$proc)) {
  570.         $tcpstatus .= "<span class='servup' title='$proc is up'>&nbsp;$proc&nbsp;</span>&nbsp;";
  571.     }
  572.     else {
  573.         $tcpstatus .= "<span class='servdown' title='$proc is down!'>&nbsp;$proc&nbsp;</span>&nbsp;";  
  574.     }
  575. }
  576.  
  577. // FUNCTIONS ==================================================================
  578.  
  579. function netstat($netstat_com) {
  580.     $out = trim(`$netstat_com`);
  581.     $out = str_replace(" Address","_Address",$out);
  582.     $lines = explode("\n",$out);
  583.     for ($i=0; $i<count($lines); $i++) {
  584.         if ($i > 0) {
  585.             $line = preg_replace("/ {1,99}/", "|", $lines[$i]);
  586.             $line = str_replace("::ffff:","",$line);
  587.             $parts = explode("|",$line);
  588.             $col_0 = str_pad($parts[0], 5, " ", STR_PAD_RIGHT);
  589.             $col_1 = str_pad($parts[1], 6, " ", STR_PAD_LEFT);
  590.             $col_2 = str_pad($parts[2], 6, " ", STR_PAD_LEFT);
  591.             $col_3 = str_pad($parts[3], 23, " ", STR_PAD_RIGHT);
  592.             if (stristr($parts[4],":")) {
  593.                 $col_4_parts = explode(":",$parts[4]);
  594.                 $ip_str = $col_4_parts[0];
  595.             }
  596.             $col_4 = str_pad($parts[4], 23, " ", STR_PAD_RIGHT);
  597.             if ($ip_str) {
  598.                 $link = "<a href='$scriptname?whois=$ip_str' onClick=\"window.open('$scriptname?whois=$ip_str', 'netstat', 'width=650, height=350, resizable, scrollbars'); return false\" title='whois $ip_str'>$ip_str</a>";
  599.                 $col_4 = str_replace($ip_str,$link,$col_4);
  600.             }
  601.             $col_5 = $parts[5];
  602.             $cols  = $col_0." ".$col_1." ".$col_2." ".$col_3." ".$col_4." ".$col_5;
  603.         }
  604.         else {
  605.             $cols = $lines[$i];
  606.         }
  607.         $all .= "\n" . $cols;
  608.     }
  609.     $all = str_replace("_Address"," Address",$all);
  610.     return $all;
  611. }
  612. function poppage($cmd,$out,$meta,$reload,$shorttime,$buttons,$title) {
  613.     echo "
  614.     <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
  615.     <html>
  616.     <head>
  617.     <title>$cmd</title>
  618.     $meta
  619.     <style type='text/css'>
  620.         html, body {
  621.             width: 100%;
  622.             height: 100%;
  623.             overflow: hidden;
  624.         }
  625.         body {
  626.             background-color: #000000;
  627.             color: #CCCCCC;
  628.             margin: 0;
  629.             padding: 0;
  630.         }
  631.         #scroll {
  632.             clear: both;
  633.             overflow: auto;
  634.             border: none;
  635.             margin: 0;
  636.             padding: 0;
  637.             overflow-Y: auto;
  638.             overflow-X: visible;
  639.             scrollbar-face-color: #666666;
  640.             scrollbar-track-color: #999999;
  641.             scrollbar-3dlight-color: #999999;
  642.             scrollbar-highlight-color: #666666;
  643.         }
  644.         pre {
  645.             font-family: vt7X13,\"Courier New\",Courier,monospace;
  646.             font-size: 11px;
  647.             line-height: 14px;
  648.             padding: 5px 5px 10px 6px;
  649.             margin: 0;
  650.         }
  651.         div.title {
  652.             float: left;
  653.             font-family: Verdana,Arial,Helvetica,sans-serif;
  654.             background-color: #333333;
  655.             color: #DDDDDD;
  656.             font-size: 13px;
  657.             font-weight: bold;
  658.             padding: 4px 0 2px 6px;
  659.         }
  660.         div.commands {
  661.             font-family: Verdana,Arial,Helvetica,sans-serif;
  662.             background-color: #333333;
  663.             text-align: right;
  664.             font-size: 13px;
  665.             padding: 4px 10px 5px 0;
  666.             border-bottom: 1px solid #666666;
  667.         }
  668.         .button {
  669.             width: 60px;
  670.             font-size: 11px;
  671.             border: 1px solid #999999;
  672.             background-color: #666666;
  673.             color: #FFFFFF;
  674.         }
  675.         a:link, a:visited, a:active {
  676.             color: #BBBB00;
  677.             text-decoration: none;
  678.         }
  679.     </style>
  680.     <script language='javascript'>
  681.     function fullHgt() {
  682.         if (document.getElementById('scroll')) {
  683.             var hgt = document.body.clientHeight - 27;
  684.             document.getElementById('scroll').style.height=hgt+'px';
  685.         }
  686.     }
  687.     </script>
  688.  
  689.     </head>
  690.     <body onLoad='fullHgt()' onResize='fullHgt()'>
  691.     <div class='title'>$title @ $shorttime</div>
  692.     <div class='commands'>$buttons </div>
  693.     <div id='scroll'><pre>$out</pre></div>
  694.    
  695.     </body>\n</html>";
  696. }
  697.  
  698. function vpsstat() {
  699.     $rawbeans = `/bin/beanc 2> /dev/null`;
  700.     if (!$rawbeans) {
  701.         if (file_exists('/proc/user_beancounters')) {
  702.             $rawbeans = `cat /proc/user_beancounters 2> /dev/null`;
  703.         }
  704.         else {
  705.             $ded=TRUE;
  706.         }
  707.     }
  708.     if ($rawbeans) {
  709.         $lines = explode("\n", $rawbeans);
  710.         for ($i=0; $i<count($lines); $i++) {
  711.             if (preg_match("/oomg|privv|numpr|numt|numo|numfi/",$lines[$i])) {
  712.                 $line = preg_replace("/ {1,99}/", "|", $lines[$i]);
  713.                 $line_parts = explode("|",$line);
  714.                 if (stristr($lines[$i],"oomg") || stristr($lines[$i],"privv")) {
  715.                     $cur = round($line_parts[2] / 256, 1) . " MB";
  716.                     $rec = round($line_parts[3] / 256, 1) . " MB";
  717.                     $bar = round($line_parts[4] / 256) . " MB";
  718.                     if (stristr($lines[$i],"oomg")) {
  719.                         $lim = "n/a";
  720.                         $mem1 = round($cur);
  721.                         if ($mem1 > $bar) {
  722.                             $mem1 = "<span class='warn'>$mem1</span>";
  723.                         }
  724.                         $mem1_label = "oomguarpages";
  725.                         $oomg_per = round($mem1 / $bar * 100);
  726.                         $mem1_tip = "title='oomguarpages is guaranteed memory; you are using $oomg_per% of your quota'";
  727.                         $mem1_units = "MB";
  728.                     }
  729.                     else {
  730.                         $lim = round($line_parts[5] / 256) . " MB";
  731.                         $mem2 = round($cur);
  732.                         $mem2_label = "privvmpages";
  733.                         $pmg_per = round($mem2 / $lim * 100);
  734.                         $mem2_tip = "title='privvmpages is burstable memory; you are using $pmg_per% of your limit'";
  735.                         $mem2_units = "MB";
  736.                     }
  737.                 }
  738.                 else {
  739.                     $cur = $line_parts[2];
  740.                     $rec = $line_parts[3];
  741.                     $bar = "n/a";
  742.                     $lim = $line_parts[5];
  743.                 }
  744.                 $beans .= str_pad($line_parts[1],12) . str_pad($cur, 12, " ", STR_PAD_LEFT) .str_pad($rec, 12, " ", STR_PAD_LEFT) . str_pad($bar, 12, " ", STR_PAD_LEFT) . str_pad($lim, 12, " ", STR_PAD_LEFT) . str_pad($line_parts[6], 12, " ", STR_PAD_LEFT) . "\n";
  745.             }
  746.         }
  747.         $parts = explode("\n",$beans);
  748.         $vpsstat  = "Resource         Current  Recent Max     Barrier       Limit    Failures\n";
  749.         $vpsstat .= "------------  ----------  ----------  ----------  ----------  ----------\n";
  750.         $vpsstat .= "$parts[2]\n$parts[0]\n$parts[1]\n$parts[3]\n$parts[4]\n$parts[5]";
  751.     }
  752.     if (!$vpsstat && $ded==FALSE) {
  753.         $vpsstat = "\n         
  754. It seems you're running Virtuozzo 3 or OpenVZ. In order to read the VPS stats
  755. (beancounters) you need a small 'helper' app. To install it do the following at
  756. a shell prompt as root:
  757.  
  758. [root@vps] wget http://www.labradordata.ca/downloads/install_beanc.sh
  759. [root@vps] sh install_beanc.sh\n\n";
  760.     }
  761.     elseif ($ded==TRUE) {
  762.         $free = `free`;
  763.         if ($free) {
  764.             $pattern = "/^.*\bMem\b.*$/mi";
  765.             preg_match($pattern, $free, $hits);
  766.             $memline = $hits[0];
  767.             $memline = preg_replace("/ {1,99}/", "|", $memline);
  768.             $parts = explode("|",$memline);
  769.             $kbytes = $parts[3];
  770.             $mbytes = round($kbytes / 1024);
  771.             if ($mbytes > 999) {
  772.                 $mem1 = round(($mbytes / 1024),1);
  773.                 $mem1_units = "GB";
  774.             }
  775.             else {
  776.                 $mem1 = $mbytes;
  777.                 $mem1_units = "MB";
  778.             }
  779.             $mem1_label = "free RAM";
  780.             $mem1_tip = "title='amount of free memory'";
  781.             $pattern = "/^.*\bSwap\b.*$/mi";
  782.             preg_match($pattern, $free, $hits);
  783.             $memline = $hits[0];
  784.             $memline = preg_replace("/ {1,99}/", "|", $memline);
  785.             $parts = explode("|",$memline);
  786.             $kbytes = $parts[2];
  787.             $mbytes = round($kbytes / 1024);
  788.             if ($mbytes > 999) {
  789.                 $mem2 = round(($mbytes / 1024),1);
  790.                 $mem2_units = "GB";
  791.             }
  792.             else {
  793.                 $mem2 = $mbytes;
  794.                 $mem2_units = "MB";
  795.             }
  796.             $mem2_label = "swap used";
  797.             $mem2_tip = "title='amount of swap space currently used'";
  798.         }
  799.     }
  800.     return array($vpsstat,$mem1,$mem1_units,$mem1_label,$mem1_tip,$mem2,$mem2_units,$mem2_label,$mem2_tip);
  801. }
  802.  
  803. $mtime = explode (" ", microtime());
  804. $tend = $mtime[0] + $mtime[1];
  805. $totaltime = round(($tend - $tstart),4);
  806. $pagegen = "page generated in $totaltime sec.";
  807.  
  808. // MAIN PAGE OUTPUT ===========================================================
  809.  
  810. if ($gzip) {
  811.     ini_set('zlib.output_compression_level', 1);
  812.     ob_start("ob_gzhandler");
  813. }
  814. header("Cache-Control: no-cache, must-revalidate");
  815. header('Pragma: no-cache');
  816. ?>
  817. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  818. <html>
  819. <head>
  820. <?=$meta_refresh?>
  821. <style type ='text/css'>
  822. BODY {
  823.     font-family: Verdana,Arial,Helvetica,sans-serif;
  824.     background-color: #31311B;
  825.     color: #CCCCCC;
  826.     margin: 5px 5px 30px 5px;
  827.     padding: 0;
  828. }
  829.  
  830. /* General layout ---------------------------- */
  831.  
  832. div.space {
  833.     font-size: 1px;
  834.     height: 3px;
  835. }
  836. td.head {
  837.     border: 1px solid #666666;
  838.     background-color: #000000;
  839. }
  840. td.tdleft {
  841. }
  842. td.tdright {
  843.     padding-left: 5px;
  844. }
  845.  
  846. /* Header section ---------------------------- */
  847.  
  848. div.hostname {
  849.     font-size: 16px;
  850.     font-weight: bold;
  851.     color: #DDDDDD;
  852.     padding: 2px 0 2px 5px;
  853. }
  854. div.date {
  855.     font-size: 13px;
  856.     font-weight: bold;
  857.     color: #DDDDDD;
  858.     padding: 0 0 2px 5px;
  859. }
  860. div.head_label {
  861.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  862.     font-size: 11px;
  863.     padding-left: 13px;
  864.     text-align: right;
  865.     cursor: help;
  866. }
  867. div.head_num {
  868.     font-size: 22px;
  869.     padding-left: 13px;
  870.     padding-right: 1px;
  871.     text-align: right;
  872. }
  873. div.head_num2 {
  874.     font-size: 18px;
  875.     padding-left: 13px;
  876.     padding-right: 1px;
  877.     text-align: right;
  878. }
  879. .head_units {
  880.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  881.     font-size: 10px;
  882.     vertical-align : super;
  883. }
  884. div.head_sum {
  885.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  886.     font-size: 11px;
  887.     padding: 1px 5px 2px 0;
  888.     text-align: right;
  889. }
  890. /* Service monitoring in the header */
  891. div.servstatus {
  892.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  893.   font-size: 11px;
  894.     background-color: #333333;
  895.     padding: 2px 0 2px 2px;
  896. }
  897. span.servup {
  898.     background-color: #004000;
  899.     color: #CCCCCC;
  900.     cursor: help;
  901. }
  902. span.servdown {
  903.     background-color: #CC0000;
  904.     color: #FFFFFF;
  905.     cursor: help;
  906. }
  907. div.disk {
  908.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  909.     font-size: 11px;
  910.     text-align: right;
  911.     background-color: #333333;
  912.     padding: 2px 5px 2px 0;
  913. }
  914. .warn {
  915.     background-color: #CC0000;
  916. }
  917. /* Load bars */
  918. div.load_label {
  919.     height: 12px;
  920.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  921.     font-size: 11px;
  922.     color: #CCCCCC;
  923.     line-height: 11px;
  924.     text-align: right;
  925.     cursor: help;
  926. }
  927. div.load_bg {
  928.     font-size: 2px;
  929.     height: 10px;
  930.     width: 200px;
  931.     cursor: help;
  932. }
  933. div.load_fg {
  934.     height: 10px;
  935. }
  936.  
  937. /* Box layouts ------------------------------- */
  938.  
  939. div.subleft,div.subright {
  940.     font-size: 13px;
  941.     font-weight: bold;
  942.     background-color: #333333;
  943.     color: #DDDDDD;
  944. }
  945. div.subleft {
  946.     width: auto;
  947.     border: 1px solid #666666;
  948.     border-bottom: none;
  949.     margin-top: 5px;
  950.     padding: 0 0 3px 6px;
  951. }
  952. div.subright {
  953.     width: auto;
  954.     border: 1px solid #666666;
  955.     border-bottom: none;
  956.     margin-top: 5px;
  957.     padding: 0 0 3px 6px;
  958. }
  959. div.left {
  960.     clear: right;
  961.     margin: 0;
  962.     background-color: #000000;
  963.     border: 1px solid #666666;
  964.     border-top: none;
  965. }
  966. div.leftscroll {
  967.     clear: right;
  968.     height: 230px;
  969.     overflow: auto;
  970.     margin-right: -1px;
  971.     background-color: #000000;
  972.     border: 1px solid #666666;
  973.     border-bottom: 1px solid #444444;
  974.     border-top: none;
  975.     /* IE-specific hacks */
  976.     overflow-Y: auto;
  977.     overflow-X: visible;
  978.     scrollbar-face-color: #666666;
  979.     scrollbar-track-color: #999999;
  980.     scrollbar-3dlight-color: #999999;
  981.     scrollbar-highlight-color: #666666;
  982. }
  983. div.right,div.toolbar,div.toolbar_left {
  984.     width: auto;
  985.     background-color: #000000;
  986.     border: 1px solid #666666;
  987.     border-top: none;
  988. }
  989. div.toolbar {
  990.     border-top: none;
  991.     padding: 3px 5px 4px 0;
  992.     text-align: right;
  993. }
  994. div.toolbar_left {
  995.     border-top: none;
  996.     padding: 3px 0 4px 5px;
  997.     text-align: left;
  998. }
  999.    
  1000. /* Box buttons to command windows */
  1001.  
  1002. div.subleftcmd {
  1003.     text-align: right;
  1004.     font-size: 10px;
  1005.     line-height: 14px;
  1006.     float: right;
  1007.     margin-top: 5px;
  1008.     margin-right: 0px;
  1009.     padding-bottom: 1px;
  1010.     border: 1px solid #777777;
  1011.     border-top: none;
  1012.     border-right: none;
  1013.     background-color: #666666;
  1014. }
  1015. /* Box button links: "+" */
  1016.  
  1017. a:link.open, a:visited.open,a:active.open {
  1018.     color: #EEEEEE;
  1019. }
  1020.  
  1021. /* Whois lookup */
  1022.  
  1023. .whois_title {
  1024.     font-size: 13px;
  1025.     font-weight: bold;
  1026.     color: #BBBBBB;
  1027. }
  1028. form.whois {
  1029.     margin: 0;
  1030.     padding: 0;
  1031. }
  1032. input.whois_input {
  1033.     width: 150px;
  1034.     font-family: vt7X13,"Courier New",Courier,monospace;
  1035.     font-size: 11px;
  1036.     line-height: 13px;
  1037.     border: 1px solid #999999;
  1038.     background-color: #CCCCCC;
  1039. }
  1040. input.button {
  1041.     width: 65px;
  1042.     font-family: Tahoma,"MS Sans Serif",Arial,Helvetica,sans-serif;
  1043.     font-size: 11px;
  1044.     border: 1px solid #999999;
  1045.     background-color: #666666;
  1046.     color: #FFFFFF;
  1047.     cursor: pointer;
  1048. }
  1049.  
  1050. /* Content formatting ------------------------ */
  1051.  
  1052. pre {
  1053.     font-family: vt7X13,"Courier New",Courier,monospace;
  1054.     font-size: 11px;
  1055.     line-height: 14px;
  1056.     padding: 5px 5px 10px 6px;
  1057.     margin: 0;
  1058. }
  1059. a:link, a:visited, a:active {
  1060.     color: #BBBB00;
  1061.     text-decoration: none;
  1062. }
  1063. div.note {
  1064.     font-size: 11px;
  1065.     font-style: italic;
  1066.     padding: 5px 0 0 5px;
  1067. }
  1068. div.sig {
  1069.     font-size: 11px;
  1070.     color: #999999;
  1071.     padding: 25px 0 0 0;
  1072.     text-align: center;
  1073. }
  1074. </style>
  1075. <title><?=$hostname?> : vpsinfo</title>
  1076. </head>
  1077.  
  1078. <body>
  1079.  
  1080. <table width='100%' cellspacing=0 cellpadding=0 border=0>
  1081.  
  1082. <tr>
  1083. <td class='head'>
  1084.  
  1085. <table width='100%' cellspacing=0 cellpadding=0 border=0>
  1086. <tr>
  1087. <td><div class='servstatus'><?=$tcpstatus?></div></td>
  1088. <td align='right'><div class='disk'>Disk Usage: <?=$allfs?></div></td>
  1089. </tr>
  1090. </table>
  1091.  
  1092. <table width='100%' cellspacing=0 cellpadding=0 border=0>
  1093. <tr>
  1094. <td valign='top' nowrap><div class='hostname'><?=$hostname?></div><div class='date'><?=$localtime?></div></td>
  1095. <td><div style='padding-left:20px'>
  1096.     <table cellspacing=0 cellpadding=0 border=0>
  1097.     <tr>
  1098.     <td nowrap><div class='load_label' title='load average during last 1 minute'><?=$loadlabel1?>&nbsp;</div></td>
  1099.     <td>
  1100.     <div class='load_bg' style='background-color: <?=$bgcolor1?>' title='load average during last 1 minute'>
  1101.     <div class='load_fg' style='width: <?=$load1_width?>px; background-color: <?=$fgcolor1?>'>&nbsp;</div>
  1102.     </div>
  1103.     </td>
  1104.     </tr>
  1105.     <tr>
  1106.     <td nowrap><div class='load_label' title='load average during last 5 minutes'><?=$loadlabel5?>&nbsp;</div></td>
  1107.     <td>
  1108.     <div class='load_bg' style='background-color: <?=$bgcolor5?>' title='load average during last 5 minutes'>
  1109.     <div class='load_fg' style='width: <?=$load5_width?>px; background-color: <?=$fgcolor5?>'>&nbsp;</div>
  1110.     </div>
  1111.     </td>
  1112.     </tr>
  1113.     <tr>
  1114.     <td nowrap><div class='load_label' title='load average during last 15 minutes'><?=$loadlabel15?>&nbsp;</div></td>
  1115.     <td>
  1116.     <div class='load_bg' style='background-color: <?=$bgcolor15?>' title='load average during last 15 minutes'>
  1117.     <div class='load_fg' style='width: <?=$load15_width?>px; background-color: <?=$fgcolor15?>'>&nbsp;</div>
  1118.     </div>
  1119.     </td>
  1120.     </tr>
  1121.     </table>
  1122. </div></td>
  1123. <td valign='top' nowrap><div class='head_label' <?=$mem1_tip?>><?=$mem1_label?></div><div class='head_num'><?=$mem1?><span class='head_units'> <?=$mem1_units?></span></div></td>
  1124. <td valign='top' nowrap><div class='head_label' <?=$mem2_tip?>><?=$mem2_label?></div><div class='head_num'><?=$mem2?><span class='head_units'> <?=$mem2_units?></span></div></td>
  1125. <?=$vnstat_head?>
  1126. <td valign='top' nowrap><div class='head_label' title='number of current TCP connections'>tcp conn</div><div class='head_num2'><?=$num_tcp?></div></td>
  1127. <td valign='top' nowrap><div class='head_label' title='number of apache processes and threads'>apache thds</div><div class='head_num2'><?=$num_httpd?></div></td>
  1128. <td valign='top' nowrap><div class='head_label' title='number of mysql processes and threads'>mysql thds</div><div class='head_num2'><?=$num_mysql?></div></td>
  1129. <?=$mysql_head?>
  1130. <td width='25%'><div class='space'>&nbsp;</div></td>
  1131. </tr>
  1132. </table>
  1133.  
  1134. </td>
  1135. </tr>
  1136. </table>
  1137.  
  1138. <table width='100%' cellspacing=0 cellpadding=0 border=0 style='margin-top: -3px'>
  1139. <tr>
  1140. <td><div class='space' style='width:<?=$leftcol?>px'>&nbsp;</div></td>
  1141. <td width='50%'><div class='space'></td>
  1142. </tr>
  1143. <tr>
  1144. <td valign='top' class='tdleft'><div class='subleftcmd'><?=$topcmdlink?></div><div class='subleft'> top</div><div class='leftscroll'><pre><?=$top?></pre></div>
  1145. <div class='toolbar'><?=$psaux?> <?=$psmem?></div>
  1146.  
  1147. <?=$vpsstat_div?>
  1148. <div class='subleftcmd'><?=$netcmdlink?></div><div class='subleft'><?=$netstat_com?></div><div class='leftscroll'><pre><?=$netstat?></pre></div>
  1149. <div class='toolbar_left'><table width='100%' cellspacing=0 cellpadding=0 border=0><tr><td><form method='post' action='<?=$scriptname?>' class='whois' name='whois_form'><span class='whois_title'>Whois: </span><input type='text' name='whois' class='whois_input' title='enter an IP address or domain'> <input type='submit' value='Lookup' class='button' title='do the lookup' onClick="javascript: if (whois_form.whois.value=='') { alert('Please enter an IP address or domain');return false; }"> <input type='reset' name='clear' value='Clear' class='button' title='clear the entry'></form></td><td align='right' style='padding-right:5px'><?=$netstat_ntl?> <?=$portslink?></td></tr></table></div>
  1150. <?=$vnstat_div?>
  1151. <?=$mysql_div?></td>
  1152. <td valign='top' class='tdright'><div class='subright'>pstree</div><div class='right'><pre><?=$pstree?></pre></div>
  1153. <div class='subright'>ls -a /tmp</div><div class='right' style='border-bottom:1px solid #444444'><div class='note'>Ignoring PHP session files (sess_*)</div><pre><?=$tmp_full?></pre></div>
  1154. <div class='toolbar_left'><?=$lsal?></div></td>
  1155. </tr>
  1156.  
  1157. </table>
  1158.  
  1159. <div class='sig'><a href='http://www.labradordata.ca/vpsinfo/'>vpsinfo</a> <?=$version?> by Douglas Robbins<br><?=$pagegen?><br>comments &amp; suggestions always welcome: <a href='http://www.labradordata.ca/home/email=4'>email</a></div>
  1160.  
  1161. </body>
  1162. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement