Results 1 to 5 of 5
Hi, a couple of questions here.
1. I have apache with PHP support running my webpage. How can I display the server uptime, website users etc as normal text?
2. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-13-2004 #1Just Joined!
- Join Date
- Feb 2004
- Posts
- 30
Display server status/DNS settings
Hi, a couple of questions here.
1. I have apache with PHP support running my webpage. How can I display the server uptime, website users etc as normal text?
2. I have set the IP and hostname to the required values which are 150.203.233.4 and postal.anu.edu.au. This all works fine. I have also installed jabberd 1.4 on it and mu-conference support. I think this requires a new subdomain, which I have set to conference.postal.anu.edu.au in the jabber.xml and muc.xml files. Is this all I need to do? If not, how do I set up the required subdomain? Im running Redhat 9.
Thanks.
- 02-14-2004 #2
To setup a subdomain just add it as a vhost like you normally would. Not sure how to display the server up time?
- 02-14-2004 #3Linux Guru
- Join Date
- Apr 2003
- Location
- London, UK
- Posts
- 3,284
to display things like server uptime etc, the following php script may work:
Note, i havent tried it, so there is no gaurentee of it working, so let me know how it goes.Code:<? passthru("/usr/bin/uptime"); ?>
Alternativly, you could could query /proc/uptime, though im not sure exactly how to interpret the data there, what format it is in etc.
Not too sure what you are meaning by website users.
Jason
- 02-15-2004 #4Just Joined!
- Join Date
- Feb 2004
- Posts
- 30
Sorry, by website users I mean the number of people browsing the page.
- 02-19-2004 #5Just Joined!
- Join Date
- Feb 2004
- Posts
- 4
pretty easy to do the number of users
needs MySQL but here goes..
create a new database, call it waht you want, now populate it with:
CREATE TABLE useronline (
timestamp int(15) DEFAULT '0' NOT NULL,
ip varchar(40) NOT NULL,
file varchar(100) NOT NULL,
PRIMARY KEY (timestamp),
KEY ip (ip),
KEY file (file)
);
now for the php
i aint supporting this btw, i just knocked it up with some old code i had, if it wipes you off of the face of the planet, it aint my faultCode:<?php $server = "xxx"; //fill in xxx with your details $db_user = "xxx"; $db_pass = "xxx"; $database = "xxx"; $timeoutseconds = 300; $timestamp = time(); $timeout = $timestamp-$timeoutseconds; mysql_connect($server, $db_user, $db_pass); $insert = mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); if(!($insert)) { print "Useronline Insert Failed > "; } $delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout"); if(!($delete)) { print "Useronline Delete Failed > "; } $result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'"); if(!($result)) { print "Useronline Select Error > "; } $user = mysql_num_rows($result); mysql_close(); if($user == 1) { print("$user user online\n"); //this bit prints if there is only 1 user } else { print("$user users online\n"); //otherwise this bit prints } ?>


Reply With Quote
