Update get_mac_list.php
This commit is contained in:
parent
f642b61bcf
commit
da8e8e4ca2
1 changed files with 112 additions and 112 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0); // skippa felmeddelanden
|
||||||
|
|
||||||
// Ange IP-range av switchar
|
// Ange IP-range av switchar
|
||||||
$switch_ips = array(
|
$switch_ips = array(
|
||||||
|
|
@ -15,7 +15,7 @@ $switch_ips = array(
|
||||||
'172.30.0.28',
|
'172.30.0.28',
|
||||||
'172.30.0.28'
|
'172.30.0.28'
|
||||||
);
|
);
|
||||||
$community = 'public'; // Byt ut mot ditt SNMP-community
|
$community = 'public'; // SNMP "lösenord"
|
||||||
|
|
||||||
foreach ($switch_ips as $switch_ip) {
|
foreach ($switch_ips as $switch_ip) {
|
||||||
echo "Bearbetar switch: $switch_ip\n";
|
echo "Bearbetar switch: $switch_ip\n";
|
||||||
|
|
@ -86,7 +86,7 @@ foreach ($switch_ips as $switch_ip) {
|
||||||
$bridgePort = $bridgePorts[$index];
|
$bridgePort = $bridgePorts[$index];
|
||||||
if ($bridgePort == '0') {
|
if ($bridgePort == '0') {
|
||||||
// Bridge-port ID 0 indikerar switchens interna MAC-adress
|
// Bridge-port ID 0 indikerar switchens interna MAC-adress
|
||||||
$macToInterface[$macAddress] = 'Intern port';
|
$macToInterface[$macAddress] = 'Switchens interna mac-adress';
|
||||||
} elseif (isset($bridgePortToIfIndex[$bridgePort])) {
|
} elseif (isset($bridgePortToIfIndex[$bridgePort])) {
|
||||||
$ifIndex = $bridgePortToIfIndex[$bridgePort];
|
$ifIndex = $bridgePortToIfIndex[$bridgePort];
|
||||||
if (isset($ifIndexToName[$ifIndex])) {
|
if (isset($ifIndexToName[$ifIndex])) {
|
||||||
|
|
@ -96,15 +96,15 @@ foreach ($switch_ips as $switch_ip) {
|
||||||
$macToInterface[$macAddress] = 'Okänt interface';
|
$macToInterface[$macAddress] = 'Okänt interface';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$macToInterface[$macAddress] = 'Okänd bridge-port';
|
$macToInterface[$macAddress] = 'Okänd switch-port';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$macToInterface[$macAddress] = 'Okänd bridge-port';
|
$macToInterface[$macAddress] = 'Okänd switch-port';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Skriv ut listan för varje switch
|
// Skriv ut listan för varje switch
|
||||||
foreach ($macToInterface as $macAddress => $interfaceName) {
|
foreach ($macToInterface as $macAddress => $interfaceName) {
|
||||||
echo "MAC-adress: $macAddress - Port: $interfaceName\n";
|
echo "MAC-adress: $macAddress - Switch Port: $interfaceName\n";
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue