Web Hosting Talk







View Full Version : display server info


mjfroggy
01-22-2006, 10:01 AM
Hello,

I am looking for a detailed tutorial or site to explain how to display server stats.
For example like the amount of Ram, OS, serveruptime and hdd space aloted to a specific user. sort of like some of the info displayed in the cpanel main page. I know some tags that display a bunch of server info but then I do not know how to take out and display only the specific things I want to display. So I need a tutorial.

can anyone help

thanks

thomas7
01-22-2006, 10:42 AM
Not sure about a tutorial, but all you need to do is run a few server commands from your script, and read a few files.
You may need to allow the user you run from script from access to certain commands with suexec etc.

Look here:
cat /proc/cpuinfo
cat /proc/meminfo
uname
uptime
df

Then just split them up. If you use perl, you could use the SPLIT command, or a regex.

shockuk
01-22-2006, 11:36 AM
phpSysInfo does what you need: http://phpsysinfo.sourceforge.net/

Try reading over the code and you may figure out how it works.

mjfroggy
01-22-2006, 12:36 PM
Hello,

well I found this
getenv('SERVER_NAME');
getenv('SERVER_ADDR');
php_uname('n');

is their any native php tag to get the total RAM that the machine has? Also the total HDD assigned to a ~user on the server

thanks

thanks

Xenatino
01-22-2006, 09:11 PM
You could possibly look into disk_total_space() and disk_free_space()

thomas7
01-23-2006, 03:11 AM
For the quota, run the shell command:
quoata <username>.

This should work from any username, so you shouldn't need to run your script as root. Again, you may need to allow your script access to the quota command.