Community discussions

MikroTik App
 
gwinton
just joined
Topic Author
Posts: 16
Joined: Fri Apr 29, 2005 8:38 am

Active Devices that are on CapsMan

Sat Feb 13, 2021 10:16 pm

I am trying to write a script to produce a report for devices that are using the WiFi.
This is the script that I have 2 scripts
The first is to get the data and then the second script will make the file and email it. The email part works. It is the first script that does not.

Script Name: Get-Data-Devices
# Print Devices from registrations in CSV format. Allows quick import into Excel
{
# print header
:local message "\"Interface\",\"SSID\",\"Mac-Address\",\"Host Name\",\"UpTime\",\"RX-Signal\",\"RX-Rate\""
:put $message
# print each registered device
:foreach n in=[/caps-man registration-table find] do={
:local interface [/caps-man registration-table get $n interface]
:local ssid [/caps-man registration-table get $n ssid]
:local macaddress [/caps-man registration-table get $n mac-address]
:local uptime [/caps-man registration-table get $n uptime]
:local rxsignal [/caps-man registration-table get $n rx-signal]
:local rxrate [/caps-man registration-table get $n rx-rate]
:local name [/ip dhcp-server lease get [find active-mac-address=$macaddress] value-name=host-name]
:local message "\"$interface\",\"$ssid\",\"$macaddress\",\"$name\",\"$uptime\",\"$rxsignal\",\"$rxrate\""
:put $message
}
}

Script Name: Execute get data, Produce file and email.
# Save the output of the netwatches-to-csv script to a txt file and email
:global strDate [/system clock get date]
:global strTime [/system clock get time]
:global strName [/system identity get name]
:local a [/system script get registrations-to-csv source]
:local outFile "devices-to-csv.csv"
execute script=$a file=$outFile
/tool e-mail send to=gwinton@grwtx.com body="$strName Device Connections for $strDate" subject="$strName Device Connections for $strDate $strTime" file=$outFile
log info message="Device Connection Logs sent"
}


It works when the devices are on 1 SSID.. If I have multiple SSID then the script produces no such item.

Is there is a script guru that can help on this.

Thanks

Who is online

Users browsing this forum: Ahrefs [Bot] and 17 guests