Router Identity Variable [SOLVED]

I would like to set up netwatch to email me when a device goes down every 30 minutes. I would like to include in the subject the router identity so I can easily determine which router is sending me the email. Can this be done?

Also, I would like netwatch to email me when the device is back up, but only once, and not every 30 minutes. Can this be done?

Thanks!

I use the system identity name for my voltage reports because I have a few that monitor solar power systems. This is what I use. Maybe it will help you.

       :local thisbox [/system identity get name]
       :local thisdate [/system clock get date]
       :local thishour
       :local emessage "Daily voltage report for $thisbox on $thisdate\n\n"

I’m not sure. Is there a constant variable for the system identity that I can just plug in? I see what you are doing.

Here is my little script:

/tool netwatch
add disabled=no down-script=“/tool e-mail send to=tony@xxx.com subject
="Host down!" body="The host is down!"” host=10.0.1.2
interval=30m timeout=5s up-script=“/tool e-mail send to=tony@xxx.co
m subject="Host up!" body="The host is up!"”

I want to add the system identity to the subject for identity purposes.

Thanks.

I did not try this with netwatch, but it works in other scripts.

/tool netwatch
add disabled=no down-script=":local thisBox [/system identity get name];/tool e-mail send to=tony@xxx.com subject\
=\"Host $thisBox down!\" body=\"The host $thisBox is down!\"" host=10.0.1.2 \
interval=30m timeout=5s up-script=":local thisBox [/system identity get name];/tool e-mail send to=tony@xxx.co\
m subject=\"Host $thisBox up!\" body=\"The host $thisBox is up!\""

Edit the order so it sends what you expect.

I tried the script, but it is giving me an expected end of line error and a few other errors. Maybe the syntax is incorrect? I’m so new to this, I’m not sure. If anyone can shed any light on this I would appreciate it. I bet it’s something really simple. Thanks.

Add this script.

/system script
add name=NetUp
edit NetUp source

:local thisBox [/system identity get name];
/tool e-mail send to=me@mydomain.com subject="$thisBox up" body="$thisBox up"

Add this script.

/system script
add name=NetDown
edit NetDown source

:local thisBox [/system identity get name];
/tool e-mail send to=me@mydomain.com subject="$thisBox down" body="$thisBox down"

Add this to /tool netwatch.

/tool netwatch
add host=1.2.3.4 interval=30m timeout=5s up-script=NetUp down-script=NetDown

It worked for me.

Thanks.

What I would like to do is monitor several ip devices, and add the router name in the email subject for all ip devices. I would like to accomplish this in as few steps as possible. Right now I would have to do your suggestion every time.

Is there a way to do it only once? Maybe store the variable and use it over and over?

I tried, but did not succeed. I could not find a way to set a global variable in “/tool netwatch”. :frowning:

I figured it out with some trial and error. Here is what I found works:

/tool netwatch
add comment=device-ip-monitor disabled=yes down-script=“/tool e-mail send to=to
ny@xxx.com subject=([/system identity get name] . " Device Down")
" host=10.0.1.3 interval=30m timeout=1s up-script=”/tool e-mail send to=to
ny@xxx.com subject=([/system identity get name] . " Device Up")"