The FuzzyBlog! : PHP Free Space Monitor Code The FuzzyBlog!

Marketing 101. Consulting 101. PHP Consulting. Random geeky stuff. I Blog Therefore I Am.

Home FuzzyGroup About Us Our Services

PHP Free Space Monitor Code

<?php

script to get the amount of free space with df -h and email it

to me daily

include "../z/class.phpmailer.php";

  $freespace = mysystem("df -h");
  $fortune = mysystem ("/usr/games/fortune");

  $email = "scott@fuzzygroup.com";
  //setup the email object & params
  $mail = new phpmailer();
  $mail->IsMail();
  $mail->From = "webmaster@fuzzygroup.com";
  $mail->FromName = "Free Space Mailer";
  $mail->AddAddress("$email");
  $mail->AddReplyTo("scott@fuzzygroup.com");
  $mail->IsHTML(false);
  $mail->Subject = "Free Space On FuzzyGroup Server";
  $mail->Body    = $freespace . "\n\n\n\n" . $fortune;

  if(!$mail->Send())
  {
    echo "Error – Can't Email User Info<p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
  }
  else {
    print "<pre>$freespace <BR><BR>$fortune</PRE>";
    exit;
  }

function mysystem($command) {
 if (!($p=popen("($command)2>&1","r"))) {
  return 126;
 }

 while (!feof($p)) {
  $line=fgets($p,1000);
   $out .= $line;
 }
 pclose($p);
 return $out;
}

?>

 

This Page was last update: 4/16/2003; 10:20:40 AM

Copyright 2003 The FuzzyStuff

Theme Design by Bryan Bell

Click here to visit the Radio UserLand website. Subscribe to "The FuzzyBlog!" in Radio UserLand. Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.