Hi. I want to write conditional statements together with my already written bandwidth control script.
Scenario : I have FTTH Internet with 1Mbps (Night Time Double Plan) which means that I will get 2Mbps at night (8:00 PM to 8:00 AM).
So my bandwidth will be -
1Mbps Download, 512Kbps Upload (Day Time)
2Mbps Download, 1Mbps Upload (Night Time)
I have already written 2 scripts, named, DayScript and NightScript and I already scheduled both of them.
DayScript
/queue tree enable PCQ-Download-Day;
/queue tree enable PCQ-Upload-Day;
/queue tree disable PCQ-Download-Night;
/queue tree disable PCQ-Upload-Night;
:local dDown "Client-Download-Day"
:local dUp "Client-Upload-Day"
:local nDown "Client-Download-Night"
:local nUp "Client-Upload-Night"
/ip firewall mangle enable [/ip firewall mangle find disabled=yes && comment=$dDown];
/ip firewall mangle enable [/ip firewall mangle find disabled=yes && comment=$dUp];
/ip firewall mangle disable [/ip firewall mangle find disabled=no && comment=$nDown];
/ip firewall mangle disable [/ip firewall mangle find disabled=no && comment=$nUp];
NightScript
/queue tree enable PCQ-Download-Night;
/queue tree enable PCQ-Upload-Night;
/queue tree disable PCQ-Download-Day;
/queue tree disable PCQ-Upload-Day;
:local dDown "Client-Download-Day"
:local dUp "Client-Upload-Day"
:local nDown "Client-Download-Night"
:local nUp "Client-Upload-Night"
/ip firewall mangle disable [/ip firewall mangle find disabled=no && comment=$dDown];
/ip firewall mangle disable [/ip firewall mangle find disabled=no && comment=$dUp];
/ip firewall mangle enable [/ip firewall mangle find disabled=yes && comment=$nDown];
/ip firewall mangle enable [/ip firewall mangle find disabled=yes && comment=$nUp];
Now, the problem is that, in my country, the electricity is not stable and sometime there will be power failures and because of that, when the power is out and then comes back, sometimes, my schedule doesn’t meet to execute the script automatically.
For example -
Power is failure at 5:00 AM Early Morning
Power comes back at 11:00 AM Afternoon
Because my schedule is set at 8:00 AM to execute the DayScript, and 8:00 PM to execute the NightScript, if the predefined scheduled time is passed when the electricity is comes back, the router doesn’t automatically change the bandwidth settings.
Pseudo Code :
- Check System Event Reboot (This reboot is need to check in looping in order to router to know when the electricity is come back)
- If clock greater than 8:00 AM (DayScript)
- If clock greater than 8:00 PM (NightScript)
Please help me and provide me with the code to use.
Thanks.