View previous topic :: View next topic |
Author |
Message |
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Sun Jan 05, 2003 11:02 pm Post subject: Web-based system info |
|
|
Have mod_php installed and want to get output from informational commands on a web server? How about getting the commands in a pretty format, vaguely resembling a standard Gentoo terminal? Then you might want to keep this PHP source handy:
Code: | <?php $hostname = `hostname`; ?><html>
<head>
<title><?php echo $hostname ?></title>
</head>
<body>
<p><font face="Lucida Console,Courier New,Courier" size="+3"><b><?php echo $hostname; ?></b></font></p>
<p><font face="Tahoma,Verdana,Arial,sans-serif">Here, have some system information:</font></p>
<table width="100%" cellpadding="8"><tr><td bgcolor=\"#000000\">
<p><font face="Lucida Console,Courier New,Courier"><?php
function sys($cmd)
{
static $host = NULL, $whoami = NULL;
if (!isset($host)) list($host) = explode('.', $GLOBALS['hostname']);
if (!isset($whoami)) list($whoami) = explode("\n", `whoami`);
echo "<font color=\"#54FF54\">$whoami@$host</font> <font color=\"#5454FF\">$whoami \$</font> <font color=\"#B2B2B2\">$cmd";
echo str_replace("\n", "<br />\n", "\n".str_replace(" ", " ", `$cmd 2>&1`)."\n")."</font>";
}
sys("hostname");
sys("uptime");
sys("free");
sys("uname -a");
sys("ifconfig eth0");
sys("cat /proc/cpuinfo");
sys("ping -c 3 '".$_SERVER['REMOTE_ADDR']."'");
?></font></p>
</td></tr></table>
</body>
</html> |
This displays the hostname, uptime, memory info, running kernel, stats on the network interface, CPU information, and round-trip times for three pings to the client. It spawns a bunch of extra processes and thus may very well bog down older hardware. Customization is easy: add or remove sys() calls as necessary, but remember that the client is not to be trusted.
Oh, and to see what this looks like, see here. (That's output from sourceforge.net, if you're wondering.)
[edit] Added $whoami to auto-detect username [/edit]
[edit] Added hostname to top of page and changed colors to match Konsole defaults [/edit] _________________ I don't believe in witty sigs. |
|
Back to top |
|
|
mezz Tux's lil' helper
Joined: 01 Jun 2002 Posts: 111
|
Posted: Mon Jan 06, 2003 3:49 am Post subject: |
|
|
Hey, you might want to check http://phpsysinfo.sourceforge.net .. I still using your vhost shell scripts that I got from your another post.. |
|
Back to top |
|
|
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Mon Jan 06, 2003 4:21 pm Post subject: |
|
|
Well, yeah, you can go phpSysInfo but this script gives you a Gentoo-looking console and lets you see whatever the heck you want easily. _________________ I don't believe in witty sigs. |
|
Back to top |
|
|
xedx Tux's lil' helper
Joined: 23 May 2003 Posts: 93
|
Posted: Fri Jun 13, 2003 6:41 am Post subject: |
|
|
your script really is better, easier to modify also: ) _________________ --+//+ |
|
Back to top |
|
|
dylix Apprentice
Joined: 20 Sep 2002 Posts: 261 Location: Atlanta
|
Posted: Sun Jun 15, 2003 1:41 pm Post subject: |
|
|
another tip: if its slowing down your machine alot, you could always throw it in your crontab. and have it write the output to a file.. _________________
https://dylix.org/
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|