Closed Thread Icon

Topic awaiting preservation: How to show the status of a site on another page? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12266" title="Pages that link to Topic awaiting preservation: How to show the status of a site on another page? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: How to show the status of a site on another page? <span class="small">(Page 1 of 1)</span>\

 
Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 06-15-2002 09:55

Sorry if this isn't the correct section for this, i'm not really sure how it would be done so i'm here

I want to show the status of a domain from another page on a different server most likely.

So say mysite.com is only up when i turn on the server, and I want to display varables messages or images on another page based on weither or not it on or off....

eg: show on.gif if the server is on & show off.gif if the server is down or off

so what kind of scripting is best to do this? .asp with a little .ssi ? or what? i'm only guessing here...

any help or ideas is much appreciated...



[This message has been edited by Synthetic (edited 06-15-2002).]

dmstiner
Bipolar (III) Inmate

From:
Insane since: Mar 2002

posted posted 06-15-2002 18:30

I'm still a php novice myself but the first thing that came to mind is to make a mysql database on your server, it can be empty, then wherever you want the on off graphics to be on your page include a php script that tries to connect to the database. If it connects, the server is up, have it display your on graphic if it doesn't just tell it to die nice and show the off graphic. I'm sure there has to be a better way but I don't know it yet heh.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-16-2002 01:08

I always recommend PHP for all scripting and many here will agree:

curl - this might not be installed, but it tells you how to.

exec - this is built into php and you could use this to run a perl program that would check the url and output the information.

The perl program would be:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
#!/usr/bin/perl
# churl - check urls

use HTML::LinkExtor;
use LWP::Simple qw(get head);

$base_url = shift
or die "usage: $0 <start_url>\n";
$parser = HTML::LinkExtor->new(undef, $base_url);
$parser->parse(get($base_url));
@links = $parser->links;
print "$base_url: \n";
foreach $linkarray (@links)
{
my @element = @$linkarray;
my @elt_type = shift @element;
while (@element)
{
my ($attr_name , $attr_value) = splice(@element, 0, 2);
if ($attr_value->scheme =~ /\b(ftp

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 06-16-2002 09:31

Thanks for all the info

I'm still open to better or easier ways from anyone else but i'll take my new information and try to get something working off that until I get informed of a better way

hehe that usually means you mr. maX lol I miss you !!!

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-16-2002 10:55

Synthetic, I wrote you a PHP script that can do what you want. You can get it from here: http://www.maxworld.co.yu/ozone/server_status.php.txt All necessary information are located inside the script as comments...

Enjoy!


WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 06-17-2002 17:53

I never knew about fsockopen()... nice function there max. I like.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-17-2002 23:07

In addition to that function, PHP also comes with a full set of various TCP/IP socket related functions, which can be used to write full featured web server. Just take a look at nanoweb...


Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 06-18-2002 10:47

Max the script looks good.
I'm not getting it to work though.
Looks like it is checking server_status.inc
but it's not outputting online or offline.

Could just be my server.
I'll look at it later.

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 06-18-2002 11:26

Wow thanks maX, your the man as usual !!!

hmm... dark seems confused, it looks pretty straight forward but incase i also run into a snag might you have an online demo of this in action?

sorry if that's asking too much of your time, thanks a million for the script regardless of the outcome

I'm going to finish installing my new program and check this script out on my server in the morning

it's about 5:30am here where i'm at so i better get some rest before attempting to do any scripting

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-18-2002 17:38

Kriek, did you set correct file permissions on 'server_status.inc' file (CHMOD 666 or 777). Also, after running the 'server_status.php' script, open 'server_status.inc' file in you favorite text editor and see if it contains the message or not (if it doesn't contain anything, php script can't write to that file for some reason). If it still doesn't work, show me how you configured the script and how you're calling it...

Synthetic, I don't have time to set up the demo (and IMHO it would be pointless, because you would just see text 'offline' or 'online'), but if you have any problems feel free post them here and I'll see what I can do help...


Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-18-2002 18:45

I swear the first time I tried this, I just got a blank page. No errors, nothing. Everything was configured right.

I just tried it again, and it's working fine. RunningWolf.com status

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-18-2002 19:25

Ahhhhh, I completely forgot about this. Since 'server_status.inc' is newly created file and since the script checks its modification status, it won't update it until amount of time specified in $interval variable passes. So, I can classify this as desired behavior, although it can be fixed very easy...


Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 06-19-2002 06:22
quote:
Since 'server_status.inc' is newly created file and since the script checks its modification status, it won't update it until amount of time specified in $interval variable passes. So, I can classify this as desired behavior, although it can be fixed very easy...



Ok that was my problem. It works now.
What would be the easiest way to configure the script to check multiple sites.


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-19-2002 07:02

Just create an array of servers.

$hosts = array('host1.com',host2.com');

Then make a foreach loop
var $out;
foreach ($hosts as $var) {
$fp = fsockopen($var, 80, $errno, $errstr, $timeout);

$status = '';

if (!$fp)
{
$status = $var." - ".$message_offline."\n\r";
}
else
{
fclose($fp);
$status = $var." - ".$message_offline."\n\r";
}

$fp = fopen('server_status.inc', "w");
fwrite($fp, $status);
fclose($fp);

$out .= "\n<br>"status;s
}
print($out);

put it all to an output var too for printing.
Hey Max is this isn't using the interval is it?



.:[ Be Bert. Be Ernie. Just be. ]:.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-19-2002 09:47

Bitdamaged, I don't understand your last question. If you ask me about your code that checks multiple servers, then answer is
yes, your code doesn't use interval and will check all those servers on *each* page view. If you ask me about my script, it does use interval...


Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 06-19-2002 17:01

Thanks a lot to everyone that helped, super thanks to maX for the custom script

First off, I tried your script maX it worked great... I had already figured out the interval part so that wasn't a big deal.

Thanks for your idea also bitdamaged, at the moment I only need to check one server but its good to know I can check several.

maX with your script, I see it works with domains, will it also work on just an IP address? or would that need a different variable or function?


Synthetic

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-19-2002 22:45

ohhh I get it, nah MAx I was asking about your's I thought the interval was for some sort of timeout or perl sleep function but it's just there to prevent the check from happening everytime the page is hit correct?

Note I didn't put the complete code in mine just the part needed to switch for multiple servers.



.:[ Be Bert. Be Ernie. Just be. ]:.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-19-2002 23:05

Synthetic, you can also use IP address instead of domain name. No changes are necessary...

Bitdamaged, the reason why checking server status on each page view isn't such hot idea is the following: When server is down, script would need to wait until connection times out ($timeout variable), before it shows that server is down. And that would *delay* showing of the page...


Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 06-20-2002 23:27

thanks maX i'll try it out right now, hey what if I wanted to check the status of a ftp server or a web site that was run of a port other than the default port 80

could you just use this 12.34.45.678:21 to specify the port you want to use?

Synthetic

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-21-2002 03:07

The port is the second bit passed to fsockopen so you can switch the port there.



.:[ Never resist a perfect moment ]:.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-21-2002 06:35

As Bitdamaged said, just change this line to suit your needs:

$fp = fsockopen($hostname, 80, $errno, $errstr, $timeout);

Optionally, you can introduce new variable to the configuration section and put in fsockopen() function call (just like $timeout variable)...


Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 05-26-2003 07:24

Hey thanks again this has been working just great

Now i've found the need to show the status of a telnet:// server, is that also possible with this script?

For example how would this work out? telnet://msn.com:3000

I know the telnet:// part can't go in the hostname variable, so i'm woundering since i'm checking the port of 3000 that the telnet is on, do i even need to bother with the telnet:// part ?

Synthetic's Chess Player Page

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-26-2003 19:43

afaik you shouldn't need to. when in doubt you can always give it a try though



.:[ Never resist a perfect moment ]:.

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 05-27-2003 01:44

Server was down last night so actually I couldn't lol, kinda why I came to ask about it in the meantime

Tried it today after the server came back on, indeed it's not needed, only the port is required

Synthetic's Chess Player Page

« BackwardsOnwards »

Show Forum Drop Down Menu