diff options
author | Christian Hesse <mail@eworm.de> | 2021-07-06 22:37:49 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-07-07 00:33:34 +0200 |
commit | e5674dec240cb3abfa71d9a3be76403b40301722 (patch) | |
tree | cb781225103b739b680e7c455a9b9c2ca64b5137 | |
parent | c982cde0bd01ed27b030ab83593cdc87c328b3d9 (diff) |
collect-wireless-mac: use $EitherOr and simplify code
-rw-r--r-- | collect-wireless-mac.capsman | 6 | ||||
-rw-r--r-- | collect-wireless-mac.local | 6 | ||||
-rw-r--r-- | collect-wireless-mac.template | 6 |
3 files changed, 6 insertions, 12 deletions
diff --git a/collect-wireless-mac.capsman b/collect-wireless-mac.capsman index 0373982..f61d058 100644 --- a/collect-wireless-mac.capsman +++ b/collect-wireless-mac.capsman @@ -16,6 +16,7 @@ :global Identity; +:global EitherOr; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -51,10 +52,7 @@ $ScriptLock $0 false 10; :local Lease ([ / ip dhcp-server lease find where mac-address=($RegVal->"mac-address") dynamic=yes status=bound ]->0); :if ([ :len $Lease ] > 0) do={ :set Address [ / ip dhcp-server lease get $Lease address ]; - :set HostName [ / ip dhcp-server lease get $Lease host-name ]; - :if ([ :len $HostName ] = 0) do={ - :set HostName "no hostname"; - } + :set HostName [ $EitherOr [ / ip dhcp-server lease get $Lease host-name ] "no hostname" ]; :set DnsName "no dns name"; :local DnsRec ([ / ip dns static find where address=$Address ]->0); :if ([ :len $DnsRec ] > 0) do={ diff --git a/collect-wireless-mac.local b/collect-wireless-mac.local index 109ec5c..6c07044 100644 --- a/collect-wireless-mac.local +++ b/collect-wireless-mac.local @@ -16,6 +16,7 @@ :global Identity; +:global EitherOr; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -51,10 +52,7 @@ $ScriptLock $0 false 10; :local Lease ([ / ip dhcp-server lease find where mac-address=($RegVal->"mac-address") dynamic=yes status=bound ]->0); :if ([ :len $Lease ] > 0) do={ :set Address [ / ip dhcp-server lease get $Lease address ]; - :set HostName [ / ip dhcp-server lease get $Lease host-name ]; - :if ([ :len $HostName ] = 0) do={ - :set HostName "no hostname"; - } + :set HostName [ $EitherOr [ / ip dhcp-server lease get $Lease host-name ] "no hostname" ]; :set DnsName "no dns name"; :local DnsRec ([ / ip dns static find where address=$Address ]->0); :if ([ :len $DnsRec ] > 0) do={ diff --git a/collect-wireless-mac.template b/collect-wireless-mac.template index e8579f0..f190084 100644 --- a/collect-wireless-mac.template +++ b/collect-wireless-mac.template @@ -17,6 +17,7 @@ :global Identity; +:global EitherOr; :global GetMacVendor; :global LogPrintExit2; :global ScriptLock; @@ -52,10 +53,7 @@ $ScriptLock $0 false 10; :local Lease ([ / ip dhcp-server lease find where mac-address=($RegVal->"mac-address") dynamic=yes status=bound ]->0); :if ([ :len $Lease ] > 0) do={ :set Address [ / ip dhcp-server lease get $Lease address ]; - :set HostName [ / ip dhcp-server lease get $Lease host-name ]; - :if ([ :len $HostName ] = 0) do={ - :set HostName "no hostname"; - } + :set HostName [ $EitherOr [ / ip dhcp-server lease get $Lease host-name ] "no hostname" ]; :set DnsName "no dns name"; :local DnsRec ([ / ip dns static find where address=$Address ]->0); :if ([ :len $DnsRec ] > 0) do={ |