No need to use ping in script.
What you do is to use netwatch.
There you can have a script for up/down information.
Script name: Netwatch
####################################
# Netwatch script
#
# Used as both up and down script
# Created Jotne 2021 v1.5
#
####################################
:local Host $host
/tool netwatch
:local Status [get [find where host="$Host"] status]
:local Comment [get [find where host="$Host"] comment]
:local Interval [get [find where host="$Host"] interval]
:local Since [get [find where host="$Host"] since]
:log info "script=netwatch watch_host=$Host comment=\"$Comment\" status=$Status interval=$Interval since=\"$Since\""
Then add an IP to monitor like this:
/tool netwatch
add down-script=Netwatch host=8.8.8.8 up-script=Netwatch
See more information here:
viewtopic.php?p=888800#p888800