New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discoverying and polling vrf #Issue280 #2820
Merged
Merged
Changes from 12 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
faf2b84
Adding sql-schema
h3n0c 9c0f0d7
Adding mibs
h3n0c 1bf8610
discoverying and polling VRF
h3n0c 2820689
Adding sql-schema
h3n0c 11097f6
Adding mibs
h3n0c b637ce6
discoverying and polling VRF
h3n0c 1f58058
merging
h3n0c 255eb9c
Adding sql-schema
h3n0c a7c88be
Adding mibs
h3n0c 831940c
discoverying and polling VRF
h3n0c 286dcdc
Adding sql-schema
h3n0c 5d9c6eb
merging
h3n0c 1a21c51
Syntax update
h3n0c c801e4b
Adding sql-schema
h3n0c 3c3cf96
Adding mibs
h3n0c 30eb276
discoverying and polling VRF
h3n0c 6a03b7d
Adding sql-schema
h3n0c b50ca4b
Adding sql-schema
h3n0c 63fa635
Adding sql-schema
h3n0c 674171c
Syntax update
h3n0c 8d466dd
merging
h3n0c a01fc7c
modify order of cisco-vrf-lite
h3n0c 24231cd
Adding sql-schema
h3n0c ea5d2c6
Adding mibs
h3n0c 0ac8f58
discoverying and polling VRF
h3n0c 386ed4b
Adding sql-schema
h3n0c b9f9189
Adding sql-schema
h3n0c 5705791
Adding sql-schema
h3n0c 21d2b45
Syntax update
h3n0c 0b34930
Adding sql-schema
h3n0c 724ad08
discoverying and polling VRF
h3n0c f3ae90f
Adding sql-schema
h3n0c 990a009
Adding sql-schema
h3n0c f5fde61
Adding sql-schema
h3n0c 08658e3
Syntax update
h3n0c e755edf
modify order of cisco-vrf-lite
h3n0c 13aac3f
merging
h3n0c 47c830a
bug correction on ospf polling module
h3n0c 1890cfb
Merge remote-tracking branch 'refs/remotes/librenms/master' into issu…
h3n0c 8a3d14f
Correct data duplication on discovering cisco vrf lite
h3n0c 6de58f5
merging
h3n0c cfee15f
update Authors
h3n0c 7a00d91
update branch
h3n0c 24df0a0
merging
h3n0c 21e37c2
merging - update schema
h3n0c 6a51746
bug correction
h3n0c 0161260
merging
h3n0c File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,78 +4,90 @@ | |
|
||
echo 'ARP Table : '; | ||
|
||
$ipNetToMedia_data = snmp_walk($device, 'ipNetToMediaPhysAddress', '-Oq', 'IP-MIB'); | ||
$ipNetToMedia_data = str_replace('ipNetToMediaPhysAddress.', '', trim($ipNetToMedia_data)); | ||
$ipNetToMedia_data = str_replace('IP-MIB::', '', trim($ipNetToMedia_data)); | ||
if( key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco'])!=0) ){ | ||
$vrfs_lite_cisco = $device['vrf_lite_cisco']; | ||
} | ||
else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a space after the else so: else { |
||
$vrfs_lite_cisco = array(array('context_name'=>null)); | ||
} | ||
foreach ($vrfs_lite_cisco as $vrf) { | ||
$device['context_name']=$vrf['context_name']; | ||
|
||
$ipNetToMedia_data = snmp_walk($device, 'ipNetToMediaPhysAddress', '-Oq', 'IP-MIB'); | ||
$ipNetToMedia_data = str_replace('ipNetToMediaPhysAddress.', '', trim($ipNetToMedia_data)); | ||
$ipNetToMedia_data = str_replace('IP-MIB::', '', trim($ipNetToMedia_data)); | ||
|
||
foreach (explode("\n", $ipNetToMedia_data) as $data) { | ||
list($oid, $mac) = explode(' ', $data); | ||
list($if, $first, $second, $third, $fourth) = explode('.', $oid); | ||
$ip = $first.'.'.$second.'.'.$third.'.'.$fourth; | ||
if ($ip != '...') { | ||
$interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $if)); | ||
foreach (explode("\n", $ipNetToMedia_data) as $data) { | ||
list($oid, $mac) = explode(' ', $data); | ||
list($if, $first, $second, $third, $fourth) = explode('.', $oid); | ||
$ip = $first.'.'.$second.'.'.$third.'.'.$fourth; | ||
if ($ip != '...') { | ||
$interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $if)); | ||
|
||
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(':', $mac); | ||
$m_a = zeropad($m_a); | ||
$m_b = zeropad($m_b); | ||
$m_c = zeropad($m_c); | ||
$m_d = zeropad($m_d); | ||
$m_e = zeropad($m_e); | ||
$m_f = zeropad($m_f); | ||
$md_a = hexdec($m_a); | ||
$md_b = hexdec($m_b); | ||
$md_c = hexdec($m_c); | ||
$md_d = hexdec($m_d); | ||
$md_e = hexdec($m_e); | ||
$md_f = hexdec($m_f); | ||
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f"; | ||
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(':', $mac); | ||
$m_a = zeropad($m_a); | ||
$m_b = zeropad($m_b); | ||
$m_c = zeropad($m_c); | ||
$m_d = zeropad($m_d); | ||
$m_e = zeropad($m_e); | ||
$m_f = zeropad($m_f); | ||
$md_a = hexdec($m_a); | ||
$md_b = hexdec($m_b); | ||
$md_c = hexdec($m_c); | ||
$md_d = hexdec($m_d); | ||
$md_e = hexdec($m_e); | ||
$md_f = hexdec($m_f); | ||
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f"; | ||
|
||
$mac_table[$if][$mac]['ip'] = $ip; | ||
$mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f"; | ||
$clean_mac = $m_a.$m_b.$m_c.$m_d.$m_e.$m_f; | ||
$mac_table[$if][$mac]['cleanmac'] = $clean_mac; | ||
$port_id = $interface['port_id']; | ||
$mac_table[$port_id][$clean_mac] = 1; | ||
$mac_table[$if][$mac]['ip'] = $ip; | ||
$mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f"; | ||
$clean_mac = $m_a.$m_b.$m_c.$m_d.$m_e.$m_f; | ||
$mac_table[$if][$mac]['cleanmac'] = $clean_mac; | ||
$port_id = $interface['port_id']; | ||
$mac_table[$port_id][$clean_mac] = 1; | ||
|
||
if (dbFetchCell('SELECT COUNT(*) from ipv4_mac WHERE port_id = ? AND ipv4_address = ?', array($interface['port_id'], $ip))) { | ||
// Commented below, no longer needed but leaving for reference. | ||
// $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE port_id = '".$interface['port_id']."' AND ipv4_address = '$ip'"; | ||
$old_mac = dbFetchCell('SELECT mac_address from ipv4_mac WHERE ipv4_address=? AND port_id=?', array($ip, $interface['port_id'])); | ||
if (dbFetchCell('SELECT COUNT(*) from ipv4_mac WHERE port_id = ? AND ipv4_address = ? AND `context_name`= ?', array($interface['port_id'], $ip, $device['context_name']))) { | ||
// Commented below, no longer needed but leaving for reference. | ||
// $sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE port_id = '".$interface['port_id']."' AND ipv4_address = '$ip'"; | ||
$old_mac = dbFetchCell('SELECT mac_address from ipv4_mac WHERE ipv4_address=? AND port_id=? AND `context_name`= ?', array($ip, $interface['port_id']), $device['context_name']); | ||
|
||
if ($clean_mac != $old_mac && $clean_mac != '' && $old_mac != '') { | ||
d_echo("Changed mac address for $ip from $old_mac to $clean_mac\n"); | ||
if ($clean_mac != $old_mac && $clean_mac != '' && $old_mac != '') { | ||
d_echo("Changed mac address for $ip from $old_mac to $clean_mac\n"); | ||
|
||
log_event("MAC change: $ip : ".mac_clean_to_readable($old_mac).' -> '.mac_clean_to_readable($clean_mac), $device, 'interface', $interface['port_id']); | ||
} | ||
log_event("MAC change: $ip : ".mac_clean_to_readable($old_mac).' -> '.mac_clean_to_readable($clean_mac), $device, 'interface', $interface['port_id']); | ||
} | ||
|
||
dbUpdate(array('mac_address' => $clean_mac), 'ipv4_mac', 'port_id=? AND ipv4_address=?', array($interface['port_id'], $ip)); | ||
echo '.'; | ||
} | ||
else if (isset($interface['port_id'])) { | ||
echo '+'; | ||
// echo("Add MAC $mac\n"); | ||
$insert_data = array( | ||
'port_id' => $interface['port_id'], | ||
'mac_address' => $clean_mac, | ||
'ipv4_address' => $ip, | ||
); | ||
dbUpdate(array('mac_address' => $clean_mac), 'ipv4_mac', 'port_id=? AND ipv4_address=? AND `context_name`= ?', array($interface['port_id'], $ip, $device['context_name'])); | ||
echo '.'; | ||
} | ||
else if (isset($interface['port_id'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update this to: elseif () { |
||
echo '+'; | ||
// echo("Add MAC $mac\n"); | ||
$insert_data = array( | ||
'port_id' => $interface['port_id'], | ||
'mac_address' => $clean_mac, | ||
'ipv4_address' => $ip, | ||
'context_name' => $device['context_name'], | ||
); | ||
|
||
dbInsert($insert_data, 'ipv4_mac'); | ||
dbInsert($insert_data, 'ipv4_mac'); | ||
}//end if | ||
}//end if | ||
}//end if | ||
}//end foreach | ||
}//end foreach | ||
|
||
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.port_id = I.port_id and I.device_id = '".$device['device_id']."'"; | ||
foreach (dbFetchRows($sql) as $entry) { | ||
$entry_mac = $entry['mac_address']; | ||
$entry_if = $entry['port_id']; | ||
if (!$mac_table[$entry_if][$entry_mac]) { | ||
dbDelete('ipv4_mac', '`port_id` = ? AND `mac_address` = ?', array($entry_if, $entry_mac)); | ||
d_echo("Removing MAC $entry_mac from interface ".$interface['ifName']); | ||
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.port_id = I.port_id and I.device_id = ' AND `context_name`= ?".$device['device_id']." AND M.context_name='". $device['context_name'] ."'"; | ||
foreach (dbFetchRows($sql) as $entry) { | ||
$entry_mac = $entry['mac_address']; | ||
$entry_if = $entry['port_id']; | ||
if (!$mac_table[$entry_if][$entry_mac]) { | ||
dbDelete('ipv4_mac', '`port_id` = ? AND `mac_address` = ? AND `context_name`= ?', array($entry_if, $entry_mac, $device['context_name'])); | ||
d_echo("Removing MAC $entry_mac from interface ".$interface['ifName']); | ||
|
||
echo '-'; | ||
echo '-'; | ||
} | ||
} | ||
echo "\n"; | ||
unset($mac); | ||
unset($device['context_name']); | ||
} | ||
|
||
echo "\n"; | ||
unset($mac); | ||
unset($vrfs_c); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you align this config item with the others please.