• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_entity_by_id_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_entity_by_id_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP get_entity_by_id_cache函数的具体用法?PHP get_entity_by_id_cache怎么用?PHP get_entity_by_id_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_entity_by_id_cache函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: implode

                        $response .= implode(PHP_EOL, $whois_parts);
                        //print_vars($request['data']['records']);
                    }
                }
            }
            if ($response) {
                $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip] = '<pre class="small">' . $response . '</pre>';
                echo $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip];
            } else {
                echo 'Not Found';
            }
        } else {
            echo 'Not correct IP address';
        }
        exit;
        break;
    default:
        if (is_array($config['entities'][$vars['entity_type']])) {
            if (is_numeric($vars['entity_id']) && is_entity_permitted($vars['entity_id'], $vars['entity_type'])) {
                $entity = get_entity_by_id_cache($vars['entity_type'], $vars['entity_id']);
                echo generate_entity_popup($entity, $vars);
            } else {
                print_warning("You are not permitted to view this entity.");
            }
        } else {
            print_error("Unknown entity type.");
        }
        exit;
        break;
}
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:entity_popup.php


示例2: print_alert_table

/**
 * Display alert_table entries.
 *
 * @param array $vars
 * @return none
 *
 */
function print_alert_table($vars)
{
    global $alert_rules;
    global $config;
    // This should be set outside, but do it here if it isn't
    if (!is_array($alert_rules)) {
        $alert_rules = cache_alert_rules();
    }
    /// WARN HERE
    if (isset($vars['device']) && !isset($vars['device_id'])) {
        $vars['device_id'] = $vars['device'];
    }
    if (isset($vars['entity']) && !isset($vars['entity_id'])) {
        $vars['entity_id'] = $vars['entity'];
    }
    // Short? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    list($query, $param, $query_count) = build_alert_table_query($vars);
    // Fetch alerts
    $count = dbFetchCell($query_count, $param);
    $alerts = dbFetchRows($query, $param);
    // Set which columns we're going to show.
    // We hide the columns that have been given as search options via $vars
    $list = array('device_id' => FALSE, 'entity_id' => FALSE, 'entity_type' => FALSE, 'alert_test_id' => FALSE);
    foreach ($list as $argument => $nope) {
        if (!isset($vars[$argument]) || empty($vars[$argument]) || $vars[$argument] == "all") {
            $list[$argument] = TRUE;
        }
    }
    // Hide device if we know entity_id
    if (isset($vars['entity_id'])) {
        $list['device_id'] = FALSE;
    }
    // Hide entity_type if we know the alert_test_id
    if (isset($vars['alert_test_id']) || TRUE) {
        $list['entity_type'] = FALSE;
    }
    // Hide entity types in favour of icons to save space
    if ($vars['pagination'] && !$short) {
        $pagination_html = pagination($vars, $count);
        echo $pagination_html;
    }
    echo '<table class="table table-condensed table-bordered table-striped table-rounded table-hover">
  <thead>
    <tr>
      <th class="state-marker"></th>
      <th style="width: 1px;"></th>';
    // No table id
    //<th style="width: 5%;">Id</th>');
    if ($list['device_id']) {
        echo '      <th style="width: 15%">设备</th>';
    }
    if ($list['alert_test_id']) {
        echo '      <th style="min-width: 15%;">警报</th>';
    }
    if ($list['entity_type']) {
        echo '      <th style="width: 10%">类型</th>';
    }
    if ($list['entity_id']) {
        echo '      <th style="">实体</th>';
    }
    echo '
      <th style="width: 20px">状态</th>
      <th style="width: 100px;">信息</th>
      <th style="width: 90px;">已检测</th>
      <th style="width: 90px;">已更改</th>
      <th style="width: 90px;">警告</th>
      <th style="width: 20px;"></th>
    </tr>
  </thead>
  <tbody>' . PHP_EOL;
    foreach ($alerts as $alert) {
        // Process the alert entry, generating colours and classes from the data
        humanize_alert_entry($alert);
        // Get the entity array using the cache
        $entity = get_entity_by_id_cache($alert['entity_type'], $alert['entity_id']);
        // Get the device array using the cache
        $device = device_by_id_cache($alert['device_id']);
        // Get the entity_name.
        ### FIXME - This is probably duplicated effort from above. We should pass it $entity
        $entity_name = entity_name($alert['entity_type'], $entity);
        // Set the alert_rule from the prebuilt cache array
        $alert_rule = $alert_rules[$alert['alert_test_id']];
        echo '<tr class="' . $alert['html_row_class'] . '" style="cursor: pointer;" onclick="location.href=\'' . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $alert['alert_table_id'])) . '\'">';
        echo '<td class="state-marker"></td>';
        echo '<td style="width: 1px;"></td>';
        // If we know the device, don't show the device
        if ($list['device_id']) {
            echo '<td><span class="entity-title">' . generate_device_link($device) . '</span></td>';
        }
        // Print link to the alert rule page
        if ($list['alert_test_id']) {
            echo '<td><a href="', generate_url(array('page' => 'alert_check', 'alert_test_id' => $alert_rule['alert_test_id'])), '">', $alert_rule['alert_name'], '</a></td>';
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:alert.inc.php


示例3: generate_entity_link

function generate_entity_link($type, $entity, $text = NULL, $graph_type = NULL)
{
    global $config, $entity_cache;
    if (is_numeric($entity)) {
        $entity = get_entity_by_id_cache($type, $entity);
    }
    switch ($type) {
        case "mempool":
            if (empty($text)) {
                $text = $entity['mempool_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'temperature'));
            break;
        case "processor":
            if (empty($text)) {
                $text = $entity['processor_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'temperature'));
            break;
        case "sensor":
            if (empty($text)) {
                $text = $entity['sensor_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'temperature'));
            break;
        case "port":
            $link = generate_port_link($entity, $text, $graph_type);
            break;
        case "storage":
            if (empty($text)) {
                $text = $entity['storage_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
            break;
        default:
            $link = $entity[$type . '_id'];
    }
    return $link;
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:39,代码来源:functions.inc.php


示例4: print_alert_table

/**
 * Display alert_table entries.
 *
 * @param array $vars
 * @return none
 *
 */
function print_alert_table($vars)
{
    global $alert_rules;
    global $config;
    // This should be set outside, but do it here if it isn't
    if (!is_array($alert_rules)) {
        $alert_rules = cache_alert_rules();
    }
    /// WARN HERE
    if (isset($vars['device']) && !isset($vars['device_id'])) {
        $vars['device_id'] = $vars['device'];
    }
    if (isset($vars['entity']) && !isset($vars['entity_id'])) {
        $vars['entity_id'] = $vars['entity'];
    }
    // Short? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    list($query, $param, $query_count) = build_alert_table_query($vars);
    // Fetch alerts
    $count = dbFetchCell($query_count, $param);
    $alerts = dbFetchRows($query, $param);
    // Set which columns we're going to show.
    // We hide the columns that have been given as search options via $vars
    $list = array('device_id' => FALSE, 'entity_id' => FALSE, 'entity_type' => FALSE, 'alert_test_id' => FALSE);
    foreach ($list as $argument => $nope) {
        if (!isset($vars[$argument]) || empty($vars[$argument]) || $vars[$argument] == "all") {
            $list[$argument] = TRUE;
        }
    }
    if ($vars['format'] != "condensed") {
        $list['checked'] = TRUE;
        $list['changed'] = TRUE;
        $list['alerted'] = TRUE;
    }
    if ($vars['short'] == TRUE) {
        $list['checked'] = FALSE;
        $list['alerted'] = FALSE;
    }
    // Hide device if we know entity_id
    if (isset($vars['entity_id'])) {
        $list['device_id'] = FALSE;
    }
    // Hide entity_type if we know the alert_test_id
    if (isset($vars['alert_test_id']) || TRUE) {
        $list['entity_type'] = FALSE;
    }
    // Hide entity types in favour of icons to save space
    if ($vars['pagination'] && !$short) {
        $pagination_html = pagination($vars, $count);
        echo $pagination_html;
    }
    echo generate_box_open($vars['header']);
    echo '<table class="table table-condensed  table-striped  table-hover">';
    if ($vars['no_header'] == FALSE) {
        echo '
  <thead>
    <tr>
      <th class="state-marker"></th>
      <th style="width: 1px;"></th>';
        if ($list['device_id']) {
            echo '      <th style="width: 15%">Device</th>';
        }
        if ($list['entity_type']) {
            echo '      <th style="width: 10%">Type</th>';
        }
        if ($list['entity_id']) {
            echo '      <th style="">Entity</th>';
        }
        if ($list['alert_test_id']) {
            echo '      <th style="min-width: 15%;">Alert</th>';
        }
        echo '
      <th style="width: 100px;">Status</th>';
        if ($list['checked']) {
            echo '      <th style="width: 95px;">Checked</th>';
        }
        if ($list['changed']) {
            echo '      <th style="width: 95px;">Changed</th>';
        }
        if ($list['alerted']) {
            echo '      <th style="width: 95px;">Alerted</th>';
        }
        echo '    <th style="width: 45px;"></th>
    </tr>
  </thead>';
    }
    echo '<tbody>' . PHP_EOL;
    foreach ($alerts as $alert) {
        // Process the alert entry, generating colours and classes from the data
        humanize_alert_entry($alert);
        // Get the entity array using the cache
        $entity = get_entity_by_id_cache($alert['entity_type'], $alert['entity_id']);
        // Get the device array using the cache
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:alert.inc.php


示例5: generate_entity_popup

function generate_entity_popup($entity, $vars)
{
    if (is_numeric($entity)) {
        $entity = get_entity_by_id_cache($entity, $vars['entity_type']);
    }
    $device = device_by_id_cache($entity['device_id']);
    $content = generate_device_popup_header($device);
    $content .= generate_entity_popup_header($entity, $vars);
    $content .= generate_entity_popup_graphs($entity, $vars);
    return $content;
}
开发者ID:Natolumin,项目名称:observium,代码行数:11,代码来源:generic.inc.php


示例6: 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 />";
                }
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:alerts.inc.php


示例7: alert_notifier

/**
 * Generate notifications for an alert entry
 *
 * @param array entry
 * @return NULL
 */
function alert_notifier($entry, $type = "alert")
{
    global $config, $alert_rules;
    $device = device_by_id_cache($entry['device_id']);
    $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']] . ")";
    }
    $metric_array = array();
    foreach ($state['metrics'] as $metric => $value) {
        $metric_array[] = $metric . ' = ' . $value;
    }
    $graphs = array();
    $graph_done = array();
    foreach ($state['metrics'] as $metric => $value) {
        if ($config['email']['graphs'] !== FALSE && is_array($config['entities'][$entry['entity_type']]['metric_graphs'][$metric]) && !in_array($config['entities'][$entry['entity_type']]['metric_graphs'][$metric]['type'], $graph_done)) {
            $graph_array = $config['entities'][$entry['entity_type']]['metric_graphs'][$metric];
            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];
                }
            }
            $image_data_uri = generate_alert_graph($graph_array);
            $image_url = generate_graph_url($graph_array);
            $graphs[] = array('label' => $graph_array['type'], 'type' => $graph_array['type'], 'url' => $image_url, 'data' => $image_data_uri);
            $graph_done[] = $graph_array['type'];
        }
        unset($graph_array);
    }
    if ($config['email']['graphs'] !== FALSE && count($graph_done) == 0 && 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_vars($graph_array);
        $image_data_uri = generate_alert_graph($graph_array);
        $image_url = generate_graph_url($graph_array);
        $graphs[] = array('label' => $graph_array['type'], 'type' => $graph_array['type'], 'url' => $image_url, 'data' => $image_data_uri);
        unset($graph_array);
    }
    $graphs_html = "";
    foreach ($graphs as $graph) {
        $graphs_html .= '<h4>' . $graph['type'] . '</h4>';
        $graphs_html .= '<a href="' . $graph['url'] . '"><img src="' . $graph['data'] . '"></a><br />';
    }
    //print_vars($graphs);
    //print_vars($graphs_html);
    //print_vars($entry);
    $message_tags = array('ALERT_STATE' => $entry['alert_status'] == '1' ? "RECOVER" : "ALERT", 'ALERT_URL' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'alert', 'alert_entry' => $entry['alert_table_id'])), 'ALERT_ID' => $entry['alert_table_id'], 'ALERT_MESSAGE' => $alert['alert_message'], 'CONDITIONS' => implode(PHP_EOL . '             ', $condition_array), 'METRICS' => implode(PHP_EOL . '             ', $metric_array), 'DURATION' => $entry['alert_status'] == '1' ? $entry['last_ok'] > 0 ? formatUptime(time() - $entry['last_ok']) . " (" . format_unixtime($entry['last_ok']) . ")" : "Unknown" : ($entry['last_ok'] > 0 ? formatUptime(time() - $entry['last_ok']) . " (" . format_unixtime($entry['last_ok']) . ")" : "Unknown"), 'ENTITY_LINK' => generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']), 'ENTITY_NAME' => $entity['entity_name'], 'ENTITY_TYPE' => $alert['entity_type'], 'ENTITY_DESCRIPTION' => $entity['entity_descr'], 'ENTITY_GRAPHS_ARRAY' => json_encode($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));
    //logfile('debug.log', var_export($message, TRUE));
    $title = alert_generate_subject($device, $message_tags['ALERT_STATE'], $message_tags);
    $message_tags['TITLE'] = $title;
    $alert_id = $entry['alert_test_id'];
    $notify_status = FALSE;
    // Set alert notify status to FALSE by default
    $notification_type = 'alert';
    $transports = get_alert_contacts($device, $alert_id, $notification_type);
    if (!empty($transports)) {
        // WARNING, alerts queue currently experimental
        if (isset($config['alerts']['queue']) && isset($config['alerts']['queue'])) {
            // Add notification to queue
            $notification = array('device_id' => $device['device_id'], 'log_id' => $log_id, 'aca_type' => $notification_type, 'endpoints' => json_encode($transports), 'message_graphs' => $message_tags['ENTITY_GRAPHS_ARRAY'], 'notification_added' => time(), 'notification_lifetime' => 300, 'notification_entry' => json_encode($entry));
            $notification_message_tags = $message_tags;
            unset($notification_message_tags['ENTITY_GRAPHS_ARRAY']);
            $notification['message_tags'] = json_encode($notification_message_tags);
            $notification_id = dbInsert($notification, 'notifications_queue');
        } else {
            // Use classic instant notifications send
            $notification_count = 0;
            foreach ($transports as $method => $endpoints) {
                if (isset($config['alerts']['disable'][$method]) && $config['alerts']['disable'][$method]) {
                    continue;
                }
                // Skip if method disabled globally
                foreach ($endpoints as $endpoint) {
                    $method_include = $config['install_dir'] . "/includes/alerting/" . $method . ".inc.php";
                    if (is_file($method_include)) {
                        print_cli_data("Notifying", "[" . $method . "] " . $endpoint['contact_descr'] . ": " . $endpoint['contact_endpoint']);
                        // Split out endpoint data as stored JSON in the database into array for use in transport
                        // The original string also remains available as the contact_endpoint key
                        foreach (json_decode($endpoint['contact_endpoint']) as $field => $value) {
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:alerts.inc.php


示例8: array

            } else {
                $update_state['ignore_until'] = array('NULL');
            }
            if (is_array($update_state)) {
                $up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` =  ?', array($vars['alert_entry']));
            }
            // Refresh array because we've changed the database.
            $entry = get_alert_entry_by_id($vars['alert_entry']);
        }
        // End actions
        humanize_alert_entry($entry);
        $alert_rules = cache_alert_rules();
        $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']);
        //  r($entry);
        //  r($alert);
        ?>

<div class="row">
  <div class="col-md-3">
    <div class="box box-solid">
      <div class="box-header with-border">
        <!-- <i class="oicon-bell"></i> --><h3 class="box-title">Alert Details</h3>
      </div>
      <div class="box-body no-padding">
        <table class="table table-condensed  table-striped ">
          <tbody>
            <tr><th>Type</th><td><?php 
        echo '<i class="' . $config['entities'][$alert['entity_type']]['icon'] . '"></i> ' . nicecase($entry['entity_type']);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:alert.inc.php


示例9: get_entity_by_id_cache

<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
if (is_numeric($vars['id']) && ($alert = get_alert_entry_by_id($vars['id']))) {
    $entity = get_entity_by_id_cache($alert['entity_type'], $alert['entity_id']);
    $device = device_by_id_cache($alert['device_id']);
    if (device_permitted($device['device_id']) || $auth) {
        $title = generate_device_link($device);
        $title_array = array();
        $title_array[] = array('text' => $device['hostname'], 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'])));
        $auth = TRUE;
        $rrd_filename = get_rrd_path($device, "alert-" . $alert['alert_table_id']);
    }
} else {
    // error?
}
开发者ID:Natolumin,项目名称:observium,代码行数:25,代码来源:auth.inc.php


示例10: foreach

            // array index -> ['measured']['port']['345'][] = sensor array
            $sensors_db['measured'][$entry['measured_class']][$entry['measured_entity']][] = $entry;
        } else {
            $sensors_db[$sensor_type][$entry['sensor_id']] = $entry;
        }
    }
}
//r($sensors_db['measured']);
// Now print founded bundle (measured_class+sensor)
if (isset($sensors_db['measured'])) {
    foreach ($sensors_db['measured'] as $measured_class => $measured_entity) {
        $box_args = array('title' => nicecase($measured_class) . ' sensors', 'icon' => 'oicon-node');
        echo generate_box_open($box_args);
        echo ' <table class="table table-condensed table-striped">';
        foreach ($measured_entity as $entity_id => $entry) {
            $entity = get_entity_by_id_cache($measured_class, $entity_id);
            $entity_name = entity_name($measured_class, $entity);
            $entity_link = generate_entity_link($measured_class, $entity);
            $entity_type = entity_type_translate_array($measured_class);
            //echo('      <tr class="'.$port['row_class'].'">
            //  <td class="state-marker"></td>
            echo '      <tr>
        <td colspan="6" class="entity"><i class="' . $entity_type['icon'] . '"></i> ' . $entity_link . '</td></tr>';
            foreach ($entry as $sensor) {
                // Remove port name from sensor description
                $sensor['sensor_descr'] = trim(str_ireplace($entity_name, '', $sensor['sensor_descr']));
                if (empty($sensor['sensor_descr'])) {
                    // Some time sensor descriptions equals to entity name
                    $sensor['sensor_descr'] = nicecase($sensor['sensor_class']);
                }
                print_sensor_row($sensor, $vars);
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:sensors.inc.php


示例11: generate_entity_link

function generate_entity_link($entity_type, $entity, $text = NULL, $graph_type = NULL, $escape = TRUE, $short = FALSE)
{
    if (is_numeric($entity)) {
        $entity = get_entity_by_id_cache($entity_type, $entity);
    }
    entity_rewrite($entity_type, $entity);
    switch ($entity_type) {
        case "device":
            $link = generate_device_link($entity);
            break;
        case "mempool":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'mempool'));
            break;
        case "processor":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'processor'));
            break;
        case "status":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'status', 'id' => $entity['status_id']));
            break;
        case "sensor":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => $entity['sensor_class'], 'id' => $entity['sensor_id']));
            break;
        case "printersupply":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'printing', 'supply' => $entity['supply_type']));
            break;
        case "port":
            $link = generate_port_link($entity, NULL, $graph_type, $escape, $short);
            break;
        case "storage":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
            break;
        case "bgp_peer":
            $url = generate_url(array('page' => 'device', 'device' => $entity['peer_device_id'] ? $entity['peer_device_id'] : $entity['device_id'], 'tab' => 'routing', 'proto' => 'bgp'));
            break;
        case "netscalervsvr":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_vsvr', 'vsvr' => $entity['vsvr_id']));
            break;
        case "netscalersvc":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_services', 'svc' => $entity['svc_id']));
            break;
        case "netscalersvcgrpmem":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_servicegroupmembers', 'svc' => $entity['svc_id']));
            break;
        case "sla":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'slas', 'id' => $entity['sla_id']));
            break;
        case "pseudowire":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'pseudowires', 'id' => $entity['pseudowire_id']));
            break;
        case "maintenance":
            $url = generate_url(array('page' => 'alert_maintenance', 'maintenance' => $entity['maint_id']));
            break;
        case "group":
            $url = generate_url(array('page' => 'group', 'group_id' => $entity['group_id']));
            break;
        case "virtualmachine":
            // If we know this device by its vm name in our system, create a link to it, else just print the name.
            if (get_device_id_by_hostname($entity['vm_name'])) {
                $link = generate_device_link(device_by_name($entity['vm_name']));
            } else {
                // Hardcode $link to just show the name, no actual link
                $link = $entity['vm_name'];
            }
            break;
        default:
            $url = NULL;
    }
    if (!isset($link)) {
        if (!isset($text)) {
            if ($short && $entity['entity_shortname']) {
                $text = $entity['entity_shortname'];
            } else {
                $text = $entity['entity_name'];
            }
        }
        if ($escape) {
            $text = escape_html($text);
        }
        $link = '<a href="' . $url . '" class="entity-popup ' . $entity['html_class'] . '" data-eid="' . $entity['entity_id'] . '" data-etype="' . $entity_type . '">' . $text . '</a>';
    }
    return $link;
}
开发者ID:Natolumin,项目名称:observium,代码行数:82,代码来源:entities.inc.php


示例12: generate_entity_link

function generate_entity_link($type, $entity, $text = NULL, $graph_type = NULL)
{
    global $config, $entity_cache;
    if (is_numeric($entity)) {
        $entity = get_entity_by_id_cache($type, $entity);
    }
    switch ($type) {
        case "mempool":
            if (empty($text)) {
                $text = $entity['mempool_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'mempool'));
            break;
        case "processor":
            if (empty($text)) {
                $text = $entity['processor_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'processor'));
            break;
        case "sensor":
            if (empty($text)) {
                $text = $entity['sensor_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => $entity['sensor_class']));
            break;
        case "toner":
            if (empty($text)) {
                $text = $entity['toner_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'printing'));
            break;
        case "port":
            $link = generate_port_link($entity, $text, $graph_type);
            break;
        case "storage":
            if (empty($text)) {
                $text = $entity['storage_descr'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
            break;
        case "bgp_peer":
            if (Net_IPv6::checkIPv6($entity['bgpPeerRemoteAddr'])) {
                $addr = Net_IPv6::compress($entity['bgpPeerRemoteAddr']);
            } else {
                $addr = $entity['bgpPeerRemoteAddr'];
            }
            if (empty($text)) {
                $text = $addr . " (AS" . $entity['bgpPeerRemoteAs'] . ")";
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'routing', 'proto' => 'bgp'));
            break;
        case "netscaler_vsvr":
            if (empty($text)) {
                $text = $entity['vsvr_label'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_vsvr', 'vsvr' => $entity['vsvr_id']));
            break;
        case "netscaler_svc":
            if (empty($text)) {
                $text = $entity['svc_label'];
            }
            $link = generate_link($text, array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_services', 'svc' => $entity['svc_id']));
            break;
        default:
            $link = $entity[$type . '_id'];
    }
    return $link;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:68,代码来源:entities.inc.php


示例13: generate_entity_link

function generate_entity_link($entity_type, $entity, $text = NULL, $graph_type = NULL, $escape = TRUE)
{
    global $config, $entity_cache;
    if (is_numeric($entity)) {
        $entity = get_entity_by_id_cache($entity_type, $entity);
    }
    entity_rewrite($entity_type, $entity);
    // Rewrite sensor subtypes to 'sensor'
    // $translate = entity_type_translate_array($type);
    // if (isset($translate['parent_type'])) { $type = $translate['parent_type']; }
    switch ($entity_type) {
        case "device":
            $link = generate_device_link($entity);
            break;
        case "mempool":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'mempool'));
            break;
        case "processor":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'processor'));
            break;
        case "status":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'status'));
            break;
        case "sensor":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => $entity['sensor_class']));
            break;
        case "toner":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'printing'));
            break;
        case "port":
            $link = generate_port_link($entity, NULL, $graph_type, $escape);
            break;
        case "storage":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'health', 'metric' => 'storage'));
            break;
        case "bgp_peer":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'routing', 'proto' => 'bgp'));
            break;
        case "netscaler_vsvr":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_vsvr', 'vsvr' => $entity['vsvr_id']));
            break;
        case "netscaler_svc":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'loadbalancer', 'type' => 'netscaler_services', 'svc' => $entity['svc_id']));
            break;
        case "sla":
            $url = generate_url(array('page' => 'device', 'device' => $entity['device_id'], 'tab' => 'slas'));
            break;
        default:
            $url = NULL;
    }
    if (!isset($link)) {
        if (!isset($text)) {
            $text = $entity['entity_name'];
        }
        if ($escape) {
            $text = escape_html($text);
        }
        $link = '<a href="' . $url . '" class="entity-popup ' . $entity['html_class'] . '" data-eid="' . $entity['entity_id'] . '" data-etype="' . $entity_type . '">' . $text . '</a>';
    }
    return $link;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:61,代码来源:entities.inc.php


示例14: foreach

   if ($list['group_id']) {
       echo '      <th style="min-width: 15%;">分组</th>';
   }
   if ($list['entity_type']) {
       echo '      <th style="width: 10%">类型</th>';
   }
   if ($list['entity_id']) {
       echo '      <th style="">实体</th>';
   }
   echo '
   </tr>
 </thead>
 <tbody>' . PHP_EOL;
   foreach ($members as $member) {
       // Get the entity array using the cache
       $entity = get_entity_by_id_cache($member['entity_type'], $member['entity_id']);
       // Get the device array using the cache
       $device = device_by_id_cache($member['device_id']);
       // Get the entity_name.
       ### FIXME - This is probably duplicated effort from above. We should pass it $entity
       $entity_name = entity_name($member['entity_type'], $entity);
       echo '<tr class="' . $entity['html_row_class'] . '" style="cursor: pointer;">';
       echo '<td style="width: 1px; background-color: ' . $entity['table_tab_colour'] . '; margin: 0px; padding: 0px"></td>';
       echo '<td style="width: 1px;"></td>';
       // If we know the device, don't show the device
       if ($list['device_id']) {
           echo '<td><span class="entity-title">' . generate_device_link($device) . '</span></td>';
       }
       // If we're showing all entity types, print the entity type here
       if ($list['entity_type']) {
           echo '<td>' . nicecase($member['entity_type']) . '</td>';
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:group.inc.php


示例15: get_port_by_id_cache

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_entity_from_uuid函数代码示例发布时间:2022-05-15
下一篇:
PHP get_entity_as_row函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap