Ejemplo n.º 1
0
    $autodiscoveryJob->save();
    exit(40);
}
$autodiscoveryJob->addNotice("Engine completed discovering devices");
$tracerouteEnabled = $config->getVar("traceroute_enabled");
$tracerouteEnabled = false;
if (!$tracerouteEnabled) {
    $autodiscoveryJob->addNotice("Tracerouting skipped.  Hosts will be set as top-level.");
} else {
    $autodiscoveryJob->addNotice("Beginning Traceroute for found hosts.");
    $c = new Criteria();
    $c->add(AutodiscoveryDevicePeer::JOB_ID, $autodiscoveryJob->getId());
    $devices = AutodiscoveryDevicePeer::doSelect($c);
    foreach ($devices as $device) {
        $autodiscoveryJob->addNotice("Attempting Traceroute to " . $device->getAddress());
        $tr = Net_Traceroute::factory();
        if (!PEAR::isError($tr)) {
            $response = $tr->traceroute($device->getAddress());
            $hops = $response->getHops();
            $numOfHops = count($hops);
            $found = false;
            for ($counter = $numOfHops - 1; $counter >= 0; $counter--) {
                // Check the farthest hop first
                $c = new Criteria();
                $c1 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $hops[$counter]['ip']);
                $c2 = $c->getNewCriterion(NagiosHostPeer::ADDRESS, $hops[$counter['machine']]);
                $c1->addOr($c2);
                $c->add($c1);
                $host = NagiosHostPeer::doSelectOne($c);
                if ($host) {
                    // Found parent
Ejemplo n.º 2
0
 /**
  * Factory for Net_Traceroute
  *
  * Call this method to create a new instance of Net_Traceroute
  *
  * @return object Net_Traceroute
  * @access public
  */
 function factory()
 {
     $OS_Guess = new OS_Guess();
     $sysname = $OS_Guess->getSysname();
     $traceroute_path = '';
     if (($traceroute_path = Net_Traceroute::_setTraceroutePath($sysname)) == NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY) {
         return PEAR::throwError(NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY_MSG, NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY);
     } else {
         return new Net_Traceroute($traceroute_path, $sysname);
     }
 }