Wed Jul 20, 2016 3:11 pm
GTJ, I hope that you don't mind if I add some findings/logs.
I have tried to work with some other part of MT functionality to see is this a problem only with /interfaces and
created similar script to work with firewall rules and results from this trial are introducing new questions from my side.
I am also using Mikrotik API Studio by Rodolfo Rughi to verify executed commands.
When there is no time wait between commands result is always "disabled":"false"
ACTION:
sleep.sleep(1);
console.log('I am here 1');
actionChannel.write(['/ip/firewall/filter/set','=disabled=yes','=.id=*D']);
// sleep.usleep(1000000); //Sleep disabled
console.log('I am here 2');
actionChannel.write(['/ip/firewall/filter/set','=disabled=no','=.id=*D']);
RESULT:
root@ub64:~# node test5-listen-mt.js
I am here 1
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"true","dynamic":"false","disabled":"false","comment":"test"}]
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"false","dynamic":"false","disabled":"false","comment":"test"}]
When I introduce small delay of 0,21 sec ( i have tried 0,5 sec also) 3 changes are registered although in MT log only 2 of them are shown.
ACTION:
sleep.sleep(1);
console.log('I am here 1');
actionChannel.write(['/ip/firewall/filter/set','=disabled=yes','=.id=*D']);
sleep.usleep(210000); //Sleep for 0,21 sec
console.log('I am here 2');
actionChannel.write(['/ip/firewall/filter/set','=disabled=no','=.id=*D']);
RESULT:
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"true","dynamic":"false","disabled":"true","comment":"test"}]
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"true","dynamic":"false","disabled":"false","comment":"test"}]
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"false","dynamic":"false","disabled":"false","comment":"test"}]
When pause between commands is 1 second all seem OK.
ACTION:
sleep.sleep(1);
console.log('I am here 1');
actionChannel.write(['/ip/firewall/filter/set','=disabled=yes','=.id=*D']);
sleep.usleep(1000000); //Sleep for 1 sec
console.log('I am here 2');
actionChannel.write(['/ip/firewall/filter/set','=disabled=no','=.id=*D']);
RESULT:
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"true","dynamic":"false","disabled":"true","comment":"test"}]
Interface change: [{".id":"*D",".nextid":"*FFFFFFFF","chain":"forward","action":"accept","log":"false","log-prefix":"","invalid":"false","dynamic":"false","disabled":"false","comment":"test"}]
LOG from MT router showing 2 commands executed in each iteration:
13:41:31 system,info,account user admin logged in from 192.168.0.200 via api
13:41:32 system,info filter rule changed by admin
13:41:32 system,info filter rule changed by admin
13:41:32 system,info,account user admin logged out from 192.168.0.200 via api
13:43:29 system,info,account user admin logged in from 192.168.0.200 via api
13:43:30 system,info filter rule changed by admin
13:43:30 system,info filter rule changed by admin
13:43:30 system,info,account user admin logged out from 192.168.0.200 via api
13:43:52 system,info,account user admin logged in from 192.168.0.200 via api
13:43:53 system,info filter rule changed by admin
13:43:53 system,info filter rule changed by admin
13:43:53 system,info,account user admin logged out from 192.168.0.200 via api
13:45:16 system,info,account user admin logged in from 192.168.0.200 via api
13:45:17 system,info filter rule changed by admin
13:45:18 system,info filter rule changed by admin
13:45:18 system,info,account user admin logged out from 192.168.0.200 via api
13:46:11 system,info,account user admin logged in from 192.168.0.200 via api
13:46:12 system,info filter rule changed by admin
13:46:13 system,info filter rule changed by admin
13:46:13 system,info,account user admin logged out from 192.168.0.200 via api