Findlargedir-Go是一种快速的黑客攻击,旨在帮助识别任何文件系统中具有超过100,000个条目的任何文件系统的“黑洞”目录。计划将尝试确定任何此类事件并报告它们。
程序将不会遵循符号链接,并且需要R/W权限能够计算目录Inode大小与条目比率的数量,并估算目录中的许多条目,而无需实际对其进行计数。虽然此方法只是目录中实际条目数量的近似值,但它足够好,可以快速扫描犯罪目录。
-a )会导致过多的I/O和过多的内存使用;仅在适当时使用-7参数)-x参数),安装FindLargedir -go有两种方法: 安装FindLargedir-Go有两种方法:从版本页面下载您的首选风味并手动安装。
go get https://github.com/dkorunic/findlargedir-go用法:
Usage: findlargedir [-7ahopx] [-c value] [-t value] [parameters ...]
-7, --isilon enable support for EMC Isilon OneFS 7.x
-a, --accurate full accuracy when checking large directories
-c, --testcount=value
set initial file count for inode size testing phase (default
20000)
-h, --help display help
-o, --onefilesystem
never cross filesystem boundaries
-p, --progress display progress status every 5 minutes
-t, --threshold=value
set file count threshold for alerting (default 50000)
-x, --cloexec disable open O_CLOEXEC for really ancient Unix systems当使用准确的模式( -a参数)时,请注意大型目录查找将完全停止该过程的长时间。这种模式的作用基本上是在可能有罪的目录上计算精确数量的条目的次级完全准确的通过。
当不确定程序进度时,请随时发送Sigusr1或Sigusr2流程信号(在Windows上尝试 ^C)以查看最后的处理路径或使用Progress Flag( -p参数)以查看连续的5分钟状态更新。
如果要在EMC Isilon Onefs> = 7.1和<8.0(基于FreeBSD 7.4)上运行它,请确保使用-7参数添加isilon模式,否则程序将检测到无效的ST_SIZE并跳过所有文件系统。 Onefs 8.0+版本不需要使用-7参数。这仅适用于386和AMD64平台。
如果您具有非常古老的FreeBSD系统(<8.3)或诸如EMC Isilon Onefs(<7.2)和程序无法创建临时文件的导数,请尝试使用-x参数使用Cloexec模式。这仅适用于386和AMD64平台。
如果您想避免登录到已安装的文件系统(如FIND -XDEV选项中),请使用-o参数使用OneFileSystem模式。但是,这将在Windows上不起作用。
典型的用例以在几个文件系统上找到可能的罪犯:
root@box: ~ # findlargedir -c 10000 -t 50000 -a /var /home
2018/09/04 08:13:16 Note: program will attempt to alert on directories larger than 50000 entries by default.
2018/09/04 08:13:16 Determining inode to file count ratio on " /var " . Please wait, creating 10000 files...
2018/09/04 08:13:16 Done. Approximate directory inode size to file count ratio on " /var " is 26.2144.
2018/09/04 08:13:21 Found 0 large directories in " /var " .
2018/09/04 08:13:21 Determining inode to file count ratio on " /home " . Please wait, creating 10000 files...
2018/09/04 08:13:21 Done. Approximate directory inode size to file count ratio on " /home " is 27.0336.
2018/09/04 08:13:21 Directory " /home/user/torrent " is possibly a large directory with ~ 100k entries.
2018/09/04 08:13:21 Calculating " /home/user/torrent " directory exact entry count. Please wait...
2018/09/04 08:13:21 Done. Directory " /home/user/torrent " has exactly 99164 entries.
2018/09/04 08:13:21 Found 1 large directories in " /home " .