Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Web-based system info
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Sun Jan 05, 2003 11:02 pm    Post subject: Web-based system info Reply with quote

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(" ", "&nbsp;", `$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
View user's profile Send private message
mezz
Tux's lil' helper
Tux's lil' helper


Joined: 01 Jun 2002
Posts: 111

PostPosted: Mon Jan 06, 2003 3:49 am    Post subject: Reply with quote

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
View user's profile Send private message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Mon Jan 06, 2003 4:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
xedx
Tux's lil' helper
Tux's lil' helper


Joined: 23 May 2003
Posts: 93

PostPosted: Fri Jun 13, 2003 6:41 am    Post subject: Reply with quote

your script really is better, easier to modify also: )
_________________
--+//+
Back to top
View user's profile Send private message
dylix
Apprentice
Apprentice


Joined: 20 Sep 2002
Posts: 261
Location: Atlanta

PostPosted: Sun Jun 15, 2003 1:41 pm    Post subject: Reply with quote

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..
_________________

Rape is such a strong word, I prefer surprise sex.
http://plutonic.mine.nu/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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