I’m a beginner of RouterOS
I would like to set up a lan monitoring tool that send me the log daily.
Email is already configured.
Using netwatch i want log only if a host is down.
But how can i write a specific log only dedicated to netwatch and send it only daily by email ?
How can i “reset” the file after successful sending it ?
what do you want to have in log?
create new “action” and “rule” in system logging (save to file)
make schedule to send this file and delete after sending
I don’t understand how to use “action” and “rule” of logging system to obtain a file only dedicated to netwatch message.
I don’t understand how to log only netwatch log because script can write only on 4 topics.. “debug, error, info and warning”.. so, how can i create a rule to filter only netwatch message ?
try smth like this:
create new action in logging (type - disk, file count 1, file name - any name you want)
create new rule (topics: script, warning action: your new action, prefix - any you want )
in netwach in down action add command (or add to the script what you run on "down"event this line: /log warning “PC is down at $[/system clock get time]” )
after that add to the scheduler script to send e-mail with file (file will have name you had written in “action” + .0.txt)
to send file you can use smth like:
/tool e-mail send to=yourmail@gmail.com subject=“Netwach lof file” file=“netwachlog.0.txt”
to clear log file after sending just delete file
/file remove netwachlog.0.txt
also you can add logging for “up” event
I’m a beginner of RouterOs and after many research i found that from script i have to save any messages about topics we select (es. warning or info or..) and after (download, email..) filter it to select the messages that interest us.
In my mind, working on linux system, i would like to create a log file dedicated to each action that i want log, but in routerOs isn’t possible.
Now i’m in the hell of those who study a new system xD
Some other question:
I haven’t found how to check a filesize of a file.. or how to check if the mail was really sent without error.
In case of lack of connection, error on authentication etc.. a simple script (example i’ve found on internet, also in this forum) will not send the email and after delete in any case the log file. That’s terribly wrong in my mind.
i can’t help with checking send email (i didn’t have to setup this). in my cases i usually setup logging to remote servers and for critical systems have telegram alerts
This setup work if the device is supposed to be constantly connected. If the connection stops, the message to syslog server are lost.
On server i use both, local log and remote syslog server. If the connection fail, after i can recover the local log on request or wait until the automatic send of the log by mail.
I think you use the same approach.
in my case log from netwatch comes to remote syslog server, so all the information about connection state is on it. and as i had said - the state of critical services comes also by telegram bot
I have something simmilar already configured.
Logs are saved to _GoogleDNS.txt untill it’s full then it is renamed to have a timestamp and a new clear file is created. You could change it to what you need.