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 " .