Hello everyone,
I am currently trying to monitor the signal strength of wireless devices on MikroTik in real time and output the records into a text file or table (CSV format). My approach is to use a script to periodically collect information from the wireless registry (including signal strength, TX/RX rate, etc.), and then append the data to the log file. But I found that when the log file size reaches about 4082B, the log record stops updating and no new data is appended.
The current question is: How to monitor the signal strength of wireless devices in real time and output the records stably into a text or table file?
The following is the script content:
:local fileName "wifi_signal_log.csv";
:local currentTime [/system clock get time];
:local currentDate [/system clock get date];
:local logEntry "";
:if ([:len [/file find name=$fileName]] > 0) do={
/file print file=$fileName;
/file set $fileName contents="Date,Time,MAC Address,Signal Strength (dBm),Uptime\r\n";
}
:local existingContent [/file get $fileName contents];
MAC TX RX
:foreach i in=[/interface wireless registration-table find] do={
:local MacAddress [/interface wireless registration-table get $i mac-address];
:local SignalStrength [/interface wireless registration-table get $i signal-strength];
:local Uptime [/interface wireless registration-table get $i uptime];
CSV
:set logEntry ($currentDate . "," . $currentTime . "," . $MacAddress . "," . $SignalStrength . "," . $Uptime . "\r\n");
:local existingContent [/file get $fileName contents];
/file set $fileName contents=($existingContent . $logEntry);
}
