Community discussions

MikroTik App
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

run script and memory leak

Fri Jan 14, 2011 3:02 pm

I write a script and I observed memory leak
Would you check where is mistake
This script should double the transfer between 24:00 and 12:00. I have a ppp users that login and SQ is take from radius. I must check SQ every few minutes because my users login on difference time on the day.


/system scheduler
add comment="" disabled=no interval=10m name=Check on-event=

:global Time [/system clock get time ]; :if ([$Time] < 12:00:00) do={/system script run Night} else={/system script run Day}

/system script
add name=Day policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=
/queue simple
set [find limit-at=\"128k/512k\"] comment=\"\" max-limit=128k/512k

add name=Night policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=
/queue simple
:if ([:len [ find comment=""]] = 0) do={:put no-512} else={set [find limit-at="128k/512k"] comment="Night-512" max-limit=128k/1024k}
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 3:25 pm

I think this will run better:
/system scheduler
add comment="" disabled=no interval=10m name=Check on-event=DayNight
The put all the code in the DayNight script, using if-else based on the current time.

ADD: You can't use the ":put" command using the scheduler. It only works from the CLI command line.
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak

Fri Jan 14, 2011 4:02 pm

may there is a problem that I'm using :put
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 4:10 pm

The ":put" and using "/system script run" in the scheduler are possible problems.
If you want to check the output, use ":log info no-512" instead of ":put", then check the log.
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak

Fri Jan 14, 2011 4:29 pm

What do you think about it.
I put all my script to scheduler and remove :put
I don't need log info about no-512k if it was to help with memory leak.

:local Time [/system clock get time ]
:if ([$Time] < 12:00:00) do=
{
/queue simple
set [find limit-at="128k/512k"] comment="" max-limit=128k/512k
}
else=
{
/queue simple
:if ([:len [ find comment=""]] = 0) do={} else={set [find limit-at="128k/512k"] comment="Night-512" max-limit=128k/1024k}
}
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 5:01 pm

I think what you want is more like this. It checks the "max-limit" value only for values that are the incorrect setting for that time of day, then change all occurrences of that rate to the correct rates. I have not run it to see if it does what you want. Before noon the values will be 128K/512K and after noon will be 256K/1M.
:local Time [/system clock get time ]
:local lineno ""

:if ([$Time] < 12:00:00) do={
    :set lineno [/queue simple find max-limit=256K/1M]

    :foreach i in=$lineno do={
        /queue simple set i limit-at=128K/512K max-limit=128K/512K
    }
} else={
    :set lineno [/queue simple find max-limit=128K/256K]

    :foreach i in=$lineno do={
        /queue simple set i limit-at=256K/1M max-limit=256K/1M
    }
}
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak

Fri Jan 14, 2011 5:22 pm

I have users with wifi card witch connect to pppoe server. From 24:00 to 12:00 user should have double transfer. When one user log in on 10:00 he login with transfer 512k/128k (radius) and I must check every few minutes if someone have 512k/128k and change transfer to 256k/1024k.
Script could theoretically be carried out only between the hours of 24:00 and 12:00.
Maybe the solution to my problem is to set the scheduler to run between 24:00 and 12:00 only.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 5:28 pm

The code I posted above can be run as often as you like. If it is morning, it will change any afternoon settings to the morning settings. If it is afternoon, it changes any morning settings to afternoon settings. If the settings are correct, it changes nothing.
 
sadoank
just joined
Posts: 20
Joined: Sun Nov 28, 2010 7:45 am

Re: run script and memory leak

Fri Jan 14, 2011 5:37 pm

what the main issues of this case? if TS want to make changes to limit bandwidth? during the daytime users get 128k/512k limits and limits at night will turn into 128k/1024k?

#add day/night
/queue simple add name=”Day” target-addresses=192.168.1.0/24 dst-address=0.0.0.0/0 interface=ether2 parent=none direction=both priority=8 queue=default-small/default-small limit-at=128/512k max-limit=128k/512k total-queue=default-small

/queue simple add name=”Night” target-addresses=192.168.1.0/24 dst-address=0.0.0.0/0 interface=ether2 parent=none direction=both priority=8 queue=default-small/default-small limit-at=128k/1024k max-limit=128k/1024k total-queue=default-small

#script
/sys script add name=”Day” source={/queue simple enable Day; /queue simple disable Night}
/sys script add name=”Night” source={/queue simple enable Night; /queue simple disable Day}

#schedule
/system scheduler add name=”Day” on-event=Day start-date=dec/8/2010 start-time=06:00:00 interval=1d
/system scheduler add name=”Night” on-event=Night start-date=dec/8/2010 start-time=18:00:00 interval=1d

you just need to change the limit, time, date, and also the IP.
My IP LAN will not run if it is used by you. to the LAN IP, change with pppoe server IP, so all you users that use pppoe server will be limited.

try it... and tell me how it work.
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak

Fri Jan 14, 2011 9:13 pm

I have dynamic simple queue it is create when client log in. I use freeradius (Mikrotik-Rate-Limit = "128k/512k"). I can't give name=”Day” or ”Night”. I can't forget the customers who log on during the night hours.

I try a solution that SurferTim post
I try to find the bug because it does not work for me.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 10:43 pm

The bug is the case of the 'K' in limit-at and max-limit. It needs to be lower case, like '256k/1M', not '256K/1M'. Insure to change all occurrences, even the find statements.
It worked for me.
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak

Fri Jan 14, 2011 11:03 pm

Thenks

success
:local Time [/system clock get time ]
:local lineno ""

:if ([$Time] < 12:00:00) do={
    :set lineno [/queue simple find max-limit="128k/512k"]

    :foreach i in=$lineno do={
        /queue simple set $i limit-at="128k/512k" max-limit="128k/1024k"
    }
} else={
    :set lineno [/queue simple find limit-at="128k/512k"]

    :foreach i in=$lineno do={
        /queue simple set $i max-limit="128k/512k"
    }
}
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: run script and memory leak

Fri Jan 14, 2011 11:17 pm

I know what you meant, but it has a small bug. This is about what I used. Low speed before noon. Higher speed after noon. Change values of both limit-at and max-limit, but you only need to find one (max-limit in my example). And be consistent about the parameter you find. Don't find max-limit before noon, then find limit-at after noon.
:local Time [/system clock get time]
:local lineno ""

:if ([$Time] < 12:00:00) do={
    :set lineno [/queue simple find max-limit="128k/1024k"]

    :foreach i in=$lineno do={
        /queue simple set $i limit-at="128k/512k" max-limit="128k/512k"
    }
} else={
    :set lineno [/queue simple find max-limit="128k/512k"]

    :foreach i in=$lineno do={
        /queue simple set $i limit-at="128K/1024k" max-limit="128k/1024k"
    }
}
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: run script and memory leak

Wed Jan 26, 2011 9:41 am

on the other hand - you could try to use time setting in queues and manage speed increase just by adding duplicate queues with different times and allowed speed.
 
marekm
Member
Member
Posts: 391
Joined: Tue Feb 01, 2011 11:27 pm

Re: run script and memory leak

Fri Jun 08, 2012 10:16 am

I can confirm a memory leak in a simple command:

/queue simple disable [/queue simple find ]

Background: RB1100AH, ROS v5.16 running as PPPoE server with dynamic simple queues set up by FreeRADIUS Mikrotik-Rate-Limit attribute, currently a little over 200 customers connected. I'm recently testing "unlimited" bandwidth at night, the above command is run every minute between 0:00 and 8:00 (to catch any new connections during that time - would have been better to run a script triggered by new PPPoE interface up, but I don't know how to do that), then at 8:00 the "disable all queues every minute" scheduled task is disabled and all queues are re-enabled again for the day. Looking at memory usage graphs, it increased by about 400 MiB in a week, and only rises during the night hours when the disable command runs every minute. It can also be reproduced by just running the command several times from the command line, alternated with "/system resource print". I've found a simple workaround - use

/queue simple disable [/queue simple find disabled=no ]

so that only enabled queues are disabled, this removes the leak or at least reduces it to manageable level (it won't exhaust the whole 1.5GB of RAM in a few weeks). I still think there is a bug - disabling an already disabled queue should simply do nothing, not eat memory.
 
ManyX
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Sat Jan 07, 2006 12:48 pm
Location: PolanD

Re: run script and memory leak - Simple Queue switching

Tue Jun 26, 2012 11:00 pm

I worked it out from memory leak. write the script which check memory status and, if necessary, reset the system.

In all versions I install memory is leak

I suspect that the reason is switching simple queue limit
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 29 guests