since in netwatch

how do i get the since in netwatch. pls help me

:do {/ppp secret
:foreach ix in=[find service=any] do={
:local sNAME [get $ix name]
:local since [/tool netw find comment=MAIN CONNECTION get $ix since]
:do {
:log warning message=(“user: " . $sNAME . " send text informing MAINCONN is UP”)
:do {/tool sms send phone-number=0910135441 message=“telco as of $since has been restored”}

:log warning message=(“The user: " . $sNAME . " sucessfully sent the sms”)
} on-error={:log info message=(“The user: " . $sNAME . " sucessfully sent the sms”)}
}
} on-error={:log error message=“script failed…”}

value-name=since

hi sir where can i put that

What are you trying to do, what is the goal?
Do you need client uptime?


Also use better formatting (tab etc) and code tags when posing code. </> button above the post.
Do not quote the whole post above your. Reply using Post Reply under the post.

You are also overuse the on-error. It will not fail on a command like :log warning message=(…

Here is a sample on code tag post.

:do {
	/ppp secret
	:foreach ix in=[find service=any] do={
		:local sNAME [get $ix name]
		:local since [/tool netw find comment=MAIN CONNECTION get $ix since]
		:do {
			:log warning message=("user: " . $sNAME . " send text informing MAINCONN is UP")
			:do {
				/tool sms send phone-number=0910135441 message="telco as of $since has been restored"
			}
			:log warning message=("The user: " . $sNAME . " sucessfully sent the sms")
		} on-error={'
			:log info message=("The user: " . $sNAME . " sucessfully sent the sms")}
	}
} on-error={
	:log error message="script failed..."
}

thank you sir.
i’d like to input the date and time of the since in /tool netwatch to send it to via text of my subs

You did not reply to what the goal is. Time since what?
Can you not use the uptime in ppp active?
And what is your configuration of netwatch?
Some manual setup stuff, or some scripted thing.

the goal is to know the subscriber when the net is up or down

like for example
do {/tool sms send phone-number=$pnumber message=" pls be inform that our connection as of $since has been restored"}
which is $since is coming from the tool netwatch since which indicated as date and time.

sorry for my bad english

As long as you do use ppp its either for L2TP ipsec or PPoE or other, you will see the users up-time with the command:

/ppp active print.

What I do not understand is why you try to use netwatch.
No need to look at /ppp secret. Only if you like to get a list of all users online or not.

You can also look at my Splunk for Mikrotik (link in signature)
There you get a graphic view of all type of information. VPN/PPPoE ++++
Even if there are some missing, I can create a view for it.

no sir. this is my script. the problem in this script is not works the command $since
i want to know my subscriber via text when the internet is down or up again thru $since

:do {
	/ppp secret
	:foreach ix in=[find service=pppoe] do={
		:local sNAME [get $ix name]
		:local sPnumber [get $ix phone-number]
		:local since [/tool netw find comment=MAIN CONNECTION get $ix since] <<<<------not running
		:do {
			:log warning message=("user: " . $sNAME . " send text informing MAINCONN is UP")
			:do {
				/tool sms send phone-number=$sPnumber message="pls inform that our internet service as of $since has been restored"
			}
			:log warning message=("The user: " . $sNAME . " sucessfully sent the sms")
		} on-error={'
			:log info message=("The user: " . $sNAME . " sucessfully sent the sms")}
	}
} on-error={
	:log error message="script failed..."
}

[/quote]

So you like a sms when connection to pppoe client goes down and when it comes up?
No need to look at line or ip, just look at /ppp active and see when pppoe is up or down, then send email while status changes.

i mean i want to get the time and date in tools netwatch “since” and i want to include here in my script

To use netwatch, you have to set it up. I do not see what you get there that you can not get from /ppp active?
Its time and there there when a client connects.

Try:

:local since [/tool netw get [find where comment=MAIN CONNECTION] since]

My apologies for my other reply, I was pulled away before I could complete my thought and didn’t realize I had submitted it.

thnak you sir but its not working sir


I missed the closing ]. I have updated, please try again.

:local since [/tool netw get [find where comment=MAIN CONNECTION] since]

thank you very much sir for your help. its working now