Community discussions

MikroTik App
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

ROS 6.49.6 Script log messages not showing

Tue Jun 07, 2022 8:14 pm

Hello,

I downgraded from ROS 7.2.1 to ROS 6.49.6 and I noticed the log messages from my Dynu DDNS are not showing in the log. But the funny thing is the script still works... Is there a bug in the ROS 6.49.6 with the log messages?

Here is the script I am using:
:global ddnsuser "your_Dynu_username"
:global ddnspass "your_Dynu_password"
:global theinterface "WAN_Interface_Name"
:global ddnshost "your_Dynu_hostname"
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("DynuDDNS: No IP address on $theinterface .")
} else={
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i];
}
}
:if ($ipddns != $ipfresh) do={
:log info ("DynuDDNS: IP-Dynu = $ipddns")
:log info ("DynuDDNS: IP-Fresh = $ipfresh")
:log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "DynuDDNS: IP updated to $ipfresh!"
} else={
:log info "DynuDDNS: dont need changes";
} } 
Last edited by nickba on Tue Jun 07, 2022 11:25 pm, edited 1 time in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Tue Jun 07, 2022 10:14 pm

I have not tested the script, but cleaned ut up:
Removed not needed ; at end of some lines.
Added TAB to make it easier to read.
Change global to local variable. If you do not need to store the variable for later use or use it in other script, use local
Removed " at end of script. It may break stuff
:local ddnsuser "your_Dynu_username"
:local ddnspass "your_Dynu_password"
:local theinterface "WAN_Interface_Name"
:local ddnshost "your_Dynu_hostname"
:local ipddns [:resolve $ddnshost]
:local ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
	:log info ("DynuDDNS: No IP address on $theinterface .")
} else={
	:for i from=( [:len $ipfresh] - 1) to=0 do={
		:if ( [:pick $ipfresh $i] = "/") do={
			:set ipfresh [:pick $ipfresh 0 $i]
		}
	}
	:if ($ipddns != $ipfresh) do={
		:log info ("DynuDDNS: IP-Dynu = $ipddns")
		:log info ("DynuDDNS: IP-Fresh = $ipfresh")
		:log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
		:local str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
		/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
		:delay 1
		:local str [/file find name="Dynu.$ddnshost"]
		/file remove $str
		:local ipddns $ipfresh
		:log info "DynuDDNS: IP updated to $ipfresh!"
	} else={
		:log info "DynuDDNS: dont need changes"
	}
}
PS if dynu dns support point to a DNS name instead of IP, use MikroTik Cloud service and get an <router_serial>.sn.mynetname.net name

Edit:
Tested on 6.49.1 and this command fails with red message while cut and past.
:if ([ :typeof $ipfresh ] = nil ) do={
Try to change to
:if ([:len $ipfresh ] = 0 ) do={
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Tue Jun 07, 2022 11:39 pm

Hello,

Thanks for replying. There is no " at the end, my bad!! I just edited my first post to reflect that.

Tried your script and same problem! No log messages! I tried to add a test log message at the end of the script:
:log info "Test log message"
I it does not show!!

If I put the message at the beginning of the script(first line) it shows! But it only show this message. Like I said, I used script on ROS7 and it was showing the log messages. Do you think it is a bug on ROS 6.49.6?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 12:00 am

Not tested directly, but cleaned and simplified on some points:
:local ddnsuser     "your_Dynu_username"
:local ddnspass     "your_Dynu_password"
:local theinterface "WAN_Interface_Name"
:local ddnshost     "your_Dynu_hostname"

:log info "Test if DNS exist, if not, the script stop with error"
:local ipddns       [:resolve $ddnshost]
:log info "Test passed"

/ip address
:local ipfresh   [find where interface=$theinterface]
:if ([:len $ipfresh] = 0) do={
    :log info "DynuDDNS: No IP address on $theinterface"
} else={
    :set ipfresh [get $ipfresh address]
    :set ipfresh [:pick $ipfresh 0 [:find $ipfresh "/" -1]]
}

:if ($ipddns != $ipfresh) do={
    :log info "DynuDDNS: IP-Dynu = $ipddns"
    :log info "DynuDDNS: IP-Fresh = $ipfresh"
    :log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
    /tool fetch user=$ddnsuser password=$ddnspass keep-result=no \
        url="http://api.dynu.com/nic/update\3Fhostname=$ddnshost&myip=$ipfresh"
    :delay 1s
    :log info "DynuDDNS: IP updated to $ipfresh!"
} else={
    :log info "DynuDDNS: dont need changes"
}
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 12:26 am

Add all your lines between { } and change all :log info to :put
The cut and past script to terminal to se what is going on.
You will then get output in the terminal window instead in the logs.


Some times I do add :put "1" :put "2" etc inn between lines to see what the path the script takes.
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 3:10 am

Hello everyone,

Thanks for replying.
I tested the rextended suggested script, it works too, but only the messages:
"Test if DNS exist, if not, the script stop with error" and "Test passed" shows in the log. So as my previous test, only the messages before the scripts commands are logged! This is really weird!

Like I said, the first script I posted and the one posted by Jotne and rextended are all working fine and the DDNS is updating, but the log messages are not showing in the log in ROS 6.49.6. It is really seems to be a bug or something broke when I downgraded from ROS 7.

I tried to replace the :log info to :put and put all the script between {} and paste to the terminal, but I got all sort of errors! Maybe it is the encoding when I am pasting...

Any other suggestions?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 8:40 am

Then you have changed some log settings. I do get logs while running the script on 6.49.1
05:38:20 script,info Test if DNS exist, if not, the script stop with error
05:38:20 script,info Test passed
05:38:26 script,info DynuDDNS: dont need changes
05:38:41 script,info Test if DNS exist, if not, the script stop with error
This is the default log setting seen using command /system logging export verbose
/system logging action
set 0 memory-lines=1000 memory-stop-on-full=no name=memory target=memory
set 1 disk-file-count=2 disk-file-name=log disk-lines-per-file=1000 disk-stop-on-full=no name=disk target=disk
set 2 name=echo remember=yes target=echo
set 3 bsd-syslog=no name=remote remote=0.0.0.0 remote-port=514 src-address=0.0.0.0 syslog-facility=daemon \
    syslog-severity=auto syslog-time-format=bsd-syslog target=remote
/system logging
set 0 action=memory disabled=no prefix="" topics=info
set 1 action=memory disabled=no prefix="" topics=error
set 2 action=memory disabled=no prefix="" topics=warning
set 3 action=echo disabled=no prefix="" topics=critical
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 10:37 am

Ok, for debug something.... extreme....
{
:local cnt 1
:log info $cnt; :set cnt ($cnt + 1)
:local ddnsuser     "your_Dynu_username"
:log info $cnt; :set cnt ($cnt + 1)
:local ddnspass     "your_Dynu_password"
:log info $cnt; :set cnt ($cnt + 1)
:local theinterface "WAN_Interface_Name"
:log info $cnt; :set cnt ($cnt + 1)
:local ddnshost     "your_Dynu_hostname"
:log info $cnt; :set cnt ($cnt + 1)

:log info $cnt; :set cnt ($cnt + 1)
:log info "Test if DNS exist, if not, the script stop with error"
:log info $cnt; :set cnt ($cnt + 1)
:local ipddns       [:resolve $ddnshost]
:log info $cnt; :set cnt ($cnt + 1)
:log info "Test passed"
:log info $cnt; :set cnt ($cnt + 1)

:log info $cnt; :set cnt ($cnt + 1)
/ip address
:log info $cnt; :set cnt ($cnt + 1)
:local ipfresh   [find where interface=$theinterface]
:log info $cnt; :set cnt ($cnt + 1)
:if ([:len $ipfresh] = 0) do={
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: No IP address on $theinterface"
:log info $cnt; :set cnt ($cnt + 1)
} else={
:log info $cnt; :set cnt ($cnt + 1)
    :set ipfresh [get $ipfresh address]
:log info $cnt; :set cnt ($cnt + 1)
    :set ipfresh [:pick $ipfresh 0 [:find $ipfresh "/" -1]]
:log info $cnt; :set cnt ($cnt + 1)
}
:log info $cnt; :set cnt ($cnt + 1)

:log info $cnt; :set cnt ($cnt + 1)
:if ($ipddns != $ipfresh) do={
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: IP-Dynu = $ipddns"
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: IP-Fresh = $ipfresh"
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:log info $cnt; :set cnt ($cnt + 1)
    /tool fetch user=$ddnsuser password=$ddnspass keep-result=no \
        url="http://api.dynu.com/nic/update\3Fhostname=$ddnshost&myip=$ipfresh"
:log info $cnt; :set cnt ($cnt + 1)
    :delay 1s
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: IP updated to $ipfresh!"
:log info $cnt; :set cnt ($cnt + 1)
} else={
:log info $cnt; :set cnt ($cnt + 1)
    :log info "DynuDDNS: dont need changes"
:log info $cnt; :set cnt ($cnt + 1)
}
:log info $cnt; :set cnt ($cnt + 1)
}
Read when on the log stops the number, and you find the line...
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 1:35 pm

Problem is that OP does not see anything in the log :)

Buts a smart log ide rextended:
:log info $cnt; :set cnt ($cnt + 1)
But if this hits loop and hops, it will not match line number so can be some hard to track back to where it stopped.
I tried to replace the :log info to :put and put all the script between {} and paste to the terminal, but I got all sort of errors! Maybe it is the encoding when I am pasting...
It does work fin on my router.

Try cut/past this (not change anything);
{
:local ddnsuser     "your_Dynu_username"
:local ddnspass     "your_Dynu_password"
:local theinterface "ether1"
:local ddnshost     "www.google.com"

:put "Test if DNS exist, if not, the script stop with error"
:local ipddns       [:resolve $ddnshost]
:put "Test passed"

/ip address
:local ipfresh   [find where interface=$theinterface]
:if ([:len $ipfresh] = 0) do={
    :put "DynuDDNS: No IP address on $theinterface"
} else={
    :set ipfresh [get $ipfresh address]
    :set ipfresh [:pick $ipfresh 0 [:find $ipfresh "/" -1]]
}

:if ($ipddns != $ipfresh) do={
    :put "DynuDDNS: IP-Dynu = $ipddns"
    :put "DynuDDNS: IP-Fresh = $ipfresh"
    :put "DynuDDNS: Update IP needed, Sending UPDATE...!"
    /tool fetch user=$ddnsuser password=$ddnspass keep-result=no \
        url="http://api.dynu.com/nic/update\3Fhostname=$ddnshost&myip=$ipfresh"
    :delay 1s
    :put "DynuDDNS: IP updated to $ipfresh!"
} else={
    :put "DynuDDNS: dont need changes"
}
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 3:22 pm

Buts a smart log ide rextended:
:log info $cnt; :set cnt ($cnt + 1)
But if this hits loop and hops, it will not match line number so can be some hard to track back to where it stopped.
Yes, but is a quick just because loop are not presents and already on if and else some other log happen... ;)
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 7:16 pm

Hello,

Thanks again for replying. I am not home now to test, but just to make sure I understood. The command to show my default log settings is this one?
/system logging export verbose/system logging action 
And, like I said, if I put the commands to write messages to the log in the first lines of the scrip, these ones are shown in the log, but the commands to write messages to the log within the script does not show. This is the weird part.

And do you guys have the version 6.49.6 to test?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 8:40 pm

As I posted above:
 /system logging export verbose
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 9:41 pm

As I posted above:
 /system logging export verbose
Hi,

Here is the result of the command:
/system logging action
set 0 memory-lines=1000 memory-stop-on-full=no name=memory target=memory
set 1 disk-file-count=2 disk-file-name=log disk-lines-per-file=1000 disk-stop-on-full=no name=disk target=disk
set 2 name=echo remember=yes target=echo
set 3 bsd-syslog=no name=remote remote=0.0.0.0 remote-port=514 src-address=0.0.0.0 syslog-facility=daemon \
    syslog-severity=auto syslog-time-format=bsd-syslog target=remote
/system logging
set 0 action=memory disabled=no prefix="" topics=info
set 1 action=memory disabled=no prefix="" topics=error
set 2 action=memory disabled=no prefix="" topics=warning
set 3 action=echo disabled=no prefix="" topics=critical
So the settings seems to be ok.

Any other suggestions? Maybe someone with version 6.49.6 to test?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 9:46 pm

Are exactly the default settings.
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Wed Jun 08, 2022 11:04 pm

Are exactly the default settings.
Exactly... I sent a support request to Mikrotik. Meanwhile, any other suggestions are welcome.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ROS 6.49.6 Script log messages not showing

Thu Jun 09, 2022 7:08 am

Test it on another router with default config. If you do not have another router to test on, download and install EVE NG and make a virtual router there. It 100% free.
 
nickba
just joined
Topic Author
Posts: 18
Joined: Sat Jun 04, 2022 10:27 pm

Re: ROS 6.49.6 Script log messages not showing

Thu Jun 09, 2022 10:55 pm

Hi,

I just found what is causing the log messages to not show in the log. It is the VPN connection. I configured the router with NordVPN as shown in the first post of this link:
viewtopic.php?t=169273

If I disable the NordVPN peer in the IP > IPSec > Peers, the log messages from Script works. So any suggestions?

Who is online

Users browsing this forum: ko00000000001 and 22 guests