Community discussions

MikroTik App
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

since in netwatch

Sat Mar 06, 2021 3:02 am

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..."}
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: since in netwatch

Sat Mar 06, 2021 5:59 am

value-name=since
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Sat Mar 06, 2021 6:16 am

value-name=since
hi sir where can i put that
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: since in netwatch

Sat Mar 06, 2021 10:51 am

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..."
}
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Sat Mar 06, 2021 12:05 pm

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
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: since in netwatch

Sat Mar 06, 2021 12:20 pm

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.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Sat Mar 06, 2021 2:16 pm

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
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: since in netwatch

Sat Mar 06, 2021 3:54 pm

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.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Sat Mar 06, 2021 4:20 pm

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]
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: since in netwatch

Sat Mar 06, 2021 4:43 pm

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.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Wed Mar 10, 2021 10:49 am

i mean i want to get the time and date in tools netwatch "since" and i want to include here in my script
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: since in netwatch

Wed Mar 10, 2021 3:55 pm

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.
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: since in netwatch

Wed Mar 10, 2021 6:15 pm

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.
Last edited by 2frogs on Thu Mar 11, 2021 11:50 pm, edited 1 time in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch

Thu Mar 11, 2021 4:09 pm

thnak you sir but its not working sir

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.
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: since in netwatch

Thu Mar 11, 2021 11:52 pm

I missed the closing ]. I have updated, please try again.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: since in netwatch  [SOLVED]

Fri Mar 12, 2021 12:59 am

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

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

Who is online

Users browsing this forum: mvz71 and 23 guests