$proc)
{
$text_descr = rewrite_entity_name($proc['processor_descr'], 'processor');
/* not required when find_similar() used
if ($device['os'] == "vmware")
{
list(, $text_descr) = explode(' ', $text_descr, 2);
list($text_descr) = explode(' @ ', $text_descr, 2);
}
*/
$processors_db[$k]['text_descr'] = $text_descr; // Just append to array for not do same later
$processors_descr[] = $text_descr;
}
$processors_descr = find_similar($processors_descr, TRUE); // Processor descr -> Similar part of
// Combine multiple same processors
foreach ($processors_db as $proc)
{
//$text_descr = rewrite_entity_name($proc['processor_descr']);
if (isset($processors_descr[$proc['text_descr']]))
{
// This is processor name with similar part only
$text_descr = $processors_descr[$proc['text_descr']];
} else {
$text_descr = $proc['text_descr'];
}
$processors[$text_descr]['device_id'] = $device['device_id'];
$processors[$text_descr]['processor_id'] = $proc['processor_id'];
$processors[$text_descr]['id'][] = $proc['processor_id'];
$processors[$text_descr]['usage'] += $proc['processor_usage'];
$processors[$text_descr]['count']++;
}
$box_args = array('title' => 'Processors',
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'processor')),
'icon' => $config['icon']['processor'],
);
echo generate_box_open($box_args);
echo('
');
// Show this for everything.
if (TRUE)
{
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = $config['time']['now'];
$graph_array['device'] = $device['device_id'];
$graph_array['type'] = (isset($device['graphs']['ucd_ss_cpu']) ? 'device_ucd_ss_cpu' : 'device_processor');
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width']);
$graph_link = generate_url($link_array);
$link = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'processor'));
$graph_array['width'] = "210";
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - Processor Usage");
//echo(overlib_link($graph_link, $graph, $overlib_content, NULL));
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent.
$graph_array['style'][] = 'margin-top: -6px';
$minigraph = generate_graph_tag($graph_array);
echo('');
echo(overlib_link($graph_link, $graph, $overlib_content, NULL));
echo(' |
');
}
// Perhaps we should collapse this when it's too long. Perhaps we should do that for other things too.
foreach ($processors as $text_descr => $proc)
{
$percent = round($proc['usage'] / $proc['count']);
$background = get_percentage_colours($percent);
$graph_colour = str_replace("#", "", $row_colour);
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = implode(',', $proc['id']);
$graph_array['type'] = $graph_type;
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
if (count($proc['id']) > 1)
{
$graph_array['type'] = "multi-processor_usage";
} else {
$graph_array['type'] = "processor_usage";
}
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr);
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00';
// $graph_array['style'][] = 'margin-top: -6px';
$minigraph = generate_graph_tag($graph_array);
$count_button = ($proc['count'] > 1 ? ' '.$proc['count'].'' : '');
echo('
|
'.generate_entity_link('processor', $proc, $text_descr).''.$count_button.' |
'.overlib_link($link, $minigraph, $overlib_content).' |
'.overlib_link($link, print_percentage_bar(200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content).' |
');
}
echo("
");
echo generate_box_close();
}
// EOF