| 
									
										
										
										
											2009-11-09 15:52:04 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $hrDevice_oids = array( | 
					
						
							|  |  |  |     'hrDeviceEntry', | 
					
						
							|  |  |  |     'hrProcessorEntry', | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2015-08-20 15:59:43 +02:00
										 |  |  | d_echo($hrDevices); | 
					
						
							| 
									
										
										
										
											2009-11-09 15:52:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-22 21:58:49 +00:00
										 |  |  | $hrDevices = array(); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | foreach ($hrDevice_oids as $oid) { | 
					
						
							|  |  |  |     $hrDevices = snmpwalk_cache_oid($device, $oid, $hrDevices, 'HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES'); | 
					
						
							| 
									
										
										
										
											2009-11-09 15:52:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-20 15:59:43 +02:00
										 |  |  | d_echo($hrDevices); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (is_array($hrDevices)) { | 
					
						
							|  |  |  |     foreach ($hrDevices as $hrDevice) { | 
					
						
							|  |  |  |         if (is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) { | 
					
						
							|  |  |  |             if (dbFetchCell('SELECT COUNT(*) FROM `hrDevice` WHERE device_id = ? AND hrDeviceIndex = ?', array($device['device_id'], $hrDevice['hrDeviceIndex']))) { | 
					
						
							|  |  |  |                 $update_array = array( | 
					
						
							|  |  |  |                     'hrDeviceType'   => mres($hrDevice['hrDeviceType']), | 
					
						
							|  |  |  |                     'hrDeviceDescr'  => mres($hrDevice['hrDeviceDescr']), | 
					
						
							|  |  |  |                     'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), | 
					
						
							|  |  |  |                     'hrDeviceErrors' => mres($hrDevice['hrDeviceErrors']), | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |                 if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor') { | 
					
						
							|  |  |  |                     $update_array['hrProcessorLoad'] = mres($hrDevice['hrProcessorLoad']); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 dbUpdate($update_array, 'hrDevice', 'device_id=? AND hrDeviceIndex=?', array($device['device_id'], $hrDevice['hrDeviceIndex'])); | 
					
						
							|  |  |  |                 echo '.'; | 
					
						
							| 
									
										
										
										
											2016-08-28 12:32:58 -05:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |                 $inserted_rows = dbInsert(array('hrDeviceIndex' => mres($hrDevice['hrDeviceIndex']), 'device_id' => mres($device['device_id']), 'hrDeviceType' => mres($hrDevice['hrDeviceType']), 'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']), 'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), 'hrDeviceErrors' => (int) mres($hrDevice['hrDeviceErrors'])), 'hrDevice'); | 
					
						
							|  |  |  |                 echo '+'; | 
					
						
							| 
									
										
										
										
											2015-08-20 15:59:43 +02:00
										 |  |  |                 d_echo($hrDevice); | 
					
						
							|  |  |  |                 d_echo("$inserted_rows row inserted"); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |             }//end if
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $valid_hrDevice[$hrDevice['hrDeviceIndex']] = 1; | 
					
						
							|  |  |  |         }//end if
 | 
					
						
							|  |  |  |     }//end foreach
 | 
					
						
							|  |  |  | }//end if
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-09 15:52:04 +00:00
										 |  |  | $sql = "SELECT * FROM `hrDevice` WHERE `device_id`  = '".$device['device_id']."'"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | foreach (dbFetchRows($sql) as $test_hrDevice) { | 
					
						
							|  |  |  |     if (!$valid_hrDevice[$test_hrDevice['hrDeviceIndex']]) { | 
					
						
							|  |  |  |         echo '-'; | 
					
						
							|  |  |  |         dbDelete('hrDevice', '`hrDevice_id` = ?', array($test_hrDevice['hrDevice_id'])); | 
					
						
							| 
									
										
										
										
											2015-08-20 15:59:43 +02:00
										 |  |  |         d_echo($test_hrDevice); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-11-09 15:52:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | unset($valid_hrDevice); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | echo "\n"; |