-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathRouterOS_File_Logging.rsc
More file actions
41 lines (28 loc) · 935 Bytes
/
RouterOS_File_Logging.rsc
File metadata and controls
41 lines (28 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Version 1.0
# Last update: 2/8/2020
# 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;