mirror of
https://github.com/gbudny93/RouterOS_Useful_Scripts.git
synced 2025-06-26 19:58:41 +02:00
Update.
This commit is contained in:
parent
e2280aad84
commit
8e7ce73c99
2 changed files with 77 additions and 4 deletions
39
RouterOS_File_Logging.rsc
Normal file
39
RouterOS_File_Logging.rsc
Normal file
|
@ -0,0 +1,39 @@
|
|||
# RouterOS Function
|
||||
# Copyright (c) Grzegorz Budny
|
||||
# Adds log entry if file is removed or added
|
||||
|
||||
:global FileToLog do={
|
||||
|
||||
:local fileName "FilesCount.txt";
|
||||
:local fileCountOld;
|
||||
:local fileCountCurrent;
|
||||
|
||||
:if ([:len [/file find name=$fileName]] <= 0) do={
|
||||
|
||||
/file print file=$fileName;
|
||||
:delay 5;
|
||||
/file set $fileName contents=[/file print count-only];
|
||||
|
||||
}\
|
||||
else={
|
||||
|
||||
:set $fileCountOld [/file get $fileName contents];
|
||||
:set $fileCountCurrent [/file print count-only];
|
||||
|
||||
:if ($fileCountCurrent > $fileCountOld) do={
|
||||
|
||||
:log warning "File has been added";
|
||||
/file set $fileName contents=$fileCountCurrent;
|
||||
|
||||
}
|
||||
:if ($fileCountCurrent < $fileCountOld) do={
|
||||
|
||||
:log warning "File has been removed";
|
||||
/file set $fileName contents=$fileCountCurrent;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$FileToLog;
|
Loading…
Add table
Add a link
Reference in a new issue