本文整理汇总了PHP中generate_entity_link函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_entity_link函数的具体用法?PHP generate_entity_link怎么用?PHP generate_entity_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_entity_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_sensor_row
function generate_sensor_row($sensor, $vars)
{
global $config;
humanize_sensor($sensor);
$table_cols = 4;
$graph_array = array();
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = "sensor_graph";
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
$graph_array['from'] = $config['time']['day'];
if ($sensor['sensor_event'] && is_numeric($sensor['sensor_value'])) {
$mini_graph = generate_graph_tag($graph_array);
} else {
// Do not show "Draw Error" minigraph
$mini_graph = '';
}
$row = '
<tr class="' . $sensor['row_class'] . '">
<td class="state-marker"></td>';
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$row .= ' <td class="entity">' . generate_device_link($sensor) . '</td>' . PHP_EOL;
$table_cols++;
}
if ($vars['entity_icon'] == TRUE) {
$row .= ' <td width="20px"><i class="' . $config['sensor_types'][$sensor['sensor_class']]['icon'] . '"></i></td>';
}
$row .= ' <td class="entity">' . generate_entity_link("sensor", $sensor) . '</td>';
if ($vars['show_class']) {
$row .= ' <td>' . nicecase($sensor['sensor_class']) . '</td>' . PHP_EOL;
$table_cols++;
}
if ($vars['tab'] != 'overview') {
$row .= ' <td><span class="label ' . ($sensor['sensor_custom_limit'] ? 'label-warning' : '') . '">' . $sensor['sensor_thresholds'] . '</span></td>' . PHP_EOL;
$table_cols++;
}
$row .= ' <td style="width: 90px; text-align: right;">' . generate_entity_link('sensor', $sensor, $mini_graph, NULL, FALSE) . '</td>';
if ($vars['tab'] != 'overview') {
$row .= ' <td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $sensor['sensor_last_change'], 'short-2') . ' ago', format_unixtime($sensor['sensor_last_change'])) . '</td>';
$table_cols++;
$row .= ' <td style="text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['sensor_event'] . '</span></strong></td>';
$table_cols++;
}
$row .= ' <td style="width: 80px; text-align: right;"><strong><span class="' . $sensor['state_class'] . '">' . $sensor['human_value'] . $sensor['sensor_symbol'] . '</span></strong>
</tr>' . PHP_EOL;
if ($vars['view'] == "graphs" || $vars['id'] == $sensor['sensor_id']) {
$vars['graph'] = "graph";
}
if ($vars['graph']) {
$row .= '
<tr class="' . $sensor['row_class'] . '">
<td class="state-marker"></td>
<td colspan="' . $table_cols . '">';
$graph_array = array();
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = 'sensor_' . $vars['graph'];
$row .= generate_graph_row($graph_array, TRUE);
$row .= '</td></tr>';
}
# endif graphs
return $row;
}
示例2: generate_sla_row
function generate_sla_row($sla, $vars)
{
global $config;
humanize_sla($sla);
$table_cols = "8";
$graph_array = array();
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sla['sla_id'];
$graph_array['type'] = $sla['graph_type'];
$graph_array['legend'] = "no";
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
$graph_array['from'] = $config['time']['day'];
if ($sla['rtt_event'] && $sla['rtt_sense']) {
$mini_graph = generate_graph_tag($graph_array);
} else {
// Do not show "Draw Error" minigraph
$mini_graph = '';
}
$out = '<tr class="' . $sla['row_class'] . '"><td class="state-marker"></td>';
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$out .= '<td class="entity">' . generate_device_link($sla) . '</td>';
$table_cols++;
}
$out .= '<td class="entity">' . generate_entity_link('sla', $sla) . '</td>';
$out .= '<td>' . $sla['sla_owner'] . '</td>';
$out .= '<td>' . $sla['rtt_label'] . '</td>';
$out .= '<td>' . generate_entity_link('sla', $sla, $mini_graph, NULL, FALSE) . '</td>';
$out .= '<td style="white-space: nowrap">' . generate_tooltip_link(NULL, formatUptime($config['time']['now'] - $sla['rtt_last_change'], 'short-2') . ' ago', format_unixtime($sla['rtt_last_change'])) . '</td>';
$out .= '<td style="text-align: right;"><strong><span class="' . $sla['rtt_class'] . '">' . $sla['rtt_event'] . '</span></strong></td>';
$out .= '<td style="text-align: right;"><strong><span class="' . $sla['rtt_class'] . '">' . $sla['rtt_sense'] . '</span></strong></td>';
$out .= '<td><span class="' . $sla['sla_class'] . '">' . $sla['human_value'] . $sla['human_unit'] . '</span></td>';
$out .= '</tr>';
if ($vars['graph'] || $vars['view'] == "graphs" || $vars['id'] == $sla['sla_id']) {
// If id set in vars, display only specific graphs
$graph_array = array();
$graph_array['type'] = $sla['graph_type'];
$graph_array['id'] = $sla['sla_id'];
$out .= '<tr class="' . $sla['row_class'] . '">';
$out .= ' <td class="state-marker"></td>';
$out .= ' <td colspan="' . $table_cols . '">';
$out .= generate_graph_row($graph_array, TRUE);
$out .= ' </td>';
$out .= '</tr>';
}
return $out;
}
示例3: generate_printersupplies_row
function generate_printersupplies_row($supply, $vars)
{
$graph_type = "printersupply_usage";
$table_cols = 5;
$total = $supply['supply_capacity'];
$perc = $supply['supply_value'];
$graph_array['type'] = $graph_type;
$graph_array['id'] = $supply['supply_id'];
$graph_array['from'] = $GLOBALS['config']['time']['day'];
$graph_array['to'] = $GLOBALS['config']['time']['now'];
$graph_array['height'] = "20";
$graph_array['width'] = "80";
if ($supply['supply_colour'] != '') {
$background = toner_to_colour($supply['supply_colour'], $perc);
} else {
$background = toner_to_colour($supply['supply_descr'], $perc);
}
/// FIXME - popup for printersupply entity.
$output .= '<tr class="' . $supply['html_row_class'] . '">';
$output .= '<td class="state-marker"></td>';
if ($vars['popup'] == TRUE) {
$output .= '<td style="width: 40px; text-align: center;"><i class="' . $GLOBALS['config']['entities']['printersupply']['icon'] . '"></i></td>';
} else {
$output .= '<td style="width: 1px;"></td>';
}
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$output .= '<td class="entity">' . generate_device_link($supply) . '</td>';
$table_cols++;
}
$output .= '<td class="entity">' . generate_entity_link('printersupply', $supply) . '</td>';
if (!isset($vars['supply'])) {
$output .= '<td>' . nicecase($supply['supply_type']) . '</td>';
}
$output .= '<td style="width: 70px;">' . generate_graph_popup($graph_array) . '</td>';
$output .= '<td style="width: 200px;"><a href="' . $link . '">' . print_percentage_bar(400, 20, $perc, $perc . '%', 'ffffff', $background['right'], NULL, "ffffff", $background['left']) . '</a></td>';
$output .= '<td style="width: 50px; text-align: right;"><span class="label">' . $perc . '%</span></td>';
$output .= '</tr>';
if ($vars['view'] == "graphs") {
$output .= '<tr class="' . $supply['html_row_class'] . '">';
$output .= '<td class="state-marker"></td>';
$output .= '<td colspan=' . $table_cols . '>';
unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $supply['supply_id'];
$graph_array['type'] = $graph_type;
$output .= generate_graph_row($graph_array, TRUE);
$output .= "</td></tr>";
}
# endif graphs
return $output;
}
示例4: generate_box_close
} else {
echo '<p class="text-center text-warning bg-warning" style="padding: 10px; margin: 0px;"><strong>This user currently has no permitted ports</strong></p>';
//print_warning('This user currently has no permitted ports');
}
echo generate_box_close();
// End port permissions
// Start sensor permissions
echo generate_box_open(array('header-border' => TRUE, 'title' => 'Sensor Permissions'));
if (count($user_permissions['sensor'])) {
echo '<table class="' . OBS_CLASS_TABLE . '">' . PHP_EOL;
foreach (array_keys($user_permissions['sensor']) as $entity_id) {
$sensor = get_entity_by_id_cache('sensor', $entity_id);
$device = device_by_id_cache($sensor['device_id']);
echo '<tr><td style="width: 1px;"></td>
<td style="width: 200px; overflow: hidden;"><i class="' . $config['entities']['device']['icon'] . '"></i> ' . generate_entity_link('device', $device) . '</td>
<td style="overflow: hidden;"><i class="' . $config['entities']['sensor']['icon'] . '"></i> ' . generate_entity_link('sensor', $sensor) . '
<td width="25">
</tr>';
}
echo '</table>' . PHP_EOL;
} else {
echo '<p class="text-center text-warning bg-warning" style="padding: 10px; margin: 0px;"><strong>This user currently has no permitted sensors</strong></p>';
//print_warning('This user currently has no permitted sensors');
}
echo generate_box_close();
// End sensor permissions
}
?>
</div>
示例5: process_alerts
/**
* Check all alerts for a device to see if they should be notified or not
*
* @param array device
* @return NULL
*/
function process_alerts($device)
{
global $config, $alert_rules, $alert_assoc;
echo "Processing alerts for " . $device['hostname'] . PHP_EOL;
$alert_table = cache_device_alert_table($device['device_id']);
$sql = "SELECT * FROM `alert_table`";
$sql .= " LEFT JOIN `alert_table-state` ON `alert_table`.`alert_table_id` = `alert_table-state`.`alert_table_id`";
$sql .= " WHERE `device_id` = ?";
foreach (dbFetchRows($sql, array($device['device_id'])) as $entry) {
echo 'Alert: ' . $entry['alert_table_id'] . ' Status: ' . $entry['alert_status'] . ' ';
// If the alerter is now OK and has previously alerted, send an recovery notice.
if ($entry['alert_status'] == '1' && $entry['has_alerted'] == '1') {
$alert = $alert_rules[$entry['alert_test_id']];
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$graphs = "";
$metric_text = "";
foreach ($state['metrics'] as $metric => $value) {
$metric_text .= $metric . " = " . $value . PHP_EOL . "<br />";
}
// FIXME De-dup this shit soon.
// - adama
$message = '
<head>
<title>Observium Alert</title>
<style>
.observium{ width:100%; max-width: 500px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:1px solid #DDDDDD; background-color:#FAFAFA;
font-size: 13px; color: #777777; }
.header{ font-weight: bold; font-size: 16px; padding: 5px; color: #555555; }
.red { color: #cc0000; }
#deviceinfo tr:nth-child(odd) { background: #ffffff; }
</style>
<style type="text/css"></style></head>
<body>
<table class="observium">
<tbody>
<tr>
<td>
<table class="observium" id="deviceinfo">
<tbody>
<tr><td class="header">RECOVERY</td><td><a style="float: right;" href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $entry['alert_table_id'])) . '">Modify</a></td></tr>
<tr><td><b>Alert</b></font></td><td class="red">' . $alert['alert_message'] . '</font></td></tr>
<tr><td><b>Entity</b></font></td><td>' . generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']) . '</font></td></tr>';
if (strlen($entity['entity_descr']) > 0) {
$message .= '<tr><td><b>Descr</b></font></td><td>' . $entity['entity_descr'] . '</font>';
}
$message .= '
<tr><td><b>Metrics</b></font></td><td>' . $metric_text . '</font></td></tr>
<tr><td><b>Duration</b></font></td><td>' . formatUptime(time() - $entry['last_failed']) . '</font></td></tr>
<tr><td colspan="2" class="header">Device</td></tr>
<tr><td><b>Device</b></font></td><td>' . generate_device_link($device) . '</font></td></tr>
<tr><td><b>Hardware</b></font></td><td>' . $device['hardware'] . '</font></td></tr>
<tr><td><b>Operating System</b></font></td><td>' . $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'] . '</font></td></tr>
<tr><td><b>Location</b></font></td><td>' . htmlspecialchars($device['location']) . '</font></td></tr>
<tr><td><b>Uptime</b></font></td><td>' . deviceUptime($device) . '</font></td></tr>
</tbody></table>
</td></tr>
<tr><td>
<center>' . $graphs . '</center></td></tr>
</tbody></table>
</body>
</html>';
alert_notify($device, "RECOVER: [" . $device['hostname'] . "] [" . $alert['entity_type'] . "] [" . $entity['entity_name'] . "] " . $alert['alert_message'], $message);
$update_array['last_recovered'] = time();
$update_array['has_alerted'] = 0;
dbUpdate($update_array, 'alert_table-state', '`alert_table_id` = ?', array($entry['alert_table_id']));
}
if ($entry['alert_status'] == '0') {
echo 'Alert tripped. ';
// Has this been alerted more frequently than the alert interval in the config?
/// FIXME -- this should be configurable per-entity or per-checker
if (time() - $entry['last_alerted'] < $config['alerts']['interval'] && !isset($GLOBALS['spam'])) {
$entry['suppress_alert'] = TRUE;
}
// Check if alert has ignore_until set.
if (is_numeric($entry['ignore_until']) && $entry['ignore_until'] > time()) {
$entry['suppress_alert'] = TRUE;
}
if ($entry['suppress_alert'] != TRUE) {
echo 'Requires notification. ';
$alert = $alert_rules[$entry['alert_test_id']];
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$condition_text = "";
foreach ($state['failed'] as $failed) {
$condition_text .= $failed['metric'] . " " . $failed['condition'] . " " . $failed['value'] . " (" . $state['metrics'][$failed['metric']] . ")<br />";
}
$graphs = "";
$metric_text = "";
foreach ($state['metrics'] as $metric => $value) {
$metric_text .= $metric . " = " . $value . PHP_EOL . "<br />";
}
//.........这里部分代码省略.........
示例6: array
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $drive['storage_id'];
$graph_array['type'] = $graph_type;
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$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'] . " - " . $drive['storage_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);
echo '<tr class="' . $background['class'] . '">
<td class="state-marker"></td>
<td class="entity" style="max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">' . generate_entity_link('storage', $drive) . '</td>
<td style="width: 90px">' . overlib_link($link, $minigraph, $overlib_content) . '</td>
<td style="width: 200px">' . overlib_link($link, print_percentage_bar(200, 20, $percent, $used . "/" . $total . " (" . $percent . "%)", "ffffff", $background['left'], $free . " (" . (100 - $percent) . "%)", "ffffff", $background['right']), $overlib_content) . '</td>
</tr>';
}
echo "</table>";
echo generate_box_close();
}
unset($drive_rows);
// EOF
示例7: generate_device_link
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = "sensor_graph";
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
# the 00 at the end makes the area transparent.
$graph_array['from'] = $config['time']['day'];
echo '
<tr class="' . $sensor['row_class'] . '">
<td class="state-marker"></td>
<td class="entity">' . generate_device_link($sensor) . '</td>
<td class="entity">' . generate_entity_link("sensor", $sensor) . '</td>
<td class="text-right"><i class="' . $alert . '"></i></td>
<td><span class="label">' . $sensor['sensor_thresholds'] . '</span></td>
<td>' . generate_entity_link("sensor", $sensor, generate_graph_tag($graph_array), FALSE, FALSE) . '</td>
<td style="text-align: right;"><span class="' . $sensor['state_class'] . '">' . $sensor['human_value'] . $sensor['sensor_symbol'] . '</span></td>
</tr>' . PHP_EOL;
if ($vars['view'] == "graphs") {
echo '
<tr class="' . $sensor['row_class'] . '">
<td class="state-marker"></td>
<td colspan=6>';
$graph_array = array();
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = 'sensor_graph';
print_graph_row($graph_array, TRUE);
echo '</td></tr>';
}
# endif graphs
示例8: generate_graph_tag
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $status['status_id'];
$graph_array['type'] = "status_graph";
$graph_array['legend'] = "no";
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
# the 00 at the end makes the area transparent.
$graph_array['from'] = $config['time']['day'];
$mini_graph = generate_graph_tag($graph_array);
$status_misc = '<span class="label">' . $status['entPhysicalClass'] . '</span>';
echo '<tr class="' . $status['row_class'] . '">
<td class="state-marker"></td>
<td class="entity">' . generate_entity_link('status', $status) . '</td>
<td><span class="label">' . $status['entPhysicalClass'] . '</span></td>
<td>' . generate_entity_link('status', $status, $mini_graph, NULL, FALSE) . '</td>
<td style="text-align: right;"><strong>' . overlib_link($link, '<span class="' . $status['state_class'] . '">' . $status['status_name'] . '</span>', $overlib_content) . '</strong></td>
</tr>' . PHP_EOL;
if ($vars['view'] == "graphs") {
echo '<tr><td class="state-marker"></td><td colspan=5>';
unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $status['status_id'];
$graph_array['type'] = "status_graph";
print_graph_row($graph_array, TRUE);
echo '</td></tr>';
}
# endif graphs
}
echo "</table>";
// EOF
示例9: process_alerts
function process_alerts($device)
{
global $config, $alert_rules, $alert_assoc;
echo "处理警报 " . $device['hostname'] . PHP_EOL;
$alert_table = cache_device_alert_table($device['device_id']);
$sql = "SELECT * FROM `alert_table`";
$sql .= " LEFT JOIN `alert_table-state` ON `alert_table`.`alert_table_id` = `alert_table-state`.`alert_table_id`";
$sql .= " WHERE `device_id` = ? AND `alert_status` IS NOT NULL;";
foreach (dbFetchRows($sql, array($device['device_id'])) as $entry) {
echo 'Alert: ' . $entry['alert_table_id'] . ' Status: ' . $entry['alert_status'] . ' ';
// If the alerter is now OK and has previously alerted, send an recovery notice.
if ($entry['alert_status'] == '1' && $entry['has_alerted'] == '1') {
$alert = $alert_rules[$entry['alert_test_id']];
if (!$alert['suppress_recovery']) {
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$metric_array = array();
foreach ($state['metrics'] as $metric => $value) {
$metric_array[] = $metric . ' = ' . $value;
}
$message_tags = array('ALERT_STATE' => 'RECOVERY', 'ALERT_URL' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $entry['alert_table_id'])), 'ALERT_MESSAGE' => $alert['alert_message'], 'METRICS' => implode(PHP_EOL . ' ', $metric_array), 'DURATION' => formatUptime(time() - $entry['last_failed']), 'ENTITY_LINK' => generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']), 'ENTITY_NAME' => $entity['entity_name'], 'ENTITY_DESCRIPTION' => $entity['entity_descr'], 'DEVICE_HOSTNAME' => $device['hostname'], 'DEVICE_LINK' => generate_device_link($device), 'DEVICE_HARDWARE' => $device['hardware'], 'DEVICE_OS' => $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'], 'DEVICE_LOCATION' => $device['location'], 'DEVICE_UPTIME' => deviceUptime($device));
$message['text'] = simple_template('alert/email_text.tpl', $message_tags, array('is_file' => TRUE));
//$message_tags['CONDITIONS'] = nl2br($message_tags['CONDITIONS']);
$message_tags['METRICS'] = nl2br($message_tags['METRICS']);
$message['html'] = simple_template('alert/email_html.tpl', $message_tags, array('is_file' => TRUE));
//logfile('debug.log', var_export($message, TRUE));
alert_notify($device, alert_generate_subject('RECOVER', $device, $alert, $entity), $message, $entry['alert_test_id']);
log_alert('恢复发送的通知', $device, $entry, 'RECOVER_NOTIFY');
} else {
echo '已限制恢复.';
log_alert('限制恢复通知', $device, $entry, 'RECOVER_SUPPRESSED');
}
$update_array['last_recovered'] = time();
$update_array['has_alerted'] = 0;
dbUpdate($update_array, 'alert_table-state', '`alert_table_id` = ?', array($entry['alert_table_id']));
}
if ($entry['alert_status'] == '0') {
echo '警报已停止. ';
// Has this been alerted more frequently than the alert interval in the config?
/// FIXME -- this should be configurable per-entity or per-checker
if (time() - $entry['last_alerted'] < $config['alerts']['interval'] && !isset($GLOBALS['spam'])) {
$entry['suppress_alert'] = TRUE;
}
// Check if alert has ignore_until set.
if (is_numeric($entry['ignore_until']) && $entry['ignore_until'] > time()) {
$entry['suppress_alert'] = TRUE;
}
// Check if alert has ignore_until_ok set.
if (is_numeric($entry['ignore_until_ok']) && $entry['ignore_until_ok'] == '1') {
$entry['suppress_alert'] = TRUE;
}
if ($entry['suppress_alert'] != TRUE) {
echo 'Requires notification. ';
$alert = $alert_rules[$entry['alert_test_id']];
$state = json_decode($entry['state'], TRUE);
$conditions = json_decode($alert['conditions'], TRUE);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$condition_array = array();
foreach ($state['failed'] as $failed) {
$condition_array[] = $failed['metric'] . " " . $failed['condition'] . " " . $failed['value'] . " (" . $state['metrics'][$failed['metric']] . ")";
}
$graphs = "";
$metric_array = array();
foreach ($state['metrics'] as $metric => $value) {
$metric_array[] = $metric . ' = ' . $value;
}
if (is_array($config['entities'][$entry['entity_type']]['graph'])) {
// We can draw a graph for this type/metric pair!
$graph_array = $config['entities'][$entry['entity_type']]['graph'];
foreach ($graph_array as $key => $val) {
// Check to see if we need to do any substitution
if (substr($val, 0, 1) == "@") {
$nval = substr($val, 1);
echo " replaced " . $val . " with " . $entity[$nval] . " from entity. " . PHP_EOL . "<br />";
$graph_array[$key] = $entity[$nval];
}
}
//print_r($graph_array);
//logfile('debug.log', var_export($graph_array, TRUE));
$image_data_uri = generate_alert_graph($graph_array);
//print_r($image_data_uri);
//logfile('debug.log', var_export($image_data_uri, TRUE));
$graphs .= '<img src="' . $image_data_uri . '"><br />';
unset($graph_array);
}
$message_tags = array('ALERT_STATE' => 'ALERT', 'ALERT_URL' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $entry['alert_table_id'])), 'ALERT_MESSAGE' => $alert['alert_message'], 'CONDITIONS' => implode(PHP_EOL . ' ', $condition_array), 'METRICS' => implode(PHP_EOL . ' ', $metric_array), 'DURATION' => formatUptime(time() - $entry['last_failed']), 'ENTITY_LINK' => generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']), 'ENTITY_NAME' => $entity['entity_name'], 'ENTITY_DESCRIPTION' => $entity['entity_descr'], 'ENTITY_GRAPHS' => $graphs, 'DEVICE_HOSTNAME' => $device['hostname'], 'DEVICE_LINK' => generate_device_link($device), 'DEVICE_HARDWARE' => $device['hardware'], 'DEVICE_OS' => $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'], 'DEVICE_LOCATION' => $device['location'], 'DEVICE_UPTIME' => deviceUptime($device));
$message['text'] = simple_template('alert/email_text.tpl', $message_tags, array('is_file' => TRUE));
$message_tags['CONDITIONS'] = nl2br($message_tags['CONDITIONS']);
$message_tags['METRICS'] = nl2br($message_tags['METRICS']);
$message['html'] = simple_template('alert/email_html.tpl', $message_tags, array('is_file' => TRUE));
//logfile('debug.log', var_export($message, TRUE));
alert_notify($device, alert_generate_subject('ALERT', $device, $alert, $entity), $message, $entry['alert_test_id']);
log_alert('Alert notification sent', $device, $entry, 'ALERT_NOTIFY');
$update_array['last_alerted'] = time();
$update_array['has_alerted'] = 1;
dbUpdate($update_array, 'alert_table-state', '`alert_table_id` = ?', array($entry['alert_table_id']));
} else {
echo "没有通知要求. " . (time() - $entry['last_alerted']);
}
//.........这里部分代码省略.........
示例10: print_addresses
//.........这里部分代码省略.........
//$query_netscaler_count = str_replace(array('vsvr_ip', '0.0.0.0'), array('vsvr_ipv6', '0:0:0:0:0:0:0:0'), $query_netscaler_count);
}
$entries = dbFetchRows($query_netscaler, $param_netscaler);
// Rewrite netscaler addresses
foreach ($entries as $entry) {
$ip_address = $address_type == 'ipv4' ? $entry['vsvr_ip'] : $entry['vsvr_' . $address_type];
$ip_network = $address_type == 'ipv4' ? $entry['vsvr_ip'] . '/32' : $entry['vsvr_' . $address_type] . '/128';
$ip_array[] = array('type' => 'netscaler_vsvr', 'device_id' => $entry['device_id'], 'hostname' => $entry['hostname'], 'vsvr_id' => $entry['vsvr_id'], 'vsvr_label' => $entry['vsvr_label'], 'ifAlias' => 'Netscaler: ' . $entry['vsvr_type'] . '/' . $entry['vsvr_entitytype'], $address_type . '_address' => $ip_address, $address_type . '_network' => $ip_network);
}
//print_message($query_netscaler_count);
$query = 'FROM `ip_addresses` AS A ';
$query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = A.`port_id` ';
$query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
$query .= 'LEFT JOIN `ip_networks` AS N ON N.`ip_network_id` = A.`ip_network_id` ';
$query .= $where . $query_port_permitted;
//$query_count = 'SELECT COUNT(`ip_address_id`) ' . $query;
$query = 'SELECT * ' . $query;
$query .= ' ORDER BY A.`ip_address`';
if ($ip_valid) {
$pagination = FALSE;
}
// Override by address type
$query = str_replace(array('ip_address', 'ip_network'), array($address_type . '_address', $address_type . '_network'), $query);
//$query_count = str_replace(array('ip_address', 'ip_network'), array($address_type.'_address', $address_type.'_network'), $query_count);
// Query addresses
$entries = dbFetchRows($query, $param);
$ip_array = array_merge($ip_array, $entries);
$ip_array = array_sort($ip_array, $address_type . '_address');
// Query address count
//if ($pagination) { $count = dbFetchCell($query_count, $param); }
if ($pagination) {
$count = count($ip_array);
$ip_array = array_slice($ip_array, $start, $pagesize);
}
$list = array('device' => FALSE);
if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
$list['device'] = TRUE;
}
$string = generate_box_open($vars['header']);
$string .= '<table class="' . OBS_CLASS_TABLE_STRIPED . '">' . PHP_EOL;
if (!$short) {
$string .= ' <thead>' . PHP_EOL;
$string .= ' <tr>' . PHP_EOL;
if ($list['device']) {
$string .= ' <th>Device</th>' . PHP_EOL;
}
$string .= ' <th>Interface</th>' . PHP_EOL;
$string .= ' <th>Address</th>' . PHP_EOL;
$string .= ' <th>Description</th>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' <tbody>' . PHP_EOL;
foreach ($ip_array as $entry) {
$address_show = TRUE;
if ($ip_valid) {
// If address not in specified network, don't show entry.
if ($address_type === 'ipv4') {
$address_show = Net_IPv4::ipInNetwork($entry[$address_type . '_address'], $addr . '/' . $mask);
} else {
$address_show = Net_IPv6::isInNetmask($entry[$address_type . '_address'], $addr, $mask);
}
}
if ($address_show) {
list($prefix, $length) = explode('/', $entry[$address_type . '_network']);
if (port_permitted($entry['port_id']) || $entry['type'] == 'netscaler_vsvr') {
if ($entry['type'] == 'netscaler_vsvr') {
$entity_link = generate_entity_link($entry['type'], $entry);
} else {
humanize_port($entry);
if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
$port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
}
$entity_link = generate_port_link($entry, $entry['port_label_short']) . ' ' . $port_error;
}
$device_link = generate_device_link($entry);
$string .= ' <tr>' . PHP_EOL;
if ($list['device']) {
$string .= ' <td class="entity" style="white-space: nowrap">' . $device_link . '</td>' . PHP_EOL;
}
$string .= ' <td class="entity">' . $entity_link . '</td>' . PHP_EOL;
if ($address_type === 'ipv6') {
$entry[$address_type . '_address'] = Net_IPv6::compress($entry[$address_type . '_address']);
}
$string .= ' <td>' . generate_popup_link('ip', $entry[$address_type . '_address'] . '/' . $length) . '</td>' . PHP_EOL;
$string .= ' <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
}
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
$string .= generate_box_close();
// Print pagination header
if ($pagination) {
$string = pagination($vars, $count) . $string . pagination($vars, $count);
}
// Print addresses
echo $string;
}
示例11: print_events
//.........这里部分代码省略.........
if ($list['device']) {
$string .= ' <th>设备</th>' . PHP_EOL;
}
if ($list['entity']) {
$string .= ' <th>单位</th>' . PHP_EOL;
}
$string .= ' <th>信息</th>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' <tbody>' . PHP_EOL;
foreach ($events['entries'] as $entry) {
#$icon = geteventicon($entry['message']);
#if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; }
switch ($entry['severity']) {
case "0":
// Emergency
// Emergency
case "1":
// Alert
// Alert
case "2":
// Critical
// Critical
case "3":
// Error
$entry['html_row_class'] = "error";
break;
case "4":
// Warning
$entry['html_row_class'] = "warning";
break;
case "5":
// Notification
$entry['html_row_class'] = "recovery";
break;
case "6":
// Informational
$entry['html_row_class'] = "up";
break;
case "7":
// Debugging
$entry['html_row_class'] = "suppressed";
break;
default:
}
$string .= ' <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
$string .= '<td class="state-marker"></td>' . PHP_EOL;
if ($events['short']) {
$string .= ' <td class="syslog" style="white-space: nowrap">';
$timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
$string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
} else {
$string .= ' <td style="width: 160px">';
$string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
}
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog');
$string .= ' <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
}
if ($list['entity']) {
if ($entry['entity_type'] == 'device' && !$entry['entity_id']) {
$entry['entity_id'] = $entry['device_id'];
}
if ($entry['entity_type'] == 'port') {
$this_if = get_port_by_id_cache($entry['entity_id']);
$entry['link'] = '<span class="entity"><i class="' . $config['entities']['port']['icon'] . '"></i> ' . generate_port_link($this_if, short_ifname($this_if['label'])) . '</span>';
} else {
if (!empty($config['entities'][$entry['entity_type']]['icon'])) {
$entry['link'] = '<i class="' . $config['entities'][$entry['entity_type']]['icon'] . '"></i> ' . generate_entity_link($entry['entity_type'], $entry['entity_id']);
} else {
$entry['link'] = nicecase($entry['entity_type']);
}
}
if (!$events['short']) {
$string .= ' <td>' . $entry['link'] . '</td>' . PHP_EOL;
}
}
if ($events['short']) {
$string .= ' <td class="syslog">';
if (strpos($entry['message'], $entry['link']) !== 0) {
$string .= $entry['link'] . ' ';
}
} else {
$string .= ' <td>';
}
$string .= escape_html($entry['message']) . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
// Print pagination header
if ($events['pagination_html']) {
$string = $events['pagination_html'] . $string . $events['pagination_html'];
}
// Print events
echo $string;
}
}
示例12: foreach
<th>Type</th>
<th>Status</th>
<th>Errors</th>
<th>Load</th>
</tr>
</thead>
<tbody>
<?php
foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice) {
echo " <tr>\n";
echo " <td>" . $hrdevice['hrDeviceIndex'] . "</td>\n";
if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") {
$proc_id = dbFetchCell('SELECT processor_id FROM processors WHERE device_id = ? AND hrDeviceIndex = ?', array($device['device_id'], $hrdevice['hrDeviceIndex']));
$proc_url = "device/device=" . $device['device_id'] . "/tab=health/metric=processor/";
echo " <td>" . generate_entity_link('processor', $proc_id) . "</td>\n";
$graph_array['height'] = "20";
$graph_array['width'] = "100";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $proc_id;
$graph_array['type'] = 'processor_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
echo " <td>" . $mini_graph . "</td>\n";
} elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") {
$int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']);
$interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int));
if ($interface['ifIndex']) {
示例13: generate_processor_row
function generate_processor_row($processor, $vars)
{
global $config;
$table_cols = 4;
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$table_cols++;
}
// Add a column for device.
// FIXME should that really be done here? :-)
// FIXME - not it shouldn't. we need some per-os rewriting on discovery-time.
$text_descr = $processor['processor_descr'];
$text_descr = str_replace("Routing Processor", "RP", $text_descr);
$text_descr = str_replace("Switching Processor", "SP", $text_descr);
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
$graph_array = array();
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $processor['processor_id'];
$graph_array['type'] = 'processor_usage';
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link_graph = generate_url($link_array);
$link = generate_url(array("page" => "device", "device" => $processor['device_id'], "tab" => "health", "metric" => 'processor'));
$overlib_content = generate_overlib_content($graph_array, $processor['hostname'] . " - " . $text_descr);
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
$graph_array['from'] = $config['time']['day'];
$mini_graph = generate_graph_tag($graph_array);
$perc = round($processor['processor_usage']);
$background = get_percentage_colours($perc);
$processor['html_row_class'] = $background['class'];
$row .= '<tr class="' . $processor['html_row_class'] . '">
<td class="state-marker"></td>';
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$row .= '<td class="entity">' . generate_device_link($processor) . '</td>';
}
$row .= ' <td class="entity">' . generate_entity_link('processor', $processor) . '</td>
<td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
<td><a href="' . $link_graph . '">
' . print_percentage_bar(400, 20, $perc, $perc . "%", "ffffff", $background['left'], 100 - $perc . "%", "ffffff", $background['right']) . '
</a>
</td>
</tr>
';
if ($vars['view'] == "graphs") {
$vars['graph'] = "usage";
}
if ($vars['graph']) {
$row .= '<tr class="' . $processor['html_row_class'] . '">';
$row .= '<td class="state-marker"></td>';
$row .= '<td colspan=' . $table_cols . '>';
unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $processor['processor_id'];
$graph_array['type'] = 'processor_' . $vars['graph'];
print_graph_row($graph_array, TRUE);
$row .= '</td></tr>';
}
# endif graphs
return $row;
}
示例14: array
WHERE A.`' . $ip_version . '_address` = ?', array($peer['bgpPeerRemoteAddr']));
if ($peerhost['device_id']) {
$peername = generate_device_link($peerhost, short_hostname($peerhost['hostname']), array('tab' => 'routing', 'proto' => 'bgp'));
$peer['remote_id'] = $peerhost['device_id'];
} else {
$peername = $peer['reverse_dns'];
}
// display overlib graphs
$graph_type = "bgp_updates";
$local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=" . $config['time']['day'] . "&to=" . $config['time']['now'] . "&width=500&height=150&afi=ipv4&safi=unicast";
$localaddresslink = "<span class=entity-title><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$local_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\">" . $peer['human_localip'] . "</a></span>";
if ($peer['remote_id']) {
$graph_type = "bgp_updates";
$peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=" . $config['time']['day'] . "&to=" . $config['time']['now'] . "&width=500&height=150";
$peeraddresslink = "<span class=entity-title><a href='device/device=" . $peer['remote_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$peer_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\">" . $peer['human_remoteip'] . "</a></span>";
$peeraddresslink = generate_entity_link('bgp_peer', $peer);
} else {
$peeraddresslink = "<span class=entity-title>" . $peer['human_remoteip'] . "</span>";
}
echo '<tr class="' . $peer['html_row_class'] . '">';
unset($sep);
foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?", array($peer['device_id'], $peer['bgpPeerRemoteAddr'])) as $afisafi) {
$afi = $afisafi['afi'];
$safi = $afisafi['safi'];
$this_afisafi = $afi . $safi;
$peer['afi'] .= $sep . $afi . "." . $safi;
$sep = "<br />";
$peer['afisafi'][$this_afisafi] = 1;
// Build a list of valid AFI/SAFI for this peer
}
unset($sep);
示例15: unset
$graph_array['to'] = $config['time']['now'];
$graph_array['device'] = $device['device_id'];
$graph_array['id'] = $proc['id'];
if (is_array($proc['id'])) {
$graph_array['type'] = "multi-processor_usage";
} else {
$graph_array['type'] = $graph_type;
}
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$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';
# the 00 at the end makes the area transparent.
// $graph_array['style'][] = 'margin-top: -6px';
$count_button = $proc['count'] > 1 ? '<span class="label pull-right" style="margin-top: 2px;"><i class="icon-remove"></i> ' . $proc['count'] . '</span>' : '';
echo '<tr class="' . $background['class'] . '">
<td class="state-marker"></td>
<td><span class="entity text-nowrap">' . generate_entity_link('processor', $proc, $text_descr) . '</span>' . $count_button . '</td>
<td style="width: 200px">' . overlib_link($link, print_percentage_bar(200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content) . '</td>
</tr>';
}
echo "</table>";
echo generate_box_close();
}
// EOF