mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
collect-wireless-mac: use $LogPrintExit
This commit is contained in:
@ -9,6 +9,7 @@
|
|||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
|
:global LogPrintExit;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ $ScriptLock "collect-wireless-mac.capsman";
|
|||||||
|
|
||||||
:if ([ / caps-man access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
:if ([ / caps-man access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
||||||
/ caps-man access-list add comment="--- collected above ---" disabled=yes;
|
/ caps-man access-list add comment="--- collected above ---" disabled=yes;
|
||||||
:log warn "Added disabled access-list entry with comment '--- collected above ---'.";
|
$LogPrintExit warn "Added disabled access-list entry with comment '--- collected above ---'." false;
|
||||||
}
|
}
|
||||||
:local PlaceBefore [ / caps-man access-list find where comment="--- collected above ---" disabled ];
|
:local PlaceBefore [ / caps-man access-list find where comment="--- collected above ---" disabled ];
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ $ScriptLock "collect-wireless-mac.capsman";
|
|||||||
:local Vendor [ $GetMacVendor $Mac ];
|
:local Vendor [ $GetMacVendor $Mac ];
|
||||||
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
||||||
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
||||||
/ log info $Message;
|
$LogPrintExit info $Message false;
|
||||||
/ caps-man access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
/ caps-man access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
||||||
$SendNotification ($Mac . " connected to " . $Ssid) \
|
$SendNotification ($Mac . " connected to " . $Ssid) \
|
||||||
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
||||||
@ -60,7 +61,7 @@ $ScriptLock "collect-wireless-mac.capsman";
|
|||||||
"DNS name: " . $DnsName . "\n" . \
|
"DNS name: " . $DnsName . "\n" . \
|
||||||
"Date: " . $DateTime);
|
"Date: " . $DateTime);
|
||||||
} else={
|
} else={
|
||||||
:local Comment [ / caps-man access-list get $AccessList comment ];
|
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
|
||||||
:log debug ("MAC address " . $Mac . " already known: " . $Comment);
|
[ / caps-man access-list get $AccessList comment ]) false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
|
:global LogPrintExit;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ $ScriptLock "collect-wireless-mac.local";
|
|||||||
|
|
||||||
:if ([ / interface wireless access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
:if ([ / interface wireless access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
||||||
/ interface wireless access-list add comment="--- collected above ---" disabled=yes;
|
/ interface wireless access-list add comment="--- collected above ---" disabled=yes;
|
||||||
:log warn "Added disabled access-list entry with comment '--- collected above ---'.";
|
$LogPrintExit warn "Added disabled access-list entry with comment '--- collected above ---'." false;
|
||||||
}
|
}
|
||||||
:local PlaceBefore [ / interface wireless access-list find where comment="--- collected above ---" disabled ];
|
:local PlaceBefore [ / interface wireless access-list find where comment="--- collected above ---" disabled ];
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ $ScriptLock "collect-wireless-mac.local";
|
|||||||
:local Vendor [ $GetMacVendor $Mac ];
|
:local Vendor [ $GetMacVendor $Mac ];
|
||||||
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
||||||
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
||||||
/ log info $Message;
|
$LogPrintExit info $Message false;
|
||||||
/ interface wireless access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
/ interface wireless access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
||||||
$SendNotification ($Mac . " connected to " . $Ssid) \
|
$SendNotification ($Mac . " connected to " . $Ssid) \
|
||||||
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
||||||
@ -60,7 +61,7 @@ $ScriptLock "collect-wireless-mac.local";
|
|||||||
"DNS name: " . $DnsName . "\n" . \
|
"DNS name: " . $DnsName . "\n" . \
|
||||||
"Date: " . $DateTime);
|
"Date: " . $DateTime);
|
||||||
} else={
|
} else={
|
||||||
:local Comment [ / interface wireless access-list get $AccessList comment ];
|
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
|
||||||
:log debug ("MAC address " . $Mac . " already known: " . $Comment);
|
[ / interface wireless access-list get $AccessList comment ]) false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
|
:global LogPrintExit;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
|
|||||||
|
|
||||||
:if ([ / %PATH% access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
:if ([ / %PATH% access-list print count-only where comment="--- collected above ---" disabled ] = 0) do={
|
||||||
/ %PATH% access-list add comment="--- collected above ---" disabled=yes;
|
/ %PATH% access-list add comment="--- collected above ---" disabled=yes;
|
||||||
:log warn "Added disabled access-list entry with comment '--- collected above ---'.";
|
$LogPrintExit warn "Added disabled access-list entry with comment '--- collected above ---'." false;
|
||||||
}
|
}
|
||||||
:local PlaceBefore [ / %PATH% access-list find where comment="--- collected above ---" disabled ];
|
:local PlaceBefore [ / %PATH% access-list find where comment="--- collected above ---" disabled ];
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
|
|||||||
:local Vendor [ $GetMacVendor $Mac ];
|
:local Vendor [ $GetMacVendor $Mac ];
|
||||||
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
:local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \
|
||||||
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
"first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface);
|
||||||
/ log info $Message;
|
$LogPrintExit info $Message false;
|
||||||
/ %PATH% access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
/ %PATH% access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes;
|
||||||
$SendNotification ($Mac . " connected to " . $Ssid) \
|
$SendNotification ($Mac . " connected to " . $Ssid) \
|
||||||
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \
|
||||||
@ -62,7 +63,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%";
|
|||||||
"DNS name: " . $DnsName . "\n" . \
|
"DNS name: " . $DnsName . "\n" . \
|
||||||
"Date: " . $DateTime);
|
"Date: " . $DateTime);
|
||||||
} else={
|
} else={
|
||||||
:local Comment [ / %PATH% access-list get $AccessList comment ];
|
$LogPrintExit debug ("MAC address " . $Mac . " already known: " . \
|
||||||
:log debug ("MAC address " . $Mac . " already known: " . $Comment);
|
[ / %PATH% access-list get $AccessList comment ]) false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user