- Timestamp:
- Aug 5, 2014, 10:49:06 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r667 r682 7 7 $System->Run(); 8 8 9 $Path = array('tool', 'netwatch'); 10 $Period = 60; // every 60 seconds 9 function NetwatchImport() 10 { 11 global $System, $Config; 11 12 12 13 while(1)14 {15 13 $StartTime = time(); 16 14 … … 27 25 { 28 26 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 29 $Routerboard = new Routerboard(); 30 $Routerboard->UserName = $Config['MainRouter']['UserName']; 31 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 32 $Routerboard->HostName = $Subnet['DHCP']; 33 $List = $Routerboard->ListGetPrint($Path, array('host', 'status')); 27 $Routerboard = new RouterosAPI(); 28 $Routerboard->Connect($Subnet['DHCP'], $Config['API']['UserName'], $Config['API']['Password']); 29 if(!$Routerboard->Connected) continue; 30 $Routerboard->Write('/tool/netwatch/getall', false); 31 $Routerboard->Write('=.proplist=host,status'); 32 $Read = $Routerboard->Read(false); 33 $List = $Routerboard->ParseResponse($Read); 34 34 foreach($List as $Properties) 35 35 { … … 96 96 else $System->Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 97 97 } 98 99 $EndTime = time();100 $Delay = $Period - ($EndTime - $StartTime);101 if($Delay < 0) $Delay = 0;102 103 echo('Waiting '.$Delay.' seconds...'."\n");104 sleep($Delay);105 98 } 106 99 100 RepeatFunction(60, 'NetwatchImport');
Note:
See TracChangeset
for help on using the changeset viewer.