Changeset 167 for www/system/generators/netwatch.php
- Timestamp:
 - Mar 24, 2009, 11:44:03 AM (17 years ago)
 - Location:
 - www/system/generators
 - Files:
 - 
      
- 2 edited
 
- 
          
  . (modified) (1 prop)
 - 
          
  netwatch.php (modified) (1 diff)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
www/system/generators
- 
Property       svn:ignore
 set to       
id_dsa
id_dsa.pub
 
 - 
Property       svn:ignore
 set to       
 - 
      
www/system/generators/netwatch.php
r161 r167 1 1 <?php 2 3 $SessionDisable = true; 2 4 include_once('../../global.php'); 3 5 4 $Commands = array(); 5 //$MaxSubnet = 1; 6 $Commands[] = '/tool netwatch remove [/tool netwatch find]'; 7 //for($i = 0; $i <= 4; $i++) 8 //{ 9 $DbResult = $Database->select('hosts', '*', 'IP != "" ORDER BY IP'); 10 while($Row = $DbResult->fetch_array()) 6 $UserName = 'admin-ssh'; 7 8 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet`'); 9 while($Router = $DbResult3->fetch_assoc()) 10 { 11 $Commands = array(); 12 $Commands[] = '/tool netwatch remove [find]'; 13 $DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `DHCP`="'.$Router['DHCP'].'"'); 14 while($Subnet = $DbResult->fetch_assoc()) 11 15 { 12 $Commands[] = '/tool netwatch add host='.$Row['IP'].' interval=1m comment='.$Row['name']; 16 //print_r($Subnet); 17 $I = explode('.', $Subnet['AddressRange']); 18 $I = $I[2]; 19 $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") AND (MAC != "00:00:00:00:00:00") ORDER BY IP'); 20 while($Host = $DbResult2->fetch_assoc()) 21 { 22 $Commands[] = '/tool netwatch add host='.$Host['IP'].' interval=1m comment='.$Host['name']; 23 } 13 24 } 14 //} 15 $Commands = implode(';', $Commands); 16 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"'; 17 echo($Command); 18 exec($Command, $Output); 19 print_r($Output); 25 $Commands = implode(';', $Commands); 26 $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Router['DHCP'].' "'.$Commands.'"'; 27 echo($Command."\n"); 28 $Output = ''; 29 exec($Command, $Output); 30 print_r($Output); 31 echo("\n"); 32 } 20 33 21 34 ?>  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  