Community discussions

MikroTik App
 
User avatar
anav
Forum Guru
Forum Guru
Topic Author
Posts: 19125
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Adding to a working Email Netwatch Script.

Mon Mar 22, 2021 1:38 am

How do I add the following to an existing and working email script (it sends a telegram to my phone).
/ tool fetch "https://api.telegram.org/bot1111111111:t rAndomStrInGof lettersandnumbers/sendMessage?chat_id
=-222222222&text=Router $[/system identity get name] has detected the HP Printer Offline"
:log info "Telegram notification sent about HP Printer offline"
..........
If the email script that works to send me an email is as follows when the DEVICE (printer) status is changed to DOWN:
:local sub1 ([/system clock get time])
/tool e-mail send from="myemail@address.com.ca" body="At $sub1 HP Printer is Offline" subject="HP Printer is offline" to="myemail@address.com" 
:log info "CHECK HP printer stat!!"
...............
Is there some special syntax to join to separate functions??
This does not work........
:local sub1 ([/system clock get time])
/tool e-mail send from="myemail@address.com.ca" body="At $sub1 HP Printer is Offline" subject="HP Printer is offline" to="myemail@address.com" 
:log info "CHECK HP printer stat!!"
/ tool fetch "https://api.telegram.org/bot1111111111:t rAndomStrInGof lettersandnumbers/sendMessage?chat_id
=-222222222&text=Router $[/system identity get name] has detected the HP Printer Offline"
:log info "Telegram notification sent about HP Printer offline"
 
User avatar
anav
Forum Guru
Forum Guru
Topic Author
Posts: 19125
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Adding to a working Email Netwatch Script.  [SOLVED]

Mon Mar 22, 2021 11:18 pm

I finally got the Fetch script working the issue was a hidden return character or extra space that I had to remove.
Now my netwatch can fetch a script from systems scripts...........
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Adding to a working Email Netwatch Script.

Tue Mar 23, 2021 1:17 am

You may be interested in my script for some additional functionality:
Notify on host up and down
 
User avatar
anav
Forum Guru
Forum Guru
Topic Author
Posts: 19125
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Adding to a working Email Netwatch Script.

Tue Mar 23, 2021 2:25 am

wow thats very advanced for me LOL, an automated master script that runs and updates a bunch of others.........
I didnt understand your notification script so rather not use what I dont fathom.

What I would like is to know how to insert date/time or just time into my Fetch URL script.
This way isnt working very well with multiple scripts

It seems to work great in simple /tool email netwatch scripts.......
:local sub1 ([/system clock get time])
/tool e-mail send from="myemail@address.com" body="At $sub1 HP Printer is Offline" subject="HP Printer is offline" to="myemail@address.com"
:log info "CHECK HP printer stat!!"

But I get poor results when using it in /tool fetch scripts in system scripts, when the time is within an URL. I often get no entry where the time should be.

:local sub1 ([/system clock get time])
/tool fetch "https://api.telegram.org/bot<mykeycode> ... t=At_$sub1 RouterTest"

Who is online

Users browsing this forum: akira463, Google [Bot] and 32 guests