#!rsc by RouterOS
# RouterOS script: netwatch-syslog
# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
# requires: dont-require-permissions=yes
#
# manage remote logging facilities
# https://git.eworm.de/cgit/routeros-scripts/about/doc/netwatch-syslog.md

:local Remote [ /system/logging/action/get ([ find where target=remote ]->0) remote ];

if ([ /tool/netwatch/get [ find where host=$Remote up-script="netwatch-syslog" down-script="netwatch-syslog" ] status ] = "up") do={
  /system/logging/set disabled=no [ find where action=remote disabled=yes ];
} else={
  /system/logging/set disabled=yes [ find where action=remote disabled=no ];
}