Group total processor utilization per processor type (#10626)

This commit is contained in:
pobradovic08
2019-09-28 06:16:18 +02:00
committed by Tony Murray
parent 2139eed306
commit 43729d7b6f

View File

@@ -20,8 +20,7 @@ if (count($processors)) {
$graph_array['from'] = \LibreNMS\Config::get('time.day');
$graph_array['legend'] = 'no';
$totalPercent=0;
$totalPercentWarn=0;
$total_percent=[];
foreach ($processors as $proc) {
$text_descr = rewrite_entity_descr($proc['processor_descr']);
@@ -54,8 +53,17 @@ if (count($processors)) {
</a></td>
</tr>';
} else {
$totalPercent = $totalPercent + $percent;
$totalPercentWarn = $totalPercentWarn + $proc['processor_perc_warn'];
if (!isset($total_percent[$proc['processor_type']])) {
$total_percent[$proc['processor_type']] = array(
'usage' => 0,
'warn' => 0,
'descr' => $text_descr,
'count' => 0
);
}
$total_percent[$proc['processor_type']]['usage'] += $percent;
$total_percent[$proc['processor_type']]['warn'] += $proc['processor_perc_warn'];
$total_percent[$proc['processor_type']]['count'] += 1;
}
}//end foreach
@@ -93,17 +101,19 @@ if (count($processors)) {
echo overlib_link($link, $graph, $overlib_content, null);
echo ' </td>
</tr>';
foreach ($total_percent as $type => $values) {
//Add a row with CPU desc, count and percent graph
$percent_usage = ceil($values['usage']/$values['count']);
$percent_warn = $values['warn']/$values['count'];
$background = get_percentage_colours($percent_usage, $percent_warn);
//Add a row with CPU desc, count and percent graph
$totalPercent=$totalPercent/count($processors);
$totalPercentWarn=$totalPercentWarn/count($processors);
$background = get_percentage_colours($totalPercent, $totalPercentWarn);
echo '<tr>
<td class="col-md-4">'.overlib_link($link, $text_descr, $overlib_content).'</td>
<td class="col-md-4">'.overlib_link($link, 'x'.count($processors), $overlib_content).'</td>
<td class="col-md-4">'.overlib_link($link, print_percentage_bar(200, 20, $totalPercent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']), $overlib_content).'</td>
</tr>';
echo '
<tr>
<td class="col-md-4">' . overlib_link($link, $values['descr'], $overlib_content).'</td>
<td class="col-md-4">' . overlib_link($link, 'x' . $values['count'], $overlib_content).'</td>
<td class="col-md-4">' . overlib_link($link, print_percentage_bar(200, 20, $percent_usage, null, 'ffffff', $background['left'], $percent_usage.'%', 'ffffff', $background['right']), $overlib_content) . '</td>
</tr>';
}
}
echo '</table>