Ejemplo n.º 1
0
 public function insertCrawlData($data)
 {
     $router_data = Router_old::getRouterInfo($data['router_id']);
     $actual_crawl_cycle = Crawling::getActualCrawlCycle();
     $last_endet_crawl_cycle = Crawling::getLastEndedCrawlCycle();
     /**Insert Router Interfaces*/
     foreach ($data['interface_data'] as $sendet_interface) {
         //Update RRD Graph DB
         $interface_last_endet_crawl = Interfaces::getInterfaceCrawlByCrawlCycleAndRouterIdAndInterfaceName($last_endet_crawl_cycle['id'], $data['router_id'], $sendet_interface['name']);
         $traffic_rx_bps = round(($sendet_interface['traffic_rx'] - $interface_last_endet_crawl['traffic_rx']) / $GLOBALS['crawl_cycle'] / 60);
         $traffic_rx_bps = $traffic_rx_bps < 0 ? 0 : $traffic_rx_bps;
         $traffic_tx_bps = round(($sendet_interface['traffic_tx'] - $interface_last_endet_crawl['traffic_tx']) / $GLOBALS['crawl_cycle'] / 60);
         $traffic_tx_bps = $traffic_tx_bps < 0 ? 0 : $traffic_tx_bps;
         //Set default indizies to prevent from warnings
         $sendet_interface['wlan_frequency'] = isset($sendet_interface['wlan_frequency']) ? preg_replace("/([A-Za-z])/", "", $sendet_interface['wlan_frequency']) : "";
         $sendet_interface['wlan_mode'] = isset($sendet_interface['wlan_mode']) ? $sendet_interface['wlan_mode'] : "";
         $sendet_interface['wlan_essid'] = isset($sendet_interface['wlan_essid']) ? $sendet_interface['wlan_essid'] : "";
         $sendet_interface['wlan_bssid'] = isset($sendet_interface['wlan_bssid']) ? $sendet_interface['wlan_bssid'] : "";
         $sendet_interface['wlan_tx_power'] = isset($sendet_interface['wlan_tx_power']) ? $sendet_interface['wlan_tx_power'] : 0;
         //check if interface already exists
         $networkinterface_test = new Networkinterface(false, (int) $data['router_id'], $sendet_interface['name']);
         //if interface not exist, create new
         if (!$networkinterface_test->fetch()) {
             $networkinterface_new = new Networkinterface(false, (int) $data['router_id'], $sendet_interface['name']);
             $networkinterface_id = $networkinterface_new->store();
         } else {
             $networkinterface_id = $networkinterface_test->getNetworkinterfaceId();
         }
         //save crawl data for interface
         $networkinterface_status = new NetworkinterfaceStatus(false, (int) $actual_crawl_cycle['id'], (int) $networkinterface_id, (int) $data['router_id'], $sendet_interface['name'], $sendet_interface['mac_addr'], (int) $sendet_interface['mtu'], (int) $sendet_interface['traffic_rx'], (int) $traffic_rx_bps, (int) $sendet_interface['traffic_tx'], (int) $traffic_tx_bps, $sendet_interface['wlan_mode'], $sendet_interface['wlan_frequency'], $sendet_interface['wlan_essid'], $sendet_interface['wlan_bssid'], (int) $sendet_interface['wlan_tx_power'], false);
         $networkinterface_status->store();
         //Update RRDDatabase
         $rrd_path_traffic_rx = ROOT_DIR . "/rrdtool/databases/router_{$data['router_id']}_interface_{$sendet_interface['name']}_traffic_rx.rrd";
         if (!file_exists($rrd_path_traffic_rx)) {
             exec("rrdtool create {$rrd_path_traffic_rx} --step 600 --start " . time() . " DS:traffic_rx:GAUGE:700:U:U DS:traffic_tx:GAUGE:900:U:U RRA:AVERAGE:0:1:144 RRA:AVERAGE:0:6:168 RRA:AVERAGE:0:18:240");
         }
         exec("rrdtool update {$rrd_path_traffic_rx} " . time() . ":" . round($traffic_rx_bps / 1000, 2) . ":" . round($traffic_tx_bps / 1000, 2));
         //add unknown ipv6 link local addresses to netmon
         //prepare data
         $ipv6_link_local_addr = explode("/", $sendet_interface['ipv6_link_local_addr']);
         $ipv6_link_local_netmask = isset($ipv6_link_local_addr[1]) ? (int) $ipv6_link_local_addr[1] : 64;
         $ipv6_link_local_addr = Ip::ipv6Expand($ipv6_link_local_addr[0]);
         //first try to determine network of given address
         $ipv6_link_local_network = Ip::ipv6NetworkFromAddr($ipv6_link_local_addr, (int) $ipv6_link_local_netmask);
         $network = new Network(false, false, $ipv6_link_local_network, (int) $ipv6_link_local_netmask, 6);
         if ($network->fetch()) {
             //if network found, then try to add ip address
             $ip = new Ip(false, (int) $networkinterface_id, $network->getNetworkId(), $ipv6_link_local_addr);
             $ip->store();
         }
     }
     RrdTool::updateRouterClientCountHistory($data['router_id'], $data['client_count']);
 }
Ejemplo n.º 2
0
    }
}
if ($_GET['section'] == "router_auto_assign") {
    $router_data = Router_old::getRouterByAutoAssignLoginString($_GET['router_auto_assign_login_string']);
    if (empty($router_data)) {
        $router = RoutersNotAssigned::getRouterByAutoAssignLoginString($_GET['router_auto_assign_login_string']);
        if (empty($router)) {
            //Make DB Insert
            try {
                DB::getInstance()->exec("INSERT INTO routers_not_assigned (create_date, update_date, hostname, router_auto_assign_login_string, interface)\n\t\t\t\t\t\t\t VALUES (NOW(), NOW(), '{$_GET['hostname']}', '{$_GET['router_auto_assign_login_string']}', '{$_GET['interface']}');");
            } catch (PDOException $e) {
                echo $e->getMessage();
            }
            $not_assigned_id = DB::getInstance()->lastInsertId();
            //Make history
            $actual_crawl_cycle = Crawling::getActualCrawlCycle();
            $event = new Event(false, (int) $actual_crawl_cycle['id'], 'not_assigned_router', (int) $not_assigned_id, 'new', array('router_auto_assign_login_string' => $_GET['router_auto_assign_login_string']));
            $event->store();
            echo "error;new_not_assigned;;{$_GET['router_auto_assign_login_string']}";
        } else {
            try {
                $result = DB::getInstance()->exec("UPDATE routers_not_assigned SET\n\t\t\t\t\t\t\t\t\t  update_date = NOW()\n\t\t\t\t\t\t\t\t   WHERE id = '{$router['id']}'");
            } catch (PDOException $e) {
                echo $e->getMessage();
            }
            echo "error;updated_not_assigned;;{$_GET['router_auto_assign_login_string']}";
        }
    } elseif ($router_data['allow_router_auto_assign'] == 0) {
        echo "error;autoassign_not_allowed;{$_GET['router_auto_assign_login_string']}";
    } elseif (!empty($router_data['router_auto_assign_hash'])) {
        echo "error;already_assigned;{$_GET['router_auto_assign_login_string']}";
Ejemplo n.º 3
0
 public function getRouterReliability($router_id, $crawl_cycles)
 {
     $status = array();
     $actual_crawl_cycle = Crawling::getActualCrawlCycle();
     $crawl_history = Router_old::getCrawlRouterHistoryExceptActualCrawlCycle($router_id, $actual_crawl_cycle['id'], $crawl_cycles);
     if (!empty($crawl_history)) {
         $count = count($crawl_history);
         $status['online_absolut'] = 0;
         $status['offline_absolut'] = 0;
         foreach ($crawl_history as $crawl) {
             if ($crawl['status'] == "online") {
                 $status['online_absolut']++;
             } else {
                 $status['offline_absolut']++;
             }
         }
         $status['online_percent'] = $status['online_absolut'] / $count * 100;
         $status['offline_percent'] = $status['offline_absolut'] / $count * 100;
     }
     return $status;
 }