I'm batting around .500 (my usual), which in baseball is fantastic, but in programming, not so much....
Here's my down script:
/system
:local cdate [clock get date]
:local yyyy [:pick $cdate 0 4]
:local MM [:pick $cdate 5 7]
:local dd [:pick $cdate 8 10]
:local identitydate "$[identity get name]_$yyyy-$MM-$dd"
:local identity "$[identity get name]"
/tool netwatch
:local Host $host
:local Status [get [find where host="$Host"] status]
:local Interval [get [find where host="$Host"] interval]
:log info "script=netwatch watch_host=$Host comment=\"$Comment\" status=$Status interval=$Interval"
:tool e-mail send to=joseph@xxxx.com subject="$identity $Status" body=( "$Status $Host $identitydate" )
:global globalstoreddown "$identitydate_Down_$Status"
Here's my up script:
/system
:local cdate [clock get date]
:local yyyy [:pick $cdate 0 4]
:local MM [:pick $cdate 5 7]
:local dd [:pick $cdate 8 10]
:local identitydate "$[identity get name]_$yyyy-$MM-$dd"
:local identity "$[identity get name]"
/tool netwatch
:local Host $host
:local Status [get [find where host="$Host"] status]
:local Interval [get [find where host="$Host"] interval]
:log info "script=netwatch watch_host=$Host comment=\"$Comment\" status=$Status interval=$Interval"
:if ([:len [$globalstoreddown]] > 1) do={
:tool e-mail send to=joseph@xxxx.com subject="$identity Previously Netwatch Down" body=( "$globalstoreddown" )
}
:tool e-mail send to=joseph@xxxx.com subject="$identity $Status" body=( "$Status $Host $identitydate" )
I confirmed that globalstoreddown gets created by the down script with
:log info $globalstoreddown
But the up script does not send the email in the line:
:if([:len [$globalstoreddown] > 1)
Also, the idea was that an email would be send that includes not just the date but the time it went down (and the time it went up).
Thanks!