#------------START SETUP----------------
#---------------END SETUP----------------
#----------------------------------------
# verifica se lo scheduler esiste. Se non esiste, lo crea.
# il tempo di esecuzione è impostato nella variabile myRunTime.
#----------------------------------------
:if ([:len [/system scheduler find name="$scheduleName"]] = 0) do={
/log warning "[LogFilter] Alert : lo Scheduler non esiste. Creo lo scheduler"
# final output
:local output
:local myMac
:local myHost
:local ptr1
:local ptr2
:local myIP
:local counter 0
# loop through all log entries that have been found
:foreach i in=$startBuf do={
# LOG DATE
# depending on log date/time, the format may be different. 3 known formats
# format of jan/01/2002 00:00:00 which shows up at unknown date/time. Using as
default
:set currentTime [ /log get $i time ]
# format of 00:00:00 which shows up on current day's logs
:if ([:len $currentTime] = 8 ) do={
:set currentTime ([:pick [/system clock get date] 0 11]." ".$currentTime)
} else={
# format of jan/01 00:00:00 which shows up on previous day's logs
:if ([:len $currentTime] = 15 ) do={
:set currentTime ([:pick $currentTime 0 6]."/".[:pick [/system clock get
date] 7 11]." ".[:pick $currentTime 7 15])
}
}
:do {
:local requestUrl "https://api.telegram.org/bot$bot/sendMessage";
:local httpData "{\"chat_id\": \"$ChatID\", \"text\": \"$output\"}";
/tool fetch url=$requestUrl http-data=$httpData http-header-
field=content-type:application/json http-method=post keep-result=no
} on-error={
# log errori http post (disabilitato)
#:log info "finished with error";
}