Netwatch tool, that monitors the status of a network or a link. At a certain point in time, this tool perform ping to a predefined network or a link. If for some reason this tool does not receive ping response from that link or network, it sends a notification in the form of email or SMS to the system admin or user. Whenever there is a change in the status of the link, a notification will be sent. Netwatch tool sends this notification with the help of some scripts. Whenever there is a change in the status of the link, the script related to that status will be started.
We will discuss the whole matter with the help of an example.
For example, we will monitor our gateway link. The IP of our gateway is 8.8.8.8. Whenever our gateway link will go down, we will get a notification in the form of SMS. In the same way, when the link will go up, the notification will come in the form of SMS.
To do this we will create two different scripts. One script will work if the link goes down and the other will work if the link goes up. And this link status will be checked by the "netwatch" tool.
The script for link down is: -
tool sms send message="link down" phone-number=your_mobile_number channel=your_channel_number port=Your_port
For example:-
tool sms send message="link down" phone-number=123456 channel=3 port=usb3
The script for link up is: -
tool sms send message="link up" phone-number=your_mobile_number channel=your_channel_number port=Your_port
For example:-
tool sms send message="link up" phone-number=123456 channel=3 port=usb3
In the same way, we can configure netwatch to send email notification. In that case, the script will be as follows:-
The script for link down is: -
tool e-mail send from="your_Email_Address" server=Your_imap_server user=your_user password=your_password subject="your_notification_message" to="recepient_address"
For example:-
tool e-mail send from="script@gmail.com" server=imap.gmail.com user=user_name password=your_password subject="link down" to="12345678"
The script for link up is: -
tool e-mail send from="your_Email_Address" server=Your_imap_server user=your_user password=your_password subject="your_notification_message" to="recepient_address"
For example:-
tool e-mail send from="script@gmail.com" server=imap.gmail.com user=user_name password=your_password subject="link up" to="12345678"
Below, the whole process is shown graphically: -
Connect your mikrotik via winbox. Then go to "Netwatch" from "Tools".
Screenshot for down script:-
No comments:
Post a Comment