Community discussions

MikroTik App
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Send one email and stop

Thu Jan 21, 2021 9:07 pm

I have this script running every 30 seconds with scheduler. I repeatedly receive an email every 30 seconds. Can I ensure that I only receive one email if the router is too hot?
Otherwise I will be spammed with the same error.
Please advise
:log info ("$[/system health get temperature]")
:if ([/system health get temperature]>10) do={/tool e-mail send to="youremail@gmail.com" subject=[/system identity get name] body=("High temperature. Current temperature is: ".[/system health get temperature])} 
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Send one email and stop

Thu Jan 21, 2021 11:12 pm

Well, as for PSU state... You could use my script for this as well.
Notify about health state

Still you need the base installation, follow main README for this.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Send one email and stop

Thu Jan 21, 2021 11:17 pm

BTW, this also can send notification to via Telegram. I have messages about temperature alert and recovery in my history, looks like this:
Screenshot_2021-01-21_22-12-50.png
You do not have the required permissions to view the files attached to this post.
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 2:02 am

Sorry but this does not help me.
I know there is a way to send an email once with the same error.
But I lost the code. This was given to me by Rextended.
 
User avatar
che
Member Candidate
Member Candidate
Posts: 111
Joined: Fri Oct 07, 2005 1:04 pm

Re: Send one email and stop

Fri Jan 22, 2021 2:57 am

Hi Plisken, I hope this idea will be helpful for you:
:global temperaturePrevious
:local temperatureCurrent [/system health get temperature]

:log info ("$temperatureCurrent")
:if (($temperatureCurrent>10) and ($temperaturePrevious<=10)) do {
    /tool e-mail send to="youremail@gmail.com" subject=[/system identity get name] body=("High temperature. Current temperature is: ".$temperatureCurrent)
}

:set temperaturePrevious $temperatureCurrent
Before starting above script you will need startup script (schedule it to run at router startup) that builds the $temperaturePrevious variable. Create the script and run it once manually for the first time if you are adding it to the live system instead of rebooting the router:
:global temperaturePrevious [/system health get temperature]
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 7:58 am

Hello Che, thanks for your reply

If I understand correctly.
Once I have started that script, will the monitoring continue without a scheduler?
This once I start the script manually? Is that correct?
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 10:09 am

I do not understand why you do not test or even consider using my scripts.
What's wrong there?
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 10:23 am

There is nothing wrong with your scripts but I don't understand them.
I have little experience with scripts.
This is not your fault. I would like to know the background how this works.
I appreciate your help.
 
User avatar
che
Member Candidate
Member Candidate
Posts: 111
Joined: Fri Oct 07, 2005 1:04 pm

Re: Send one email and stop

Fri Jan 22, 2021 12:21 pm

Hi Plisken, you have to schedule the main script to run in intervals you like and set the temperature numbers to match your needs, and global variable one to be scheduled to run at startup. You can manually run main script as many times as you like, but first you have to run once the "startup" script so everything is correct.

Eworm, I apologise if you have already written the solution somewhere on your website, I rarely open external links on public forums. I didn't mean to disrespect anyone. :)
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 1:19 pm

Hello Che, many thanks for this explanation.
@Eworm thanks for your answer too.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 1:22 pm

Eworm, I apologise if you have already written the solution somewhere on your website, I rarely open external links on public forums. I didn't mean to disrespect anyone. :)
I have a collection of script, one of them does what plisken wants - and a lot more. But it is complex and depends on other scripts. If you want something that just works - use my scripts.
Looks like plisken wants a simple script he can maintain himself. That's fine and I am glad you teach him.

(Still there's not a lot of knowledge required to use my scripts. Everything is documented and you just have to follow the instructions in README. So everybody is invited to try it.)
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Send one email and stop

Fri Jan 22, 2021 1:28 pm

Hello Eworm, when I find the time I will dig deeper into your scripts.
I am interested in these scripts and want to understand them.
Thanks
 
User avatar
panisk0
newbie
Posts: 25
Joined: Sun Mar 06, 2016 10:36 pm
Location: Cracow
Contact:

Re: Send one email and stop

Tue Mar 09, 2021 9:05 pm

make 2 if conditions

:local condition
:global informed

:if (($informed="YES") && ($condition>$example)) do={
:set informed YES
} else {
:set informed NO
}

Who is online

Users browsing this forum: No registered users and 22 guests