This program counts files under a list of given target directories. User gets control over what system calls to use. Basic mode of operation uses only readdir(3) (getdents(2)), so that filesystem gets less load (than using lstat(2)s).
With -mode={dump_dentry|dump_stat}
, it can be used as a low-level alternative of
find(1):
dump_dentry
shows the information carried by dentries (file name, type, inode number), relying ongetdents(2)
, to spare the filesystem from stat'ing. (Nb. on Linuxfind
does stats if-type
option is used, so it does not export readdir-based type information.)dump_stat
dumps full stat info as JSON.
The other focus of the utility is monitoring, ie. it repeatedly counts files / dumps filenames and can also produce a json feed of the result with timing information.
Tested/expected to work on Linux x64.
You need Go for the build.
Tested with Go 1.16.
cd fico
go build
This might be the workable procedure for other Go versions if the "with module" instructions don't work.
mkdir _
ln -s .. _/src
GO111MODULE=off GOPATH=$PWD/_ go install fico
(binary will be in _/bin
).
$ fico -h
FAST CONCURRENT TUNABLE fiLE coUNTER
fico [options] [targets...] [-- message]
options:
-debug
debug mode
-dump0
on dump_dentry, separate entries by zero byte
-dumpfullpath
on dumping, do not strip off path to target
-filter string
glob pattern to exclude (matching done relatively from targets, matching dirs are not entered)
-filterfiles
apply 'filter' to file counting, too
-flimit int
run 'till this number of files is reached (≤0 means no limit)
-fuzzy
tolerate fs fuzzines (errors due to ongoing changes)
-hili int
interval to show highlighted scan result (default 20)
-hint int
directory branchiness hint (hint on avg. no. of entires in dirs) (default 256)
-logappend
append to previously existing logfile
-logcont
continue logging with relative time of earlier logs (implies logappend)
-logf string
log file
-mode string
counting / dump_dentry / dump_stat (default "counting")
-scan int
interval to scan by (default 10)
-stat
salvage missing dirent type by falling back to lstat
-turns int
number of iterations (≤0 means infinite) (default 1)
-workers int
number of workers (default 5)