Commit 7c4fc267 authored by Miha Petkovsek's avatar Miha Petkovsek Committed by GitHub
Browse files

Merge pull request #30 from yaleman/master

Fixes for issues #27 #28 #29
parents da2b2184 0e2eed4a
......@@ -372,7 +372,7 @@ class Scan extends Common_functions {
# set ping command based on OS type
if (PHP_OS == "FreeBSD" || PHP_OS == "NetBSD") { $cmd = $this->config->pingpath." -c $this->icmp_count -W ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
elseif(PHP_OS == "Linux" || PHP_OS == "OpenBSD") { $cmd = $this->config->pingpath." -c $this->icmp_count -w $this->icmp_timeout $address 1>/dev/null 2>&1"; }
elseif(PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT") { $cmd = $this->config->pingpath." -n $this->icmp_count -I ".($this->icmp_timeout*1000)." $address 1>/dev/null 2>&1"; }
elseif(PHP_OS == "WIN32" || PHP_OS == "Windows" || PHP_OS == "WINNT") { $cmd = $this->config->pingpath." -n $this->icmp_count -I ".($this->icmp_timeout*1000)." $address"; }
else { $cmd = $this->config->pingpath." -c $this->icmp_count -n $address 1>/dev/null 2>&1"; }
# execute command, return $retval
......
......@@ -635,7 +635,7 @@ class phpipamAgent extends Common_functions {
* @return void
*/
private function update_subnet_status_scantime ($subnet_id) {
try { $this->Database->updateObject("subnets", array("id"=>$id, "lastScan"=>$this->nowdate), "id"); }
try { $this->Database->updateObject("subnets", array("id"=>$subnet_id, "lastScan"=>$this->nowdate), "id"); }
catch (Exception $e) {}
}
......@@ -762,7 +762,7 @@ class phpipamAgent extends Common_functions {
// int check
if(!is_numeric($subnetId)) { return false; }
// check
try { $count = $this->Database->numObjectsFilter("subnets", "masterSubnetId", $subnetid); }
try { $count = $this->Database->numObjectsFilter("subnets", "masterSubnetId", $subnetId); }
catch (Exception $e) {
$this->Result->show("danger", _("Error: ").$e->getMessage());
return false;
......@@ -980,42 +980,12 @@ class phpipamAgent extends Common_functions {
* @access private
* @param mixed $subnets
* @param mixed $addresses
* @return void
* @return $subnets
*/
private function mysql_scan_discover_hosts_ping_nonthreaded ($subnets, $addresses) {
$z = 0; //addresses array index
/*
//run per MAX_THREADS
for ($m=0; $m<=sizeof($addresses); $m += $this->config->threads) {
// create threads
$threads = array();
//fork processes
for ($i = 0; $i <= $this->config->threads && $i <= sizeof($addresses); $i++) {
//only if index exists!
if(isset($addresses[$z])) {
//start new thread
$threads[$z] = new Thread( 'ping_address' );
$threads[$z]->start( $this->transform_to_dotted( $addresses[$z]['ip_addr']) );
$z++; //next index
}
}
// wait for all the threads to finish
while( !empty( $threads ) ) {
foreach( $threads as $index => $thread ) {
if( ! $thread->isAlive() ) {
//unset dead hosts
if($thread->getExitCode() != 0) {
unset($addresses[$index]);
}
//remove thread
unset( $threads[$index]);
}
}
usleep(200000);
}
for ($i = 0; $i <= sizeof($addresses); $i++) {
ping_address( $this->transform_to_dotted( $addresses[$z]['ip_addr']) );
}
//ok, we have all available addresses, rekey them
......@@ -1030,7 +1000,6 @@ class phpipamAgent extends Common_functions {
}
}
}
*/
// return result
return $subnets;
......@@ -1048,7 +1017,7 @@ class phpipamAgent extends Common_functions {
$discovered = 0; //for mailing
# reset db connection for ping / pear
if ($this->can_type!=="fping") {
if ($this->scan_type!=="fping") {
unset($this->Database);
$this->Database = new Database_PDO ();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment