{"id":286,"date":"2021-10-27T12:41:11","date_gmt":"2021-10-27T12:41:11","guid":{"rendered":"https:\/\/sznetwork.systems\/?p=286"},"modified":"2025-05-19T11:40:05","modified_gmt":"2025-05-19T09:40:05","slug":"mikrotik-ping-script-to-check-host-online-or-offline","status":"publish","type":"post","link":"https:\/\/sznetwork.systems\/?p=286","title":{"rendered":"Mikrotik ping script to check host online or offline (Migrated)"},"content":{"rendered":"\n<p>This small script for Mikrotik will check is host\/hosts online or offline and sends messages to email if host is down.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Comment in log that script starts\n:log info (\"Script started\");\n# Define how many ping attempts try to do\n:local pingcount 3;\n# List of IP addresses to check\n:local host1 192.168.88.3;\n# Function that check first host in list\n:log info (\"host 1 CHECK\");\n\n:local pingresult1 [\/ping $host1 count=$pingcount];\n\n:if (pingresult1 > 0) do={:log info (\"$pingresult1 of $pingcount PING Requests PASS\");\n:log info (\"$host1 ONLINE\");} \\\n\nelse={ \/tool e-mail send \\\n\n      to=your@email.com \\\n\n      subject=\"$pingresult1 of $pingcount PING Requests PASS Can't ping $host1\";\\\n\n:log info (\"$host1 OFFLINE\");\n    }\n\n:delay 1;\n\n:log info (\"Delay 1 sec\");<\/pre>\n\n\n\n<p>hosts can be more than one, simply add :local host2, copy function in bottom and change $host1 to host2<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Mikrotik script to check host availability and send email in host offline\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/Won0s8oHZAA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This small script for Mikrotik will check is host\/hosts online or offline and sends messages to email if host is down. # Comment in log that script starts :log info. <a class=\"read-more-link\" href=\"https:\/\/sznetwork.systems\/?p=286\">read more&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[37],"tags":[33,35,31,34,32],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-mikrotik","tag-email","tag-how-to","tag-mikrotik","tag-monitoring","tag-script"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":3,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":1890,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/1890"}],"wp:attachment":[{"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sznetwork.systems\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}