mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
alerting stuff (non-functional)
git-svn-id: http://www.observium.org/svn/observer/trunk@3197 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -341,29 +341,54 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
|
||||
return $output;
|
||||
}
|
||||
|
||||
function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
function generate_entity_link($type, $entity, $text = NULL, $graph_type=NULL)
|
||||
{
|
||||
global $config;
|
||||
global $entity_cache;
|
||||
|
||||
if(is_numeric($entity))
|
||||
{
|
||||
$entity = get_entity_by_id_cache($type, $entity);
|
||||
}
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case "port":
|
||||
$link = generate_port_link($entity, $text, $graph_type);
|
||||
break;
|
||||
case "storage":
|
||||
$url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
|
||||
default:
|
||||
$link = $entity[$type.'_id'];
|
||||
}
|
||||
|
||||
return($link);
|
||||
|
||||
}
|
||||
|
||||
function generate_port_link($port, $text = NULL, $type = NULL)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$args = ifNameDescr($args);
|
||||
if (!$text) { $text = fixIfName($args['label']); }
|
||||
if ($type) { $args['graph_type'] = $type; }
|
||||
if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; }
|
||||
$port = ifNameDescr($port);
|
||||
if (!$text) { $text = fixIfName($port['label']); }
|
||||
if ($type) { $port['graph_type'] = $type; }
|
||||
if (!isset($port['graph_type'])) { $port['graph_type'] = 'port_bits'; }
|
||||
|
||||
$class = ifclass($args['ifOperStatus'], $args['ifAdminStatus']);
|
||||
$class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
|
||||
|
||||
if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); }
|
||||
if (!isset($port['hostname'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); }
|
||||
|
||||
$content = "<div class=list-large>".$args['hostname']." - " . fixifName($args['label']) . "</div>";
|
||||
if ($args['ifAlias']) { $content .= $args['ifAlias']."<br />"; }
|
||||
$content = "<div class=list-large>".$port['hostname']." - " . fixifName($port['label']) . "</div>";
|
||||
if ($port['ifAlias']) { $content .= $port['ifAlias']."<br />"; }
|
||||
$content .= "<div style=\'width: 850px\'>";
|
||||
$graph_array['type'] = $args['graph_type'];
|
||||
$graph_array['type'] = $port['graph_type'];
|
||||
$graph_array['legend'] = "yes";
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "340";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['id'] = $args['port_id'];
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
@@ -373,9 +398,9 @@ function generate_port_link($args, $text = NULL, $type = NULL)
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= "</div>";
|
||||
|
||||
$url = generate_port_url($args);
|
||||
$url = generate_port_url($port);
|
||||
|
||||
if (port_permitted($args['port_id'], $args['device_id'])) {
|
||||
if (port_permitted($port['port_id'], $port['device_id'])) {
|
||||
return overlib_link($url, $text, $content, $class);
|
||||
} else {
|
||||
return fixifName($text);
|
||||
|
||||
86
html/pages/device/alerts.inc.php
Normal file
86
html/pages/device/alerts.inc.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
$glo_conditions = cache_conditions_global();
|
||||
|
||||
#echo("<pre>");
|
||||
#print_r($glo_conditions);
|
||||
#echo("</pre>");
|
||||
|
||||
echo('<table cellspacing="0" cellpadding=5 class="sortable" width="100%">
|
||||
<tr class="tablehead">
|
||||
<th width=10></th>
|
||||
<th class=paddedcell width=150>Type</th>
|
||||
<th class=paddedcell width=150>Subtype</th>
|
||||
<th class=paddedcell width=150>Metric</th>
|
||||
<th class=paddedcell width=100>Operator</th>
|
||||
<th class=paddedcell width=100>Value</th>
|
||||
<th class=paddedcell width=75>Severity</th>
|
||||
<th class=paddedcell width=50>On</th>
|
||||
<th class=paddedcell width=50>Status</th>
|
||||
<th class=paddedcell></th>
|
||||
</tr>');
|
||||
|
||||
function get_entity_list($type, $subtype = "*", $device_id = "*", $entry)
|
||||
{
|
||||
if($type == "storage") { $table = $type; } else { $table = $type.'s'; }
|
||||
|
||||
$query = 'SELECT '.$type.'_id AS id FROM '.$table.' WHERE 1';
|
||||
$args = array();
|
||||
|
||||
if(is_numeric($device_id))
|
||||
{
|
||||
$query .= " AND device_id = ?";
|
||||
$args[] = $device_id;
|
||||
}
|
||||
|
||||
if(is_numeric($entry['entity']))
|
||||
{
|
||||
$query .= " AND ".$type."_id = ?";
|
||||
$args[] = $entry['entity'];
|
||||
}
|
||||
|
||||
$entities_db = dbFetchRows($query, $args);
|
||||
|
||||
foreach($entities_db as $entity_db)
|
||||
{
|
||||
$entities[] = $entity_db['id'];
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
foreach($glo_conditions as $type => $subtypes)
|
||||
{
|
||||
foreach($subtypes as $subtype => $metrics)
|
||||
{
|
||||
if(empty($subtype)) { $subtype = "*"; }
|
||||
foreach($metrics as $metric => $entries)
|
||||
{
|
||||
foreach($entries as $entry_id => $entry)
|
||||
{
|
||||
if($entry['enable'] == 1) { $enabled = '<img align=absmiddle src="images/16/tick.png" />'; } else { $enabled = '<img align=absmiddle src="images/16/stop.png" />'; }
|
||||
echo('<tr class=list>');
|
||||
echo('<td></td><td><strong>'.$type.'</strong></td><td>'.$subtype.'</td><td>'.$metric.'</td><td>'.htmlentities($entry['operator']).'</td><td>'.$entry['value'].'</td><td>'.$entry['severity'].'</td><td>'.$enabled.'</td>');
|
||||
echo('<td></td><td></td>');
|
||||
echo('</tr>');
|
||||
|
||||
/// Get which entities match this checker
|
||||
$entities = get_entity_list($type, $subtype, $device['device_id'], $entry['entity']);
|
||||
|
||||
if(!empty($entities))
|
||||
{
|
||||
echo('<tr class=list><td></td><td colspan=9><strong>Entities: </strong>');
|
||||
foreach($entities as $entity)
|
||||
{
|
||||
echo(generate_entity_link($type, $entity)." ");
|
||||
}
|
||||
echo('</td></tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo('</table>');
|
||||
|
||||
?>
|
||||
@@ -188,7 +188,7 @@ function get_entity_by_id_cache($type, $id)
|
||||
{
|
||||
$entity = $entity_cache[$type][$id];
|
||||
} else {
|
||||
$entity = dbFetchRow("SELECT * FROM `".$table."` WHERE `".$type."_id` = ?", array($port_id));
|
||||
$entity = dbFetchRow("SELECT * FROM `".$table."` WHERE `".$type."_id` = ?", array($id));
|
||||
$entity_cache[$type][$id] = $entity;
|
||||
}
|
||||
return $entity;
|
||||
|
||||
Reference in New Issue
Block a user