The USA Linux Users Group Paste Bin

  • el
  • pt
  • This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

    The USA Linux Users Group Paste Bin

    Posted by whodey on Wed 27th Sep 09:38
    download | new post

    1. <?php
    2. $fp = fopen("hosts", "r");
    3.  
    4. while (!feof($fp)) {
    5. $host = fgets($fp);
    6.  
    7. $handle = popen("/bin/ping -c2 -q ".$host, "r");
    8. $message = "$host appears to be down";
    9.  
    10.         while (!feof($handle)) {
    11.                 $info = fgets($handle);
    12.  
    13.                 if (strpos($info, "100% packet loss")) {
    14.                         mail("[email protected]", "Server Problem", $message, "From: [email protected]\r\n");
    15.                 }
    16.         }
    17. }
    18. fclose($fp);
    19. pclose($handle);
    20. ?>

    Submit a correction or amendment below. (click here to make a fresh posting)
    After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

    Use syntax highlighting

    To highlight particular lines, prefix each line with @@


    Remember my settings