Page 1 of 1

netwatch: how to create up_action and down_action email scri

Posted: Tue Aug 28, 2007 12:03 am
by donv
Hello,

I am trying to monitor a group of hosts on a hotspot network.

I have created netwatch rules successfully to monitor the hosts.
such as this:
0 ;;; workstation 1
192.168.120.1 5m 1m up

I am trying to figure out how to create a single up_action and a single down_action script that will run if any monitored machine goes down. I dont understand how to pass the ip address to the script. I am monitoring like 100 machines and dont want to create a unique up action and down action for each machine.

my current script is:

0 name="workstation_down" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,password run-count=0
source=/tool e-mail send from="mikrotik@xyzcustomer.com"
server="67.55.143.33" body="TEST BY DON - workstation is Down"
subject="TEST BY DON - workstaiton is down at xyzcustomer"
to="xyztest@rdi1.com"

I need to change this script so that I can feed the IPaddress of the up or down machine to the up_action or down_action script.

I read a ton of stuff and cant figure out how to do this.

Can anyone tell me how to pipe the IP address of the netwatch machine that called this script into the body of the email message?

Thanks in advance!

-d

Re: netwatch: how to create up_action and down_action email scri

Posted: Tue Aug 28, 2007 4:32 pm
by janisk
in netwatch
you can use global variable and set the value you want
and run script that will use that variable

like
:global myGlobal globalVaue
{:global myGlobal
:put $myGlobal}

Re: netwatch: how to create up_action and down_action email scri

Posted: Wed Oct 24, 2007 6:58 pm
by andreasj8
All about GLOBAL Variabale is clear, but it do not work.
I have same problem (task).
CAN U HELP ME ?

in netwatch actions (tabs UP & DONW) for ip 10.0.0.12 i have only one word, with out any ; {} etc ... and this work. - that word is name of my script placed into /system scripts

for UP name of "/system script " : sendAlertNetWatchUP
for DOWN name of "/system script " : sendAlertNetWatchDOWN
all scripts above like this (different only subject and body for UP and DOWN actions) :
- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -
/tool e-mail send server=10.0.0.1 to="trouble@bla-bla.net" from="mt-router@bla-blab.net" subject="$gg1 SWITCH UP" body="SOME HOST UP"
- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -

Now i want pass ip 10.0.0.12 into both of these scripts.
HOW i must do it ?

i try for UP :
{:global gg1 "10.0.0.12" }; sendAlertNetWatchUP;
and then try
{:global gg1 "10.0.0.12"; sendAlertNetWatchUP;}

result was SAME - NOTHING happens.

Do u have real help with it ?

Re: netwatch: how to create up_action and down_action email scri

Posted: Thu Oct 25, 2007 9:31 am
by mrz
Only script code or only script name is supported. You can't mix them both.

Use:
:global gg1 "10.0.0.12";
/system script run sendAlertNetWatchUP;

Re: netwatch: how to create up_action and down_action email scri

Posted: Sat Jan 05, 2008 3:34 am
by butche
Do u have real help with it ?
While I haven't done the whole script, you can gather the IP address using something like this:
:set hostip [/tool netwatch get [find status=up ] host] ; :environment print
That works on 2.9.x, but not sure on 3.x (I think it will work there, too).