6

PHP Free Space Monitor Code

 3 years ago
source link: https://fuzzyblog.io/blog/story.radio.weblogs.com/2003/04/16/php-free-space-monitor-code.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

PHP Free Space Monitor Code

Apr 16, 2003

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

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

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 = "[email protected]";
  //setup the email object & params
  $mail = new phpmailer();
  $mail->IsMail();
  $mail->From = "[email protected]";
  $mail->FromName = "Free Space Mailer";
  $mail->AddAddress("$email");
  $mail->AddReplyTo("[email protected]");
  $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


Posted In: #php


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK