Skip to content

Commit c7ba6b8

Browse files
committed
add description about required permissions and sudo
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
1 parent 807403b commit c7ba6b8

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ By default (`0.5`), the command detects log files that have not been collected u
168168
$ fluent-tailcheck --ratio 0.7 /var/log/td-agent/pos/secure
169169
```
170170

171+
### Permission
172+
173+
`fluent-tailcheck` requires read permission to the specified pos files and the target log files.
174+
175+
Please use `sudo` (on Linux-like) or a terminal with administrative privileges (on Windows).
176+
177+
```console
178+
$ sudo fluent-tailcheck /var/log/td-agent/pos/secure
179+
```
180+
171181
### Result example
172182

173183
#### No anomalies found

lib/fluent/tail_checker/collection_ratio_checker.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,18 @@ def get_file_size(pos_entry)
7373
end
7474

7575
def get_file_size_from_path(pos_entry)
76-
FileTest.size?(pos_entry.path)
76+
size = FileTest.size?(pos_entry.path)
77+
unless size
78+
$stderr.puts "Skip #{pos_entry.path} because it is not found. Make sure you have the proper privilege, e.g. 'sudo'."
79+
end
80+
size
7781
end
7882

7983
def get_file_size_from_inode(pos_entry)
80-
return nil unless FileTest.exist?(pos_entry.path)
84+
unless FileTest.exist?(pos_entry.path)
85+
$stderr.puts "Skip #{pos_entry.path} because it is not found. Make sure you have the proper privilege, e.g. 'sudo'."
86+
return nil
87+
end
8188

8289
stat = Fluent::FileWrapper.stat(pos_entry.path)
8390
# If follow_inodes is enabled, the inode of the current logfile should match the inode in the pos_file.

lib/fluent/tail_checker/tail_check.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def parse_command_line(argv)
4545
Example: fluent-tailcheck /path/to/pos/*
4646
Example: fluent-tailcheck --follow-inodes /path/to/pos_with_follow_inodes
4747
48+
Requires read permission to the specified pos files and the target log files.
49+
Example: sudo fluent-tailcheck /path/to/pos1
50+
4851
If you have any issues with this command, please report it to https://github.com/clear-code/fluent-tail_checker/issues.
4952
5053
Options:
@@ -73,7 +76,7 @@ def validate_paths(paths)
7376
Enumerator.new do |y|
7477
paths.each do |path|
7578
unless FileTest.exist?(path)
76-
$stderr.puts "File does not exist. Skipped. Path: #{path}"
79+
$stderr.puts "Skip #{path} because it is not found. Make sure you have the proper privilege, e.g. 'sudo'."
7780
next
7881
end
7982

@@ -117,7 +120,7 @@ def check
117120
def try_to_open_pos_file(path)
118121
PosFile.load(path)
119122
rescue => e
120-
$stderr.puts "Can not open the file. Skipped. Path: #{path}, Error: #{e}"
123+
$stderr.puts "Can not open the file. Skipped. Make sure you have the proper privilege, e.g. 'sudo'. Path: #{path}, Error: #{e}"
121124
end
122125
end
123126
end

0 commit comments

Comments
 (0)