Example #1
0
function get_authlog_array($vars)
{
    $array = array();
    // Short authlog? (no pagination, small out)
    $array['short'] = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $array['pagination'] = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $array['pageno'] = $vars['pageno'];
    $array['pagesize'] = $vars['pagesize'];
    $start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
    $pagesize = $array['pagesize'];
    $query = " FROM `authlog`";
    $query_count = 'SELECT COUNT(`id`) ' . $query;
    $query_updated = 'SELECT MAX(`datetime`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `datetime` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query authlog
    $array['entries'] = dbFetchRows($query, $param);
    // Query authlog count
    if ($array['pagination'] && !$array['short']) {
        $array['count'] = dbFetchCell($query_count, $param);
        $array['pagination_html'] = pagination($vars, $array['count']);
    } else {
        $array['count'] = count($array['entries']);
    }
    // Query for last timestamp
    $array['updated'] = dbFetchCell($query_updated, $param);
    return $array;
}
Example #2
0
function service_get($device = null, $service = null)
{
    $sql_query = "SELECT `service_id`,`device_id`,`service_ip`,`service_type`,`service_desc`,`service_param`,`service_ignore`,`service_status`,`service_changed`,`service_message`,`service_disabled`,`service_ds` FROM `services` WHERE";
    $sql_param = array();
    $add = 0;
    d_echo("SQL Query: " . $sql_query);
    if (!is_null($service)) {
        // Add a service filter to the SQL query.
        $sql_query .= " `service_id` = ? AND";
        $sql_param[] = $service;
        $add++;
    }
    if (!is_null($device)) {
        // Add a device filter to the SQL query.
        $sql_query .= " `device_id` = ? AND";
        $sql_param[] = $device;
        $add++;
    }
    if ($add == 0) {
        // No filters, remove " WHERE" -6
        $sql_query = substr($sql_query, 0, strlen($sql_query) - 6);
    } else {
        // We have filters, remove " AND" -4
        $sql_query = substr($sql_query, 0, strlen($sql_query) - 4);
    }
    d_echo("SQL Query: " . $sql_query);
    // $service is not null, get only what we want.
    $services = dbFetchRows($sql_query, $sql_param);
    d_echo("Service Array: " . print_r($services, true) . "\n");
    return $services;
}
Example #3
0
/**
 * Build a cache of device-specific alert conditions
 *
 * @return array
 * @param device_id
*/
function cache_conditions_device($device_id)
{
    $cache = array();
    foreach (dbFetchRows("SELECT * FROM `alert_conditions` WHERE `device_id` = ?", array($device_id)) as $entry) {
        $cache[$entry['type']][$entry['subtype']][$entry['entity']][$entry['metric']][] = array('condition' => $entry['operator'], 'value' => $entry['value'], 'severity' => $entry['severity'], 'alerter' => $entry['alerter'], 'enable' => $entry['enable']);
    }
    return $cache;
}
Example #4
0
/**
 * Fetch all info about a Proxmox VM
 * @param integer $vmid Proxmox VM ID
 * @param string $c Clustername
 * @return array An array with all info of this VM on this cluster, including ports
 */
function proxmox_vm_info($vmid, $c)
{
    $vm = dbFetchRow("SELECT pm.*, d.hostname AS host, d.device_id FROM proxmox pm, devices d WHERE pm.device_id = d.device_id AND pm.vmid = ? AND pm.cluster = ?", array($vmid, $c));
    $appid = dbFetchRow("SELECT app_id FROM applications WHERE device_id = ? AND app_type = ?", array($vm['device_id'], 'proxmox'));
    $vm['ports'] = dbFetchRows("SELECT * FROM proxmox_ports WHERE vm_id = ?", array($vm['id']));
    $vm['app_id'] = $appid['app_id'];
    return $vm;
}
Example #5
0
function get_instance_stats()
{
    // Overall Ports/Devices statistics
    $stats['ports'] = dbFetchCell("SELECT COUNT(*) FROM ports");
    $stats['devices'] = dbFetchCell("SELECT COUNT(*) FROM devices");
    $stats['edition'] = OBSERVIUM_EDITION;
    // Per-feature statistics
    $stats['sensors'] = dbFetchCell("SELECT COUNT(*) FROM `sensors`");
    $stats['services'] = dbFetchCell("SELECT COUNT(*) FROM `services`");
    $stats['applications'] = dbFetchCell("SELECT COUNT(*) FROM `applications`");
    $stats['bgp'] = dbFetchCell("SELECT COUNT(*) FROM `bgpPeers`");
    $stats['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports`");
    $stats['eigrp'] = dbFetchCell("SELECT COUNT(*) FROM `eigrp_ports`");
    $stats['ipsec_tunnels'] = dbFetchCell("SELECT COUNT(*) FROM `ipsec_tunnels`");
    $stats['munin_plugins'] = dbFetchCell("SELECT COUNT(*) FROM `munin_plugins`");
    $stats['pseudowires'] = dbFetchCell("SELECT COUNT(*) FROM `pseudowires`");
    $stats['vrfs'] = dbFetchCell("SELECT COUNT(*) FROM `vrfs`");
    $stats['vminfo'] = dbFetchCell("SELECT COUNT(*) FROM `vminfo`");
    $stats['users'] = dbFetchCell("SELECT COUNT(*) FROM `users`");
    $stats['bills'] = dbFetchCell("SELECT COUNT(*) FROM `bills`");
    $stats['alerts'] = dbFetchCell("SELECT COUNT(*) FROM `alert_table`");
    $stats['alert_tests'] = dbFetchCell("SELECT COUNT(*) FROM `alert_tests`");
    $stats['slas'] = dbFetchCell("SELECT COUNT(*) FROM `slas`");
    $stats['statuses'] = dbFetchCell("SELECT COUNT(*) FROM `status`");
    $stats['groups'] = dbFetchCell("SELECT COUNT(*) FROM `groups`");
    $stats['group_members'] = dbFetchCell("SELECT COUNT(*) FROM `group_table`");
    $stats['poller_time'] = dbFetchCell("SELECT SUM(`last_polled_timetaken`) FROM devices");
    $stats['discovery_time'] = dbFetchCell("SELECT SUM(`last_discovered_timetaken`) FROM devices");
    $stats['php_version'] = phpversion();
    $os_text = external_exec("DISTROFORMAT=export " . $GLOBALS['config']['install_dir'] . "/scripts/distro");
    foreach (explode("\n", $os_text) as $part) {
        list($a, $b) = explode("=", $part);
        $stats['os'][$a] = $b;
    }
    // sysObjectID for Generic devices
    foreach (dbFetchRows("SELECT `sysObjectID`, COUNT(*) AS `count` FROM `devices` WHERE `os` = 'generic' GROUP BY `sysObjectID`") as $data) {
        $stats['generics'][$data['sysObjectID']] = $data['count'];
    }
    // Per-OS counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `os` FROM `devices` GROUP BY `os`") as $data) {
        $stats['devicetypes'][$data['os']] = $data['count'];
    }
    // Per-type counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `type` FROM `devices` GROUP BY `type`") as $data) {
        $stats['types'][$data['type']] = $data['count'];
    }
    // Per-apptype counts
    foreach (dbFetchRows("SELECT COUNT(*) AS `count`, `app_type` FROM `applications` GROUP BY `app_type`") as $data) {
        $stats['app_types'][$data['app_type']] = $data['count'];
    }
    $stats['misc']['max_len']['port_label'] = dbFetchCell("SELECT MAX(LENGTH(`port_label`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_short'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_short`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_base'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_base`)) FROM `ports`");
    $stats['misc']['max_len']['port_label_num'] = dbFetchCell("SELECT MAX(LENGTH(`port_label_num`)) FROM `ports`");
    $stats['version'] = OBSERVIUM_VERSION;
    $stats['uuid'] = get_unique_id();
    return $stats;
}
Example #6
0
function devices_with_graph($graph)
{
    $devices = array();
    $sql = "SELECT `device_id` FROM `device_graphs` WHERE `graph` = ? AND `enabled` = '1'";
    foreach (dbFetchRows($sql, array($graph)) as $entry) {
        $devices[$entry['device_id']] = $entry['device_id'];
    }
    return $devices;
}
Example #7
0
/**
 * merge the database config with the global config
 * Global config overrides db
 */
function mergedb()
{
    global $config;
    $clone = $config;
    foreach (dbFetchRows('select config_name,config_value from config') as $obj) {
        $clone = array_replace_recursive($clone, mergecnf($obj));
    }
    $config = array_replace_recursive($clone, $config);
}
Example #8
0
function print_mempool_table($vars)
{
    global $cache;
    $sql = build_mempool_query($vars);
    $mempools = array();
    foreach (dbFetchRows($sql) as $mempool) {
        if (isset($cache['devices']['id'][$mempool['device_id']])) {
            $mempool['hostname'] = $cache['devices']['id'][$mempool['device_id']]['hostname'];
            $mempool['html_row_class'] = $cache['devices']['id'][$mempool['device_id']]['html_row_class'];
            $mempools[] = $mempool;
        }
    }
    // 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 'usage':
            $mempools = array_sort_by($mempools, 'mempool_perc', $sort_neg, SORT_NUMERIC);
            break;
        case 'used':
            $mempools = array_sort_by($mempools, 'mempool_' . $vars['sort'], $sort_neg, SORT_NUMERIC);
            break;
        default:
            $mempools = array_sort_by($mempools, 'hostname', $sort_order, SORT_STRING, 'mempool_descr', $sort_order, SORT_STRING);
            break;
    }
    $mempools_count = count($mempools);
    // Pagination
    $pagination_html = pagination($vars, $mempools_count);
    echo $pagination_html;
    if ($vars['pageno']) {
        $mempools = array_chunk($mempools, $vars['pagesize']);
        $mempools = $mempools[$vars['pageno'] - 1];
    }
    // End Pagination
    echo generate_box_open();
    print_mempool_table_header($vars);
    foreach ($mempools as $mempool) {
        print_mempool_row($mempool, $vars);
    }
    echo "</tbody></table>";
    echo generate_box_close();
    echo $pagination_html;
}
Example #9
0
function get_entity_list($type, $subtype = "*", $device_id = "*", $entry, $descr_regex = NULL)
{
    if ($type == "storage") {
        $table = $type;
    } else {
        $table = $type . 's';
    }
    if ($type == "port") {
        $deleted = "deleted";
    } else {
        $deleted_d = $type . '_deleted';
    }
    if ($type == "sensor") {
        $descr_field = "sensor_descr";
    }
    $query = 'SELECT *,' . $type . '_id AS id';
    if ($deleted) {
        $query .= ', ' . $deleted;
    }
    $query .= ' FROM ' . $table . ' WHERE 1';
    $args = array();
    if (is_numeric($device_id)) {
        $query .= " AND device_id = ?";
        $args[] = $device_id;
    }
    if ($subtype != "*" && strlen($subtype)) {
        switch ($type) {
            case "sensor":
                $query .= " AND sensor_class = ?";
                $args[] = $subtype;
                break;
        }
    }
    if (is_numeric($entry['entity'])) {
        $query .= " AND " . $type . "_id = ?";
        $args[] = $entry['entity'];
    }
    #  echo("$query");
    $entities_db = dbFetchRows($query, $args);
    foreach ($entities_db as $entity_db) {
        if ($descr_regex) {
            if (preg_match($descr_regex, $entity_db[$descr_field])) {
                $entity_db['ignore_this'] = FALSE;
            } else {
                $entity_db['ignore_this'] = TRUE;
            }
        }
        // Is this entity marked as deleted?
        if ($entity_db['deleted'] != "1" && !$entity_db['ignore_this']) {
            $entities[] = $entity_db['id'];
        }
    }
    return $entities;
}
Example #10
0
function print_printersupplies_table($vars)
{
    $supplies = array();
    foreach (dbFetchRows(build_printersupplies_query($vars)) as $supply) {
        global $cache;
        if (isset($cache['devices']['id'][$supply['device_id']])) {
            $supply['hostname'] = $cache['devices']['id'][$supply['device_id']]['hostname'];
            $supply['html_row_class'] = $cache['devices']['id'][$supply['device_id']]['html_row_class'];
            $supplies[] = $supply;
        }
    }
    $supplies = array_sort_by($supplies, 'hostname', SORT_ASC, SORT_STRING, 'supply_descr', SORT_ASC, SORT_STRING);
    $supplies_count = count($supplies);
    echo generate_box_open();
    // Pagination
    $pagination_html = pagination($vars, $supplies_count);
    echo $pagination_html;
    if ($vars['pageno']) {
        $supplies = array_chunk($supplies, $vars['pagesize']);
        $supplies = $supplies[$vars['pageno'] - 1];
    }
    // End Pagination
    if ($vars['view'] == "graphs") {
        $stripe_class = "table-striped-two";
    } else {
        $stripe_class = "table-striped";
    }
    // Allow the table to be printed headerless for use in some places.
    if ($vars['headerless'] != TRUE) {
        echo '<table class="table ' . $stripe_class . '  table-condensed">';
        echo '  <thead>';
        echo '<tr class="strong">';
        echo '<th class="state-marker"></th>';
        echo '<th></th>';
        if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
            echo '      <th style="width: 250px;">Device</th>';
        }
        echo '<th>Toner</th>';
        if (!isset($vars['supply'])) {
            echo '<th>Type</th>';
        }
        echo '<th></th>';
        echo '<th>Level</th>';
        echo '<th>Remaining</th>';
        echo '</tr>';
        echo '</thead>';
    }
    foreach ($supplies as $supply) {
        print_printersupplies_row($supply, $vars);
    }
    echo "</table>";
    echo generate_box_close();
    echo $pagination_html;
}
Example #11
0
function humanize_alert_check(&$check)
{
    // Fetch the queries to build the alert table.
    list($query, $param, $query_count) = build_alert_table_query(array('alert_test_id' => $check['alert_test_id']));
    // Fetch a quick set of alert_status values to build the alert check status text
    $query = str_replace(" * ", " `alert_status` ", $query);
    $check['entities'] = dbFetchRows($query, $param);
    $check['entity_status'] = array('up' => 0, 'down' => 0, 'unknown' => 0, 'delay' => 0, 'suppress' => 0);
    foreach ($check['entities'] as $alert_table_id => $alert_table_entry) {
        if ($alert_table_entry['alert_status'] == '1') {
            ++$check['entity_status']['up'];
        } elseif ($alert_table_entry['alert_status'] == '0') {
            ++$check['entity_status']['down'];
        } elseif ($alert_table_entry['alert_status'] == '2') {
            ++$check['entity_status']['delay'];
        } elseif ($alert_table_entry['alert_status'] == '3') {
            ++$check['entity_status']['suppress'];
        } else {
            ++$check['entity_status']['unknown'];
        }
    }
    $check['num_entities'] = count($check['entities']);
    if ($check['entity_status']['up'] == $check['num_entities']) {
        $check['class'] = "green";
        $check['table_tab_colour'] = "#194b7f";
        $check['html_row_class'] = "";
    } elseif ($check['entity_status']['down'] > '0') {
        $check['class'] = "red";
        $check['table_tab_colour'] = "#cc0000";
        $check['html_row_class'] = "error";
    } elseif ($check['entity_status']['delay'] > '0') {
        $check['class'] = "orange";
        $check['table_tab_colour'] = "#ff6600";
        $check['html_row_class'] = "warning";
    } elseif ($check['entity_status']['suppress'] > '0') {
        $check['class'] = "purple";
        $check['table_tab_colour'] = "#740074";
        $check['html_row_class'] = "suppressed";
    } elseif ($check['entity_status']['up'] > '0') {
        $check['class'] = "green";
        $check['table_tab_colour'] = "#194b7f";
        $check['html_row_class'] = "";
    } else {
        $check['entity_status']['class'] = "gray";
        $check['table_tab_colour'] = "#555555";
        $check['html_row_class'] = "disabled";
    }
    $check['status_numbers'] = '<span class="green">' . $check['entity_status']['up'] . '</span>/<span class="purple">' . $check['entity_status']['suppress'] . '</span>/<span class=red>' . $check['entity_status']['down'] . '</span>/<span class=orange>' . $check['entity_status']['delay'] . '</span>/<span class=gray>' . $check['entity_status']['unknown'] . '</span>';
    // We return nothing, $check is modified in place.
}
Example #12
0
function adduser($username, $level = 0, $email = '', $realname = '', $can_modify_passwd = 0, $description = '', $twofactor = 0)
{
    // Check to see if user is already added in the database
    if (!user_exists_in_db($username)) {
        $userid = dbInsert(array('username' => $username, 'realname' => $realname, 'email' => $email, 'descr' => $description, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'twofactor' => $twofactor, 'user_id' => get_userid($username)), 'users');
        if ($userid == false) {
            return false;
        } else {
            foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc', array($userid)) as $notif) {
                dbInsert(array('notifications_id' => $notif['notifications_id'], 'user_id' => $userid, 'key' => 'read', 'value' => 1), 'notifications_attribs');
            }
        }
        return $userid;
    } else {
        return false;
    }
}
/**
 * Grab the mysql data
 *
 * @return array
 * @param  vars
 *
*/
function api_packages_db($vars)
{
    global $config;
    $res = array();
    foreach (dbFetchRows("SELECT * FROM `packages` WHERE `device_id` = ? GROUP BY `name`", array($vars['device'])) as $packages) {
        if ($config['api']['module']['encryption']) {
            $tmp = array();
            foreach ($packages as $item => $value) {
                $tmp[$item] = api_encrypt_data($value, $config['api']['encryption']['key']);
            }
            $res[] = $tmp;
            unset($tmp);
        } else {
            $res[] = $packages;
        }
    }
    return $res;
}
/**
 * Grab the mysql data
 *
 * @return array
 * @param  vars
 *
*/
function api_inventory_db($vars)
{
    global $config;
    $res = array();
    foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($vars['device'])) as $hrdevice) {
        if ($config['api']['module']['encryption']) {
            $tmp = array();
            foreach ($hrdevice as $item => $value) {
                $tmp[$item] = api_encrypt_data($value, $config['api']['encryption']['key']);
            }
            $res[] = $tmp;
            unset($tmp);
        } else {
            $res[] = $hrdevice;
        }
    }
    return $res;
}
Example #15
0
function print_p2pradio_table($vars)
{
    if ($vars['view'] == "graphs" || isset($vars['graph'])) {
        $stripe_class = "table-striped-two";
    } else {
        $stripe_class = "table-striped";
    }
    echo generate_box_open();
    echo '<table class="table table-hover ' . $stripe_class . '  table-condensed">';
    print_p2pradio_table_header($vars);
    $sql = generate_p2pradio_query($vars);
    $radios = dbFetchRows($sql);
    foreach ($radios as $radio) {
        print_p2pradio_row($radio, $vars);
    }
    echo '</table>';
    echo generate_box_close();
}
Example #16
0
 public static function start()
 {
     global $config;
     if (file_exists($config['plugin_dir'])) {
         // $plugin_files = scandir($config['plugin_dir']);
         $plugin_files = dbFetchRows("SELECT * FROM `plugins` WHERE `plugin_active` = '1'");
         foreach ($plugin_files as $plugins) {
             $plugin_info = pathinfo($config['plugin_dir'] . '/' . $plugins['plugin_name'] . '/' . $plugins['plugin_name'] . '.php');
             if ($plugin_info['extension'] == 'php') {
                 if (is_file($config['plugin_dir'] . '/' . $plugins['plugin_name'] . '/' . $plugins['plugin_name'] . '.php')) {
                     self::load($config['plugin_dir'] . '/' . $plugins['plugin_name'] . '/' . $plugins['plugin_name'] . '.php', $plugin_info['filename']);
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }
Example #17
0
/**
 * Display device inventory hierarchy.
 *
 * @param string $ent, $level, $class
 * @return none
 *
 */
function print_ent_physical($ent, $level, $class)
{
    global $device;
    $ents = dbFetchRows("SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ? ORDER BY `entPhysicalContainedIn`, `entPhysicalIndex`", array($device['device_id'], $ent));
    foreach ($ents as $ent) {
        $link = '';
        $text = " <li class='{$class}'>";
        /*
        Currently no icons for:
        
        JUNIPER-MIB::jnxFruType.10.1.1.0 = INTEGER: frontPanelModule(8)
        JUNIPER-MIB::jnxFruType.12.1.0.0 = INTEGER: controlBoard(5)
        
        For Geist RCX, IPOMan:
        outlet
        relay
        */
        switch ($ent['entPhysicalClass']) {
            case 'chassis':
                $text .= '<i class="oicon-database"></i> ';
                break;
            case 'module':
            case 'portInterfaceCard':
                $text .= '<i class="oicon-drive"></i> ';
                break;
            case 'port':
                $text .= '<i class="oicon-network-ethernet"></i> ';
                break;
            case 'container':
            case 'flexiblePicConcentrator':
                $text .= '<i class="oicon-box-zipper"></i> ';
                break;
            case 'stack':
                $text .= '<i class="oicon-databases"></i> ';
                break;
            case 'fan':
            case 'airflowSensor':
                $text .= '<i class="oicon-weather-wind"></i> ';
                break;
            case 'powerSupply':
            case 'powerEntryModule':
                $text .= '<i class="oicon-plug"></i> ';
                break;
            case 'backplane':
                $text .= '<i class="oicon-zones"></i> ';
                break;
            case 'sensor':
                $text .= '<i class="oicon-asterisk"></i> ';
                $sensor = dbFetchRow("SELECT * FROM `sensors` AS S\n                             LEFT JOIN `sensors-state` AS ST ON S.`sensor_id` = ST.`sensor_id`\n                             WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($device['device_id'], $ent['entPhysicalIndex'], $ent['entPhysicalIndex']));
                break;
            default:
                $text .= '<i class="oicon-chain"></i> ';
        }
        if ($ent['entPhysicalParentRelPos'] > '-1') {
            $text .= '<strong>' . $ent['entPhysicalParentRelPos'] . '.</strong> ';
        }
        $ent_text = '';
        if ($ent['ifIndex']) {
            $interface = get_port_by_ifIndex($device['device_id'], $ent['ifIndex']);
            $ent['entPhysicalName'] = generate_port_link($interface);
        }
        if ($ent['entPhysicalModelName'] && $ent['entPhysicalName']) {
            $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong> (" . $ent['entPhysicalName'] . ")";
        } elseif ($ent['entPhysicalModelName']) {
            $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong>";
        } elseif (is_numeric($ent['entPhysicalName']) && $ent['entPhysicalVendorType']) {
            $ent_text .= "<strong>" . $ent['entPhysicalName'] . " " . $ent['entPhysicalVendorType'] . "</strong>";
        } elseif ($ent['entPhysicalName']) {
            $ent_text .= "<strong>" . $ent['entPhysicalName'] . "</strong>";
        } elseif ($ent['entPhysicalDescr']) {
            $ent_text .= "<strong>" . $ent['entPhysicalDescr'] . "</strong>";
        }
        $ent_text .= "<br /><div class='small' style='margin-left: 20px;'>" . $ent['entPhysicalDescr'];
        if ($ent['entPhysicalClass'] == "sensor" && $sensor['sensor_value']) {
            $ent_text .= ' (' . $sensor['sensor_value'] . ' ' . $sensor['sensor_class'] . ')';
            $link = generate_entity_link('sensor', $sensor, $ent_text, NULL, FALSE);
        }
        $text .= $link ? $link : $ent_text;
        if ($ent['entPhysicalSerialNum']) {
            $text .= ' <span class="text-info">[Serial: ' . $ent['entPhysicalSerialNum'] . ']</span> ';
        }
        $text .= "</div>";
        echo $text;
        $count = dbFetchCell("SELECT COUNT(*) FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ?", array($device['device_id'], $ent['entPhysicalIndex']));
        if ($count) {
            echo "<ul>";
            print_ent_physical($ent['entPhysicalIndex'], $level + 1, '');
            echo "</ul>";
        }
        echo "</li>";
    }
}
Example #18
0
                    $param[] = "up";
                } elseif ($value == "admindown") {
                    $where .= " AND I.ifAdminStatus = ? AND D.ignore = 0";
                    $param[] = "down";
                }
                break;
        }
    }
}
if ($ignore_filter == 0 && $disabled_filter == 0) {
    $where .= " AND `I`.`ignore` = 0 AND `I`.`disabled` = 0 AND `I`.`deleted` = 0";
}
$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id " . $where . " " . $query_sort;
$row = 1;
list($format, $subformat) = explode("_", $vars['format']);
$ports = dbFetchRows($query, $param);
switch ($vars['sort']) {
    case 'traffic':
        $ports = array_sort($ports, 'ifOctets_rate', SORT_DESC);
        break;
    case 'traffic_in':
        $ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC);
        break;
    case 'traffic_out':
        $ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC);
        break;
    case 'packets':
        $ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC);
        break;
    case 'packets_in':
        $ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC);
Example #19
0
 * @copyright  2016 Tony Murray
 * @author     Tony Murray <*****@*****.**>
 */
if (key_exists('vrf_lite_cisco', $device) && count($device['vrf_lite_cisco']) != 0) {
    $vrfs_lite_cisco = $device['vrf_lite_cisco'];
} else {
    $vrfs_lite_cisco = array(array('context_name' => null));
}
foreach ($vrfs_lite_cisco as $vrf) {
    $context = $vrf['context_name'];
    $device['context_name'] = $context;
    $arp_data = snmpwalk_cache_multi_oid($device, 'ipNetToPhysicalPhysAddress', array(), 'IP-MIB');
    $arp_data = snmpwalk_cache_multi_oid($device, 'ipNetToMediaPhysAddress', $arp_data, 'IP-MIB');
    $sql = "SELECT M.* from ipv4_mac AS M, ports AS I WHERE M.port_id=I.port_id AND I.device_id=? AND M.context_name=?";
    $params = array($device['device_id'], $context);
    $existing_data = dbFetchRows($sql, $params);
    $ipv4_addresses = array();
    foreach ($existing_data as $data) {
        $ipv4_addresses[] = $data['ipv4_address'];
    }
    $arp_table = array();
    $insert_data = array();
    foreach ($arp_data as $ip => $data) {
        if (isset($data['ipNetToPhysicalPhysAddress'])) {
            $raw_mac = $data['ipNetToPhysicalPhysAddress'];
            list($if, $ipv, $ip) = explode('.', $ip, 3);
        } elseif (isset($data['ipNetToMediaPhysAddress'])) {
            $raw_mac = $data['ipNetToMediaPhysAddress'];
            list($if, $ip) = explode('.', $ip, 2);
            $ipv = 'ipv4';
        }
<?php

foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool) {
    echo "Mempool " . $mempool['mempool_descr'] . ": ";
    $mempool_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd");
    $file = $config['install_dir'] . "/includes/polling/mempools/" . $mempool['mempool_type'] . ".inc.php";
    if (is_file($file)) {
        include $file;
    } else {
        // Do we need a generic mempool poller?
    }
    if ($mempool['total']) {
        $percent = round($mempool['used'] / $mempool['total'] * 100, 2);
    } else {
        $percent = 0;
    }
    echo $percent . "% ";
    if (!is_file($mempool_rrd)) {
        rrdtool_create($mempool_rrd, "--step 300 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U " . $config['rrd_rra']);
    }
    rrdtool_update($mempool_rrd, "N:" . $mempool['used'] . ":" . $mempool['free']);
    $mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']);
    if ($config['memcached']['enable']) {
        if ($debug) {
            print_r($mempool['state']);
        }
        $memcache->set('mempool-' . $mempool['mempool_id'] . '-value', $mempool['state']);
    } else {
        dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
    }
    echo "\n";
Example #21
0
         DS:bgpPeerInTotal:COUNTER:600:U:100000000000 
         DS:bgpPeerEstablished:GAUGE:600:0:U ' . $config['rrd_rra'];
     rrdtool_create($peerrrd, $create_rrd);
 }
 $fields = array('bgpPeerOutUpdates' => $bgpPeerOutUpdates, 'bgpPeerInUpdates' => $bgpPeerInUpdates, 'bgpPeerOutTotal' => $bgpPeerOutTotalMessages, 'bgpPeerInTotal' => $bgpPeerInTotalMessages, 'bgpPeerEstablished' => $bgpPeerFsmEstablishedTime);
 rrdtool_update("{$peerrrd}", $fields);
 $peer['update']['bgpPeerState'] = $bgpPeerState;
 $peer['update']['bgpPeerAdminStatus'] = $bgpPeerAdminStatus;
 $peer['update']['bgpPeerFsmEstablishedTime'] = $bgpPeerFsmEstablishedTime;
 $peer['update']['bgpPeerInUpdates'] = $bgpPeerInUpdates;
 $peer['update']['bgpLocalAddr'] = $bgpLocalAddr;
 $peer['update']['bgpPeerOutUpdates'] = $bgpPeerOutUpdates;
 dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', array($device['device_id'], $peer['bgpPeerIdentifier']));
 if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
     // Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
     $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier']));
     foreach ($peer_afis as $peer_afi) {
         $afi = $peer_afi['afi'];
         $safi = $peer_afi['safi'];
         d_echo("{$afi} {$safi}\n");
         if ($device['os_group'] == 'cisco') {
             $bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']);
             if (strstr($peer['bgpPeerIdentifier'], ':')) {
                 $ip_type = 2;
                 $ip_len = 16;
                 $ip_ver = 'ipv6';
             } else {
                 $ip_type = 1;
                 $ip_len = 4;
                 $ip_ver = 'ipv4';
             }
Example #22
0
function list_bills()
{
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $status = 'ok';
    $err_msg = '';
    $message = '';
    $code = 200;
    $bills = array();
    $bill_id = mres($router['bill_id']);
    $bill_ref = mres($_GET['ref']);
    $bill_custid = mres($_GET['custid']);
    if (!empty($bill_custid)) {
        $sql = '`bill_custid` = ?';
        $param = array($bill_custid);
    } elseif (!empty($bill_ref)) {
        $sql = '`bill_ref` = ?';
        $param = array($bill_ref);
    } elseif (is_numeric($bill_id)) {
        $sql = '`bill_id` = ?';
        $param = array($bill_id);
    } else {
        $sql = '';
        $param = array();
    }
    if (count($param) >= 1) {
        $sql = "WHERE {$sql}";
    }
    foreach (dbFetchRows("SELECT `bills`.*,COUNT(port_id) AS `ports_total` FROM `bills` LEFT JOIN `bill_ports` ON `bill_ports`.`bill_id`=`bills`.`bill_id` {$sql} GROUP BY `bill_name`,`bill_ref` ORDER BY `bill_name`", $param) as $bill) {
        $rate_data = $bill;
        $allowed = '';
        $used = '';
        $percent = '';
        $overuse = '';
        if ($bill['bill_type'] == "cdr") {
            $allowed = format_si($bill['bill_cdr']) . "bps";
            $used = format_si($rate_data['rate_95th']) . "bps";
            $percent = round($rate_data['rate_95th'] / $bill['bill_cdr'] * 100, 2);
            $overuse = $rate_data['rate_95th'] - $bill['bill_cdr'];
            $overuse = $overuse <= 0 ? "-" : format_si($overuse);
        } elseif ($bill['bill_type'] == "quota") {
            $allowed = format_bytes_billing($bill['bill_quota']);
            $used = format_bytes_billing($rate_data['total_data']);
            $percent = round($rate_data['total_data'] / $bill['bill_quota'] * 100, 2);
            $overuse = $rate_data['total_data'] - $bill['bill_quota'];
            $overuse = $overuse <= 0 ? "-" : format_bytes_billing($overuse);
        }
        $bill['allowed'] = $allowed;
        $bill['used'] = $used;
        $bill['percent'] = $percent;
        $bill['overuse'] = $overuse;
        $bills[] = $bill;
    }
    $count = count($bills);
    $output = array('status' => $status, 'message' => $message, 'err-msg' => $err_msg, 'count' => $count, 'bills' => $bills);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
/**
 * Find contacts for alert
 * @param array $results Rule-Result
 * @return array
 */
function GetContacts($results)
{
    global $config;
    if (sizeof($results) == 0) {
        return array();
    }
    if ($config['alerts']['email']['default_only']) {
        return array($config['alerts']['email']['default'] => 'NOC');
    }
    $contacts = array();
    $uids = array();
    foreach ($results as $result) {
        $tmp = NULL;
        if (is_numeric($result["port_id"])) {
            $tmpa = dbFetchRows("SELECT user_id FROM ports_perms WHERE access_level >= 0 AND port_id = ?", array($result["port_id"]));
            foreach ($tmpa as $tmp) {
                $uids[$tmp['user_id']] = $tmp['user_id'];
            }
        }
        if (is_numeric($result["device_id"])) {
            $tmpa = dbFetchRow("SELECT sysContact FROM devices WHERE device_id = ?", array($result["device_id"]));
            $contacts[$tmpa["sysContact"]] = "NOC";
            $tmpa = dbFetchRows("SELECT user_id FROM devices_perms WHERE access_level >= 0 AND device_id = ?", array($result["device_id"]));
            foreach ($tmpa as $tmp) {
                $uids[$tmp['user_id']] = $tmp['user_id'];
            }
        }
    }
    if ($config["alert"]["globals"]) {
        $tmpa = dbFetchRows("SELECT realname,email FROM users WHERE level >= 5 AND level < 10");
        foreach ($tmpa as $tmp) {
            $contacts[$tmp['email']] = $tmp['realname'];
        }
    }
    if ($config["alert"]["admins"]) {
        $tmpa = dbFetchRows("SELECT realname,email FROM users WHERE level = 10");
        foreach ($tmpa as $tmp) {
            $contacts[$tmp['email']] = $tmp['realname'];
        }
    }
    if (is_array($uids)) {
        foreach ($uids as $uid) {
            $tmp = dbFetchRow("SELECT realname,email FROM users WHERE user_id = ?", array($uid));
            $contacts[$tmp['email']] = $tmp['realname'];
        }
    }
    return $contacts;
}
Example #24
0
<?php

/**
 * Observium Network Management and Monitoring System
 * Copyright (C) 2006-2014, Adam Armstrong - http://www.observium.org
 *
 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
print_message("This page allows you to disable or enable certain Graphs detected for a device.");
$graphs_db = array();
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry) {
    $graph = $entry['graph'];
    $section = $config['graph_types']['device'][$graph]['section'];
    $graphs_db[$graph] = (bool) $entry['enabled'];
    // Another array sorted by sections
    $graphs_sections[$section][$graph] = (bool) $entry['enabled'];
}
$graph = $_POST['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) && !in_array($config['graph_types']['device'][$graph]['section'], array('poller', 'system'))) {
    $value = (int) (!$graphs_db[$graph]);
    // Toggle current 'enabled' value
    $updated = dbUpdate(array('enabled' => $value), 'device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph));
    if ($updated) {
        print_success("Graph '{$graph}' " . ($value ? 'enabled' : 'disabled') . '.');
        $graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool) $value;
    }
}
Example #25
0
foreach (dbFetchRows($sql) as $entry) {
    include "includes/print-syslog.inc.php";
}
echo "</table>";
echo "</div>\n\n   </td>\n   <td bgcolor=#e5e5e5 width=470 valign=top>";
// this stuff can be customised to show whatever you want....
if ($_SESSION['userlevel'] >= '5') {
    $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
    unset($seperator);
    foreach (dbFetchRows($sql) as $interface) {
        $ports['transit'] .= $seperator . $interface['port_id'];
        $seperator = ",";
    }
    $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
    unset($seperator);
    foreach (dbFetchRows($sql) as $interface) {
        $ports['peering'] .= $seperator . $interface['port_id'];
        $seperator = ",";
    }
    $ports['broadband'] = "3294,3295,688,3534";
    $ports['wave_broadband'] = "827";
    $ports['new_broadband'] = "3659,4149,4121,4108,3676,4135";
    echo "<div style=' margin-bottom: 5px;'>";
    if ($ports['peering'] && $ports['transit']) {
        echo "<div style='width: 235px; '>\n    <a href='internet/' onmouseover=\"return overlib('\\\n    <img src=\\'graph.php?type=multiport_bits_duo&amp;id=" . $ports['peering'] . "&amp;idb=" . $ports['transit'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150\\'>\\\n    <img src=\\'graph.php?type=multiport_bits_duo&amp;id=" . $ports['peering'] . "&amp;idb=" . $ports['transit'] . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<div style='font-size: 16px; font-weight: bold; color: #555555;'>Aggregate Internet Traffic</div>" . "<img src='graph.php?type=multiport_bits_duo&amp;id=" . $ports['peering'] . "&amp;idb=" . $ports['transit'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=385&amp;height=100&amp;legend=no'></a></div>";
    }
    echo "</div>";
    echo "<div style=' margin-bottom: 5px;'>";
    if ($ports['transit']) {
        echo "<div style='width: 235px; float: left;'>\n    <a href='iftype/transit/' onmouseover=\"return overlib('\\\n    <img src=\\'graph.php?type=multiport_bits&amp;id=" . $ports['transit'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150\\'>\\\n    <img src=\\'graph.php?type=multiport_bits&amp;id=" . $ports['transit'] . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<div style='font-size: 16px; font-weight: bold; color: #555555;'>Internet Transit</div>" . "<img src='graph.php?type=multiport_bits&amp;id=" . $ports['transit'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=155&amp;height=100&amp;legend=no'></a></div>";
    }
     echo "<h3>Bill Access</h3>";
     $bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($vars['user_id']));
     echo "<div class='panel panel-default panel-condensed'>\n            <table class='table table-hover table-condensed table-striped'>\n            <tr>\n              <th>Bill name</th>\n              <th>Action</th>\n            </tr>";
     foreach ($bill_perms as $bill_perm) {
         echo "<tr>\n              <td>\n                <strong>" . $bill_perm['bill_name'] . "</strong></td><td width=50>&nbsp;&nbsp;<a href='edituser/action=delbillperm/user_id=" . $vars['user_id'] . "/bill_id=" . $bill_perm['bill_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a>\n              </td>\n            </tr>";
         $bill_access_list[] = $bill_perm['bill_id'];
         $bpermdone = "yes";
     }
     echo "</table>\n          </div>";
     if (!$bpermdone) {
         echo "None Configured";
     }
     // Display devices this user doesn't have access to
     echo "<h4>Grant access to new bill</h4>";
     echo "<form method='post' action='' class='form-inline' role='form'>\n            <input type='hidden' value='" . $vars['user_id'] . "' name='user_id'>\n            <input type='hidden' value='edituser' name='page'>\n            <input type='hidden' value='addbillperm' name='action'>\n            <div class='form-group'>\n              <label class='sr-only' for='bill_id'>Bill</label>\n              <select name='bill_id' class='form-control' id='bill_id'>";
     $bills = dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`");
     foreach ($bills as $bill) {
         unset($done);
         foreach ($bill_access_list as $ac) {
             if ($ac == $bill['bill_id']) {
                 $done = 1;
             }
         }
         if (!$done) {
             echo "<option value='" . $bill['bill_id'] . "'>" . $bill['bill_name'] . "</option>";
         }
     }
     echo "</select>\n          </div>\n          <button type='submit' class='btn btn-default' name='Submit' value='Add'>Add</button>\n        </form>\n        </div>";
 } elseif ($vars['user_id'] && $vars['edit']) {
     if (!empty($vars['new_level'])) {
         if ($vars['can_modify_passwd'] == 'on') {
Example #27
0
     $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']);
 } else {
     $peer_ip = $peer['bgpLocalAddr'];
 }
 $localaddresslink = "<span class=list-large><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_ip . '</a></span>';
 $graph_type = 'bgp_updates';
 $peer_daily_url = 'graph.php?id=' . $peer['bgpPeer_id'] . '&amp;type=' . $graph_type . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . '&amp;width=500&amp;height=150';
 if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) {
     $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']);
 } else {
     $peer_ident = $peer['bgpPeerIdentifier'];
 }
 $peeraddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$peer_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ');" onmouseout="return nd();">' . $peer_ident . '</a></span>';
 echo '<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . '>';
 unset($sep);
 foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) 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);
 echo '  <td></td>
     <td width=150>' . $localaddresslink . '<br />' . generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . '</td>
     <td width=30><b>&#187;</b></td>
     <td width=150>' . $peeraddresslink . "</td>\n            <td width=50><b>{$peer_type}</b></td>\n            <td width=50>" . $peer['afi'] . '</td>
     <td><strong>AS' . $peer['bgpPeerRemoteAs'] . '</strong><br />' . $peer['astext'] . "</td>\n            <td><strong><span style='color: {$admin_col};'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: {$col};'>" . $peer['bgpPeerState'] . '</span></strong></td>
     <td>' . formatUptime($peer['bgpPeerFsmEstablishedTime']) . "<br />\n            Updates <img src='images/16/arrow_down.png' align=absmiddle /> " . format_si($peer['bgpPeerInUpdates']) . "\n            <img src='images/16/arrow_up.png' align=absmiddle /> " . format_si($peer['bgpPeerOutUpdates']) . '</td></tr>';
Example #28
0
function show_traffic($config)
{
    // Show Traffic
    if ($_SESSION['userlevel'] >= '5') {
        $ports = array();
        $query_permitted = generate_query_permitted(array('port'));
        foreach (dbFetchRows("SELECT `port_descr_type`,`port_id`,`ifAlias` FROM `ports`\n                          WHERE `port_descr_type` IS NOT NULL {$query_permitted}\n                          ORDER BY `ifAlias`") as $port) {
            switch ($port['port_descr_type']) {
                case 'transit':
                case 'peering':
                case 'core':
                    $ports[$port['port_descr_type']][] = $port['port_id'];
                    break;
            }
        }
        echo generate_box_open();
        $links['transit'] = generate_url(array("page" => "iftype", "type" => "transit"));
        $ports['transit_list'] = implode(',', $ports['transit']);
        $graph_array['from'] = $config['time']['day'];
        $graph_array['to'] = $config['time']['now'];
        $graph_array['type'] = 'multi-port_bits_separate';
        $graph_array['width'] = 528;
        $graph_array['height'] = 100;
        $graph_array['legend'] = 'no';
        $graph_array['id'] = $ports['transit_list'];
        $transit_graph = generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['week'];
        $transit_graph_week = generate_graph_tag($graph_array);
        $links['peering'] = generate_url(array("page" => "iftype", "type" => "peering"));
        $ports['peering_list'] = implode(',', $ports['peering']);
        $graph_array['from'] = $config['time']['day'];
        $graph_array['id'] = $ports['peering_list'];
        $peering_graph = generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['week'];
        $peering_graph_week = generate_graph_tag($graph_array);
        $graph_array['id'] = $ports['peering_list'];
        $graph_array['idb'] = $ports['transit_list'];
        $graph_array['from'] = $config['time']['month'];
        $graph_array['type'] = 'multi-port_bits_duo_separate';
        $graph_array['width'] = 1158;
        $summary_graph = generate_graph_tag($graph_array);
        if (count($ports['transit']) && count($ports['peering'])) {
            echo '<div class="row">';
            echo '  <div class="col-sm-6">';
            echo '    <h3><a href="/iftype/type=transit">Overall Transit Traffic Today</a></h3>';
            echo '    <a href="' . $links['transit'] . '">' . $transit_graph . '</a>';
            echo '  </div>';
            echo '  <div class="col-sm-6">';
            echo '    <h3><a href="/iftype/type=peering">Overall Peering Traffic Today</a></h3>';
            echo '    <a href="' . $links['peering'] . '">' . $peering_graph . '</a>';
            echo '  </div>';
            echo '</div>';
        } elseif (count($ports['transit'])) {
            echo '<div class="row">';
            echo '  <div class="col-sm-6">';
            echo '    <h3><a href="/iftype/type=transit">Overall Transit Traffic Today</a></h3>';
            echo '    <a href="' . $links['transit'] . '">' . $transit_graph . '</a>';
            echo '  </div>';
            echo '  <div class="col-sm-6 ">';
            echo '    <h3><a href="/iftype/type=transit">Overall Transit Traffic This Week</a></h3>';
            echo '    <a href="' . $links['transit'] . '">' . $transit_graph_week . '</a>';
            echo '  </div>';
            echo '</div>';
        } elseif (count($ports['peering'])) {
            $links['peering'] = generate_url(array("page" => "iftype", "type" => "peering"));
            $ports['peering_list'] = implode(',', $ports['peering']);
            echo '<div class="row">';
            echo '  <div class="col-sm-6 ">';
            echo '    <h3><a href="/iftype/type=peering">Overall Peering Traffic Today</a></h3>';
            echo '    <a href="' . $links['peering'] . '">' . $peering_graph . '</a>';
            echo '  </div>';
            echo '  <div class="col-sm-6 ">';
            echo '    <h3><a href="/iftype/type=peering">Overall Peering Traffic This Week</a></h3>';
            echo '    <a href="' . $links['peering'] . '">' . $peering_graph_week . '</a>';
            echo '  </div>';
            echo '</div>';
        }
        if ($ports['transit_list'] && $ports['peering_list']) {
            $links['peer_trans'] = generate_url(array("page" => "iftype", "type" => "peering,transit"));
            echo '<div class="row">';
            echo '  <div class="col-sm-12">';
            echo '    <h3><a href="/iftype/type=transit%2Cpeering">Overall Transit &amp; Peering Traffic This Month</a></h3>';
            echo '    <a href="' . $links['peer_trans'] . '">' . $summary_graph . '</a>';
            echo '  </div>';
            echo '</div>';
        }
        echo generate_box_close();
    }
}
Example #29
0
    echo "</div>";
    echo "</div>";
} else {
    if ($_SESSION['userlevel'] == '10') {
        $query = "SELECT *,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate  FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15";
    } else {
        $query = "SELECT *,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate  FROM `eventlog` AS E, devices_perms AS P WHERE E.host =\n            P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15";
    }
    $data = mysql_query($query);
    echo '<div class="container-fluid">
          <div class="row">
            <div class="col-md-12">
              &nbsp;
            </div>
          </div>
          <div class="row">
            <div class="col-md-12">
              <div class="panel panel-default panel-condensed">
              <div class="panel-heading">
                <strong>Eventlog entries</strong>
              </div>
              <table class="table table-hover table-condensed table-striped">';
    foreach (dbFetchRows($query) as $entry) {
        include 'includes/print-event.inc.php';
    }
    echo "</table>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
}
Example #30
0
    }
    foreach ($enabled as $app) {
        if (!in_array($app, $app_in_db)) {
            $updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
        }
    }
    if ($updated) {
        print_message('Applications updated!');
    } else {
        print_message('No changes.');
    }
}
//end if
// Show list of apps with checkboxes
echo '<div style="padding: 10px;">';
$apps_enabled = dbFetchRows('SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type', array($device['device_id']));
if (count($apps_enabled)) {
    foreach ($apps_enabled as $application) {
        $app_enabled[] = $application['app_type'];
    }
}
echo "<div class='row'>\n    <div class='col-md-4'>\n    <form id='appedit' name='appedit' method='post' action='' role='form' class='form-horizontal'>\n    <input type=hidden name=device value='" . $device['device_id'] . "'>\n    <table class='table table-hover table-responsive'>\n    <tr align=center>\n    <th>Enable</th>\n    <th>Application</th>\n    </tr>\n    ";
$row = 1;
foreach ($applications as $app) {
    if (is_integer($row / 2)) {
        $row_colour = $list_colour_a;
    } else {
        $row_colour = $list_colour_b;
    }
    echo "    <tr bgcolor={$row_colour}>";
    echo '      <td>';