diff --git a/RouterOS_Count_Array_Items.rsc b/RouterOS_Count_Array_Items.rsc new file mode 100644 index 0000000..e69de29 diff --git a/RouterOS_Log_To_Alert.rsc b/RouterOS_Log_To_Alert.rsc index b7f6f44..bc535c0 100644 --- a/RouterOS_Log_To_Alert.rsc +++ b/RouterOS_Log_To_Alert.rsc @@ -1,38 +1,21 @@ -:global SendEmail do={ +:global LogToAlert do={ -:local smtpServer #smtp server IP -:local smtpPort #smtp port -:local from #sender email -:local to #recipeints email -:local cc #cc email -:local subject #email subject -:local body #email body -:log info "..::Sending email notification::.."; -tool e-mail send server=$smtpServer port=$smtpPort from=$from to=$to cc=$cc subject=$subject body=$body; + :local logMessage $message + :local logCount [/log print count-only where message~$logMessage] + :local logArray + + :put $logCount + + + :if ($logCount > 0) do={ + + :set $logArray [/log find where message~$logMessage] + :toarray value=$logArray + + :log print where .id=($logArray->0) + + } } - -#Here script starts - -:local message #message -:local systemName [/system identity get value-name=name] -:local recipient #recipient -:local logCount [/log print count-only where message~$message] -:local logArray [/log find where message~$message] - -:toarray value=$logArray - -:if (logCount > 0) do={ - - :log warning "..::Alert detected:.."; - $SendEmail smtpServer=#SMTPIP smtpPort=Port from=($systemName."domain") to=$recipient subject=($systemName." Triggered and Alert!") body=($logArray->1) - :log info ("..::Alert has been sent to ".$recipient) - -} - - - - - - +$LogToAlert message="winbox" \ No newline at end of file