function makeGraph($receiver, $array_of_freezers, $graphname, $j) { $title = $graphname[$receiver]; print "Graphing Receiver: {$receiver} \t {$title}\n"; $command_line = ""; foreach ($array_of_freezers as $freezer_id => $freezer_details) { $db_name = $freezer_details[1]; $legend = $freezer_details[2]; $color = $freezer_details[3]; $result = getTempAvg($db_name); if ($result == 999) { $result = "--"; } //Check for lockfile $filename = $legend . ".lock"; if (file_exists($filename)) { $lockfilemark = "*"; } else { $lockfilemark = ""; } $command_line .= " DEF:temp{$freezer_id}={$db_name}.rrd:freezer1:AVERAGE LINE2:temp{$freezer_id}#{$color}:\"{$legend}({$result}){$lockfilemark}\" "; } $begin = "rrdtool graph receiver{$j}.png "; $end = " --disable-rrdtool-tag --upper-limit -20 --lower-limit -100 -D --rigid --font LEGEND:10:\"Arial Bold\" --font TITLE:13:\"Arial\" --title=\"{$title}\" -w 310 -h 275"; $end .= " --color BACK#000000 --color FONT#FFFFFF --color SHADEA#000000 --color SHADEB#000000 --color AXIS#FFFFFF --color CANVAS#000000 --color MGRID#FFFF33"; // $end = " --slope-mode --disable-rrdtool-tag --upper-limit -20 --lower-limit -100 -D --rigid --vertical-label \"Deg C\" --title=\"$title\" -w 310 "; $final_command = $begin . $command_line . $end; $output = shell_exec($final_command); //print "\n".$final_command."\n\n"; }
// CRON Job script to monitor rrd databases and send emails // See thermo_includes.php for setting threshold value, email addresses etc. // JDeRisi 2013 include 'thermo_includes.php'; print "<pre>"; $myarray = getFreezers($datafile); $rec_count = count($myarray); print "Fetching last 30 minutes for {$rec_count} receivers.\n"; $j = 0; foreach ($myarray as $receiver => $array_of_freezers) { print "Receiver: {$receiver}\n"; foreach ($array_of_freezers as $id => $freezer_array) { $db_name = $freezer_array[1]; $label = $freezer_array[2]; print "{$label} \t : {$db_name} \t : "; $result = getTempAvg($db_name); if ($result != 999) { print ": \tAVG: {$result} \t"; $check = checkResult($result, $threshold); if (!$check) { // Check for a lockfile $filename = $label . ".lock"; if (file_exists($filename)) { print " Lock file detected. No alert sent."; } else { sendAlert($result, $threshold, $db_name, $label, $graphname[$receiver], $contactfile); $mylock = fopen($filename, "w"); if ($mylock == false) { print "Could not creat lock file {$filename}"; } else { fwrite($mylock, "Locked");