2009-11-09 15:52:04 +00:00
|
|
|
<?php
|
|
|
|
|
2010-02-15 03:05:16 +00:00
|
|
|
$hrDevice_oids = [
|
|
|
|
'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 = [];
|
|
|
|
foreach ($hrDevice_oids as $oid) {
|
2015-03-01 12:23:31 +00:00
|
|
|
$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
|
|
|
|
2011-03-15 11:39:50 +00:00
|
|
|
if (is_array($hrDevices)) {
|
|
|
|
foreach ($hrDevices as $hrDevice) {
|
|
|
|
if (is_array($hrDevice) && is_numeric($hrDevice['hrDeviceIndex'])) {
|
2014-01-13 17:43:58 +00:00
|
|
|
if (dbFetchCell('SELECT COUNT(*) FROM `hrDevice` WHERE device_id = ? AND hrDeviceIndex = ?', [$device['device_id'], $hrDevice['hrDeviceIndex']])) {
|
2014-06-10 22:21:10 +01:00
|
|
|
$update_array = [
|
2021-03-28 17:25:30 -05:00
|
|
|
'hrDeviceType' => $hrDevice['hrDeviceType'],
|
|
|
|
'hrDeviceDescr' => $hrDevice['hrDeviceDescr'],
|
|
|
|
'hrDeviceStatus' => $hrDevice['hrDeviceStatus'],
|
|
|
|
'hrDeviceErrors' => $hrDevice['hrDeviceErrors'],
|
2015-07-13 20:10:26 +02:00
|
|
|
];
|
2011-03-15 11:39:50 +00:00
|
|
|
if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor') {
|
2021-03-28 17:25:30 -05:00
|
|
|
$update_array['hrProcessorLoad'] = $hrDevice['hrProcessorLoad'];
|
2015-07-13 20:10:26 +02:00
|
|
|
}
|
|
|
|
|
2014-06-10 22:21:10 +01:00
|
|
|
dbUpdate($update_array, 'hrDevice', 'device_id=? AND hrDeviceIndex=?', [$device['device_id'], $hrDevice['hrDeviceIndex']]);
|
2015-07-13 20:10:26 +02:00
|
|
|
echo '.';
|
2016-08-28 12:32:58 -05:00
|
|
|
} else {
|
2021-03-28 17:25:30 -05:00
|
|
|
$inserted_rows = dbInsert(['hrDeviceIndex' => $hrDevice['hrDeviceIndex'], 'device_id' => $device['device_id'], 'hrDeviceType' => $hrDevice['hrDeviceType'], 'hrDeviceDescr' => $hrDevice['hrDeviceDescr'], 'hrDeviceStatus' => $hrDevice['hrDeviceStatus'], 'hrDeviceErrors' => (int) $hrDevice['hrDeviceErrors']], 'hrDevice');
|
2015-07-13 20:10:26 +02:00
|
|
|
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
|
|
|
|
|
2011-03-15 15:39:57 +00:00
|
|
|
$valid_hrDevice[$hrDevice['hrDeviceIndex']] = 1;
|
2015-07-13 20:10:26 +02:00
|
|
|
}//end if
|
|
|
|
}//end foreach
|
|
|
|
}//end if
|
|
|
|
|
2009-11-09 15:52:04 +00:00
|
|
|
$sql = "SELECT * FROM `hrDevice` WHERE `device_id` = '" . $device['device_id'] . "'";
|
|
|
|
|
2014-01-13 17:43:58 +00:00
|
|
|
foreach (dbFetchRows($sql) as $test_hrDevice) {
|
2011-03-15 15:39:57 +00:00
|
|
|
if (! $valid_hrDevice[$test_hrDevice['hrDeviceIndex']]) {
|
2009-11-09 15:52:04 +00:00
|
|
|
echo '-';
|
2014-01-13 17:43:58 +00:00
|
|
|
dbDelete('hrDevice', '`hrDevice_id` = ?', [$test_hrDevice['hrDevice_id']]);
|
2015-08-20 15:59:43 +02:00
|
|
|
d_echo($test_hrDevice);
|
2009-11-09 15:52:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($valid_hrDevice);
|
|
|
|
echo "\n";
|