| | |
Simple server stats
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
This is a very simple statistics script that provides for services on/offline, memory info, server load averages and uptime and lastly drive info.
Its easily customised and i have usef <font> alot where you could have set come css and have it all done easily and look a bit more tidy than mine.
Its easily customised and i have usef <font> alot where you could have set come css and have it all done easily and look a bit more tidy than mine.
<? // Set the services you want the script to check. // You can add more by just adding a line "servers name"=>"host/IP:port number", // You can use game servers or anything. // e.g. "IRCdaemon"=>"localhost:6667", $services = array( "http"=>"localhost:80", "ssh"=>"localhost:22", // "telnet"=>"localhost:23", "ftp"=>"localhost:21", // "smtp"=>"localhost:25", "pop3"=>"localhost:110", "mysql"=>"localhost:3306" ); // Variables at the top of the page, date, uptime etc. $date = date("l, M d, Y - h:i:s A"); $version = `uname -sr`; $name = `hostname`; $uptime = `uptime`; // df command function, formatted into a table function output_df() { $disk = `df`; $lines = split("\n", $disk); echo "<table border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">"; for ($i = 0; $i < sizeof($lines) && strlen($lines[$i]) > 1; $i++) { $cols = preg_split("/[\s]+/", $lines[$i]); if ($i == 0) echo "<tr bgcolor=\"black\"><font color=orange>"; else echo "<tr>"; for ($j = 0; $j < 6; $j++) { if ($j == 0 || $j == 5) $align = "left"; else if ($j == 1 || $j == 2 || $j == 3) $align = "right"; else if ($j == 4) $align = "center"; echo "<td align=$align> <font face=\"Verdana\" size=\"1\" color=\"orange\">$cols[$j]</font> </td>"; } echo "</font></tr>"; } echo "</table>"; } // free comand function, formatted into a table function output_free() { $free = `free`; $lines = split("\n", $free); echo "<table border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">"; for ($i = 0; $i < sizeof($lines) && strlen($lines[$i]) > 1; $i++) { if ($i == 2) $i++; $cols = preg_split("/[\s]+/", $lines[$i]); if ($i == 0) echo "<tr bgcolor=\"black\">"; else echo "<tr>"; foreach ($cols as $data) echo "<td align=right> <font face=\"Verdana\" size=\"1\" color=\"orange\">$data</font> </td>"; echo "</tr>"; } echo "</table>"; } // info grabbind done, onto the html ?> <table border="0" align="center" cellpadding="1" cellspacing="0"> <tr><td> <p><font face="Verdana" size="1"><b>System Status:</b> <? echo $name ?><br><b>Time:</b> <? echo $date ?></font></p> <font face="Verdana" size="1"> <? echo $version ?><br> <? echo $uptime ?> <p><table> <b>Services:</b><br> <tr bgcolor="black"><td><font face="Verdana" size="1" color="orange">Status</font></td><td><font face="Verdana" size="1" color="orange">Service</font></td><td><font face="Verdana" size="1" color="orange">Host</font></td></tr> <? foreach ($services as $name=>$location) { list($host, $port) = split(":",$location); $running = fsockopen($host, $port, $errno, $errstr, 30); if (!$running) $status_color = "red"; else { fclose($running); $status_color = "green"; } echo "<tr><td align=center><div align=\"center\" style=\"font-size: 13pt; color: $status_color\" width=\"15\" height=\"15\"><b>?</b></div></td><td><font face=\"Verdana\" size=\"1\">$name</font></td><td><font face=\"Verdana\" size=\"1\">$host</font></td></tr>"; } ?> </table></p> <b>Memory:</b><br> <? output_free(); ?><br> <b>Drive Info:</b><br> <? output_df(); ?> </font> </td></tr></table>
Similar Threads
- Simple Chat Server (Java)
- Help with simple C++ server? (C++)
- Simple server problem (Python)
- help with simple server prog (C)
- Displaying XML on HTML page, Server Stats to be complete (RSS, Web Services and SOAP)
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode up-to-date update upload url validator variable video web xml youtube



