<?php
// continuous_report.php
// RJM Programming
// September, 2015
// Report on number of web server processes running

   $startdate = new DateTime();
   $rnow = $startdate->format("Y-m-d_H_i_s");
   $rhour = $startdate->format("Y-m-d_H");
   $rday = $startdate->format("Y-m-d");
   $rmonth = $startdate->format("Y-m");
   $ryear = $startdate->format("Y");
   exec("ps -e | wc -l | tr -d ' ' > creports/acontinuous.rpt" . $rnow . ".html; cp -f creports/acontinuous.rpt" . $rnow . ".html creports/acontinuous.rpt" . $rhour . ".html;  cp -f creports/acontinuous.rpt" . $rnow . ".html creports/acontinuous.rpt" . $rday . ".html;  cp -f creports/acontinuous.rpt" . $rnow . ".html creports/acontinuous.rpt" . $rmonth . ".html;  cp -f creports/acontinuous.rpt" . $rnow . ".html creports/acontinuous.rpt" . $ryear . ".html; ");
   if (isset($_GET['fiftycheck']) && strpos($startdate->format("_i_"), "_50_") !== false) { // only keep 2 months worth
    exec("ksh -c 'for i in `find creports -name \"acontinuous.rpt????-??-??_??_??_??.html\" -mtime +62`; do rm -f \$i; done '");          
   } 
   if (isset($_GET['forcecheck'])) { // only keep 2 months worth
    exec("ksh -c 'for i in `find creports -name \"acontinuous.rpt????-??-??_??_??_??.html\" -mtime +62`; do rm -f \$i; done '");          
   }
   exit
      
?>
