Esempio n. 1
0
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health');
//if (!$vars['metric']) { $vars['metric'] = "overview"; }
$navbar['brand'] = "SLAs";
$navbar['class'] = "navbar-narrow";
if (!isset($vars['rtt_type'])) {
    $navbar['options']['all']['class'] = "active";
}
$navbar['options']['all']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'slas', 'rtt_type' => NULL));
$navbar['options']['all']['text'] = "All SLAs";
$vars_type = $vars;
unset($vars_type['rtt_type']);
// Do not filter rtt_type
$sql = generate_sla_query($vars_type);
$slas = dbFetchRows($sql);
foreach ($slas as $sla) {
    $rtt_type = $sla['rtt_type'];
    if (!in_array($rtt_type, $rtt_types)) {
        if (isset($config['sla_type_labels'][$rtt_type])) {
            $text = $config['sla_type_labels'][$rtt_type];
        } else {
            $text = nicecase($rtt_type);
        }
    }
    $rtt_types[$rtt_type] = $text;
}
asort($rtt_types);
foreach ($rtt_types as $type => $text) {
    if ($vars['rtt_type'] == $type) {
Esempio n. 2
0
function print_sla_table($vars)
{
    $sql = generate_sla_query($vars);
    $slas = array();
    foreach (dbFetchRows($sql) as $sla) {
        if (isset($GLOBALS['cache']['devices']['id'][$sla['device_id']])) {
            $sla['hostname'] = $GLOBALS['cache']['devices']['id'][$sla['device_id']]['hostname'];
            $slas[] = $sla;
        }
    }
    // Sorting
    // FIXME. Sorting can be as function, but in must before print_table_header and after get table from db
    switch ($vars['sort_order']) {
        case 'desc':
            $sort_order = SORT_DESC;
            $sort_neg = SORT_ASC;
            break;
        case 'reset':
            unset($vars['sort'], $vars['sort_order']);
            // no break here
        // no break here
        default:
            $sort_order = SORT_ASC;
            $sort_neg = SORT_DESC;
    }
    switch ($vars['sort']) {
        case 'device':
            $slas = array_sort_by($slas, 'hostname', $sort_order, SORT_STRING);
            break;
        case 'descr':
            $slas = array_sort_by($slas, 'sla_index', $sort_order, SORT_STRING, 'sla_tag', $sort_order, SORT_STRING);
            break;
        case 'owner':
            $slas = array_sort_by($slas, 'sla_owner', $sort_order, SORT_STRING);
            break;
        case 'type':
            $slas = array_sort_by($slas, 'rtt_type', $sort_order, SORT_STRING);
            break;
        case 'event':
            $slas = array_sort_by($slas, 'rtt_event', $sort_order, SORT_STRING);
            break;
        case 'sense':
            $slas = array_sort_by($slas, 'rtt_sense', $sort_order, SORT_STRING);
            break;
        case 'last_change':
            $slas = array_sort_by($slas, 'rtt_last_change', $sort_neg, SORT_NUMERIC);
            break;
        case 'rtt':
            $slas = array_sort_by($slas, 'rtt_value', $sort_order, SORT_NUMERIC);
            break;
        default:
            // Not sorted
    }
    $slas_count = count($slas);
    // Pagination
    $pagination_html = pagination($vars, $slas_count);
    echo $pagination_html;
    if ($vars['pageno']) {
        $slas = array_chunk($slas, $vars['pagesize']);
        $slas = $slas[$vars['pageno'] - 1];
    }
    // End Pagination
    echo generate_box_open();
    print_sla_table_header($vars);
    foreach ($slas as $sla) {
        print_sla_row($sla, $vars);
    }
    echo '</tbody></table>';
    echo generate_box_close();
    echo $pagination_html;
}
Esempio n. 3
0
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$link_array = array('page' => 'slas');
$navbar['brand'] = 'SLAs';
$navbar['class'] = 'navbar-narrow';
if (!isset($vars['rtt_type'])) {
    $navbar['options']['all']['class'] = 'active';
}
$navbar['options']['all']['url'] = generate_url(array('page' => 'slas', 'rtt_type' => NULL));
$navbar['options']['all']['text'] = 'All SLAs';
$vars_filter = $vars;
unset($vars_filter['rtt_type'], $vars_filter['owner']);
// Do not filter rtt_type and owner for navbar
$sql = generate_sla_query($vars_filter);
foreach (dbFetchRows($sql) as $sla) {
    $owner = $sla['sla_owner'] == '' ? OBS_VAR_UNSET : $sla['sla_owner'];
    if (!isset($vars['rtt_type']) || $vars['rtt_type'] == $sla['rtt_type']) {
        if (!isset($sla_owners[$owner])) {
            $sla_owners[$owner] = nicecase($owner);
        }
    }
    if (!isset($vars['owner']) || $vars['owner'] == $owner) {
        $rtt_type = $sla['rtt_type'];
        if (isset($config['sla_type_labels'][$rtt_type])) {
            $rtt_label = $config['sla_type_labels'][$rtt_type];
        } else {
            $rtt_label = nicecase($rtt_type);
        }
        // Combinate different types with same label