>>  Site Map >>  Forums >>  PHP+MySql

Forum module - topics in forum:



PHP+MySql - Coding mã nguồn mở rât thông dụng để làm web, và hệ thống cơ sỏ dữ liệu rất mạnh duợc ưa chuộng



Website Monitoring - Theo dõi trạng thái web

If you have many domain names, and/or pointers to domains, that you do not visit at least daily you may want this script. It will tell you if your sites are having issues. For example, what if someone hacked your registrar and pointed your domain name to another DNS (yes, this actually happened to me)? Or what if the zone files are borked at your webhost? Or what if there was a server issue (or a hacker) that deleted your files? Doing a simple website ping on port 80 will not answer all these questions. Using this script will.

This is a simple script that can be executed to monitor a whole list of domain names. Run it at least every day. The instructions are in the comments in the script.

- - Start Script Here - -
Code: :
<?php
/*
This script is used to validate that all of the websites in a list are operational.
It actually reads the contents of a file on each website.
This ensures the domain name is pointing where it should, the site is up, and at least one file is intact.
It can help identify unauthorized DNS changes, server outages, or global file issues.
It must be run from a server where none of the sites are located, or the DNS test will not be valid.  << IMPORTANT POINT
/
The script assumes that each site has a file named site_test.txt at the document root.
That file must contain the text "The site is up" (no quotes or line break).
/
The only alteration to the script should be the $filename variable, which has the location of the domain name file.
The domain name file is a text file with the domain names listed (i.e. example.com) one per line.
The domain name file can be located on any server (you can use a url location).
/
The output of the script will list the domain names in green (OK) or red (problem).
This script will not identify the specific problem with a domain, only that there is a problem.
*/
$filename = "domain_names.txt";
$site = file($filename);
echo "<span style='font-weight: bold;'>Domain Validation</span><br>";
foreach ($site as $domain) {
  $domain = preg_replace("#\r\n?|\n#", "", $domain);
  $testFile = @file_get_contents("http://" . $domain . "/site_test.txt");
  if ($testFile == "The site is up")
    echo "<span style='color: green;'>$domain</span><br>";
  else
    echo "<span style='color: red;'>$domain</span><br>";
}
?>
- - End Script Here - -




Search from ALEXA


put your ads here