Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP polling data from a .php file on another server

Status
Not open for further replies.

kodr

Programmer
Dec 4, 2003
368
I'm not sure if this is possible, or if there's a better way. What I've got is 5 Linux/Apache servers. 4 of them have a small php file that basically just echo's the results of a small command.

I can pull up the server_status.php file from any of the 4 servers from any machine on my network, and get the text data that I'm expecting.

How could I pull this data into a web page on the 5th server?

It's probably something real simple that I'm overlooking.

my server status code is this:

Code:
<?php
	$results = exec('/var/[URL unfurl="true"]www/html/server.status[/URL] SITE_A');
	echo $results;
?>
 
I think security advice is to turn off using HTTP:// as a file name in the standard way e.g.
Code:
$fp=fopen("[URL unfurl="true"]http://server1/page.php");[/URL]
$server1=fread(*fp,256);
echo "<br>server 1 is " . $server1;
fclose($fp);

$fp=fopen("[URL unfurl="true"]http://server1/page.php");[/URL]
$server2=fread(*fp,256);
echo "<br>server 2 is " . $server2;
fclose($fp);
etc.
If this were totaly internal to your organisation it's probabbly ok. The best way I would think is to use CURL.
So it's entirly possible, You might want to make my code a bit more generic as well !
 
Thanks. After I posted this I ran across an example of just including the server_status.php and echoing the results.

Fortunately, none of these servers is accessible outside our network, but that doesn't mean I should just ignore that aspect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top