هوتسبوت
فحص حد بيانات المستخدم المشترك - حسب حد كل مستخدم — 7
يقرأ حد البيانات الخاص بكل مستخدم (limit-bytes-total) ويفصل كل جلسات المستخدم النشطة عند وصول استهلاكه الكلي إليه. لا يحتاج تعديل - الحدود تؤخذ من إعدادات المستخدمين.
RouterOS 7
/system script add name=CheckSharedUsersUserLimit source={
# EN: Only users that have a data limit set | AR: فقط المستخدمون الذين لديهم حد بيانات
:foreach u in=[/ip hotspot user find where limit-bytes-total>0] do={
:local name [/ip hotspot user get $u name];
:local limit [/ip hotspot user get $u limit-bytes-total];
# EN: Total traffic of the user (all sessions) | AR: إجمالي استهلاك المستخدم (كل الجلسات)
:local used ([/ip hotspot user get $u bytes-in] + [/ip hotspot user get $u bytes-out]);
:if ($used >= $limit) do={
:local sessions [/ip hotspot active find where user=$name];
# EN: Log out every active session of this user | AR: فصل كل الجلسات النشطة لهذا المستخدم
:if ([:len $sessions] > 0) do={
/ip hotspot active remove $sessions;
:log info ("User $name reached the data limit and was logged out");
}
}
}
}