diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php
index fcd76ab1e..260a75e00 100644
--- a/html/includes/functions.inc.php
+++ b/html/includes/functions.inc.php
@@ -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 = "
".$args['hostname']." - " . fixifName($args['label']) . "
";
- if ($args['ifAlias']) { $content .= $args['ifAlias']."
"; }
+ $content = "".$port['hostname']." - " . fixifName($port['label']) . "
";
+ if ($port['ifAlias']) { $content .= $port['ifAlias']."
"; }
$content .= "";
- $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 .= "
";
- $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);
diff --git a/html/pages/device/alerts.inc.php b/html/pages/device/alerts.inc.php
new file mode 100644
index 000000000..e7c633b02
--- /dev/null
+++ b/html/pages/device/alerts.inc.php
@@ -0,0 +1,86 @@
+");
+#print_r($glo_conditions);
+#echo("");
+
+echo('
+
+ |
+ Type |
+ Subtype |
+ Metric |
+ Operator |
+ Value |
+ Severity |
+ On |
+ Status |
+ |
+
');
+
+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 = '
'; } else { $enabled = '
'; }
+ echo('');
+ echo(' | '.$type.' | '.$subtype.' | '.$metric.' | '.htmlentities($entry['operator']).' | '.$entry['value'].' | '.$entry['severity'].' | '.$enabled.' | ');
+ echo(' | | ');
+ echo('
');
+
+ /// Get which entities match this checker
+ $entities = get_entity_list($type, $subtype, $device['device_id'], $entry['entity']);
+
+ if(!empty($entities))
+ {
+ echo(' | Entities: ');
+ foreach($entities as $entity)
+ {
+ echo(generate_entity_link($type, $entity)." ");
+ }
+ echo(' |
');
+ }
+ }
+ }
+ }
+}
+
+
+echo('
');
+
+?>
diff --git a/includes/common.php b/includes/common.php
index 1a049d4c7..ea4f47f55 100644
--- a/includes/common.php
+++ b/includes/common.php
@@ -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;