Пример #1
0
<?php

require_once 'runtime.php';
require_once ROOT_DIR . '/lib/core/Network.class.php';
require_once ROOT_DIR . '/lib/core/Iplist.class.php';
$network = new Network((int) $_GET['network_id']);
$network->fetch();
$smarty->assign('network', $network);
$iplist = new Iplist(false, (int) $_GET['network_id']);
$smarty->assign('iplist', $iplist->getIplist());
$smarty->display("header.tpl.html");
$smarty->display("iplist.tpl.html");
$smarty->display("footer.tpl.html");
echo "\tinterfaces_used_for_crawling: ";
foreach ($interfaces_used_for_crawling as $iface) {
    echo $iface;
}
echo "\n";
echo "\tactual_crawl_cycle: " . $actual_crawl_cycle . "\n";
//fetch all routers that need to be crawled by a crawler. Respect offset and limit!
$routerlist = new Routerlist(false, false, "crawler", false, false, false, false, false, (int) $router_offset, (int) $router_limit, "router_id", "asc");
foreach ($routerlist->getRouterlist() as $key => $router) {
    echo $key + 1 . ". crawling Router " . $router->getHostname() . " (" . $router->getRouterId() . ")\n";
    foreach ($interfaces_used_for_crawling as $name) {
        echo "\tFetching IP-Addresses of interface " . $name . "\n";
        $networkinterface = new Networkinterface(false, $router->getRouterId(), $name);
        if ($networkinterface->fetch()) {
            $iplist = new Iplist($networkinterface->getNetworkinterfaceId());
            foreach ($iplist->getIplist() as $ip) {
                echo "\t\tWorking with " . $ip->getIp() . "\n";
                $xml_array = array();
                $ping = false;
                $return = array();
                if ($ip->getNetwork()->getIpv() == 6) {
                    $command = "ping6 -c {$ping_count} -w " . ($ping_count + 1) * $ping_timeout . " -W {$ping_timeout} -I {$network_connection_ipv6_interface} " . $ip->getIp();
                } elseif ($ip->getNetwork()->getIpv() == 4) {
                    $command = "ping -c {$ping_count} -w " . ($ping_count + 1) * $ping_timeout . " -W {$ping_timeout} " . $ip->getIp();
                }
                echo "\t\t\t" . $command . "\n";
                PsExecute($command, $ping_hard_timeout, 1);
                //fetch crawl data from router
                $return = array();
                if ($ip->getNetwork()->getIpv() == 6) {
                    $command = "curl -s --max-time {$crawl_timeout} -g http://[" . $ip->getIp() . "%25\$(cat /sys/class/net/{$network_connection_ipv6_interface}/ifindex)]/node.data";