mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Final update for overwriting ifAlias
This commit is contained in:
@ -29,7 +29,7 @@ if (!empty($ifName) && is_numeric($port_id)) {
|
||||
}
|
||||
if (dbUpdate(array('ifAlias'=>$descr), 'ports', '`port_id`=?', array($port_id)) > 0) {
|
||||
$device = device_by_id_cache($device_id);
|
||||
if (empty($descr)) {
|
||||
if ($descr === 'repoll') {
|
||||
del_dev_attrib($device, 'ifName');
|
||||
}
|
||||
else {
|
||||
|
@ -435,8 +435,13 @@ function get_dev_entity_state($device) {
|
||||
return $state;
|
||||
}
|
||||
|
||||
function get_dev_attrib($device, $attrib_type) {
|
||||
if ($row = dbFetchRow("SELECT attrib_value FROM devices_attribs WHERE `device_id` = ? AND `attrib_type` = ?", array($device['device_id'], $attrib_type))) {
|
||||
function get_dev_attrib($device, $attrib_type, $attrib_value='') {
|
||||
$params = array($device['device_id'], $attrib_type);
|
||||
if (!empty($attrib_value)) {
|
||||
$sql = " AND `attrib_value`=?";
|
||||
array_push($params, $attrib_value);
|
||||
}
|
||||
if ($row = dbFetchRow("SELECT attrib_value FROM devices_attribs WHERE `device_id` = ? AND `attrib_type` = ? $sql", $params)) {
|
||||
return $row['attrib_value'];
|
||||
}
|
||||
else {
|
||||
|
@ -333,6 +333,13 @@ foreach ($ports as $port) {
|
||||
|
||||
// Update IF-MIB data
|
||||
foreach ($data_oids as $oid) {
|
||||
|
||||
if ($oid == 'ifAlias') {
|
||||
if (get_dev_attrib($device, 'ifName', $port['ifName'])) {
|
||||
$this_port['ifAlias'] = $port['ifAlias'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) {
|
||||
$port['update'][$oid] = array('NULL');
|
||||
log_event($oid.': '.$port[$oid].' -> NULL', $device, 'interface', $port['port_id']);
|
||||
|
Reference in New Issue
Block a user