I created a PHP code to display disk usage alerts, it does it well. What I need is guidance on how can use this code to send this HTML content to email as well. Writing the HTML to file is one option, but the question is, can it be done at run time, I mean while I echo the HTML, at the same time send email as well.
Below is my code:
<table border=1 cellspacing=0 cellpadding=3>
<thead>
<tr class="info">
<th>HOST</th>
<th>APP_HOST1</th>
<th>APP_HOST2</th>
<th>APP_HOST3</th>
<th>APP_HOST4</th>
<th>APP_HOST5</th>
<th>DB_HOST1</th>
<th>DB_HOST2</th>
</tr>
</thead>
<tbody>
<tr>
<td>DISK_ROOT</td>
<?php
$lines = file('disk_usage_root.txt');
foreach($lines as $line) {
$cols = explode(' ', $line);
$disk_root_pc = $cols[0];
$disk_root_usedvstotal = $cols[1];
$percentage = (int) str_replace("%", "", $disk_root_pc);
$status = "success";
if ($percentage > 80) {
$status = "danger";
} elseif ($percentage > 70) {
$status = "warning";
}
echo '<td>
<span class="badge progress-bar-'.$status.'">'.$disk_root_pc.' '.$disk_app_usedvstotal.'</span>
</td>';
}
?>
</tr>
</tbody>
</table>