lsoflog(8)
π lsoflog(8) β the ClusterTools2 era π
okay so bestie, this one's a lil script from the ClusterTools2 family, and it's literally just here to keep receipts on what files are open. let's get into it π«Ά
β¨ NAME β¨
lsoflog β logs the open file list, with a timestamp glued on top, no cap ππ
πΈ SYNOPSIS πΈ
lsoflog [ logfile [ pathlist [ timeout ]]]
three optional lil args, all stacked in brackets like russian dolls π
π¦ DESCRIPTION π¦
so lsoflog logs the open file list with a timestamp. basically what the script does is slam the output of date +%F %T onto the front of every single line coming out of lsof -n -P -X -w -S42 +fg +x +D.... iconic behavior honestly π
the default pathlist is "+D/opt +D/srv". and ngl, giving it a proper pathlist is the whole vibe check here β it keeps the logfile reasonably small π a non-existing directory will make lsoflog fail, so likeβ¦ watch out π
also heads up: lsof consumes a noticeable amount of CPU cycles π so it should only be activated when needed. don't just leave it running for the aesthetic.
default timeout is 42 seconds β±οΈ (yes, the number. it's giving hitchhiker's guide, we love it)
π EXAMPLES π
π running it every 10 minutes
to run lsoflog every 10 minutes, the crontab entry could look like this:
-02-57/10 * * * * root /usr/sbin/lsoflog /var/log/lsof.log
"+D/db2/data"
π§ rotating + compressing the log
to rotate and compress the log from time to time, the logrotate entry could look like this:
/var/log/lsof.log {
compress
dateext
maxage 365
rotate 99
size +20M
notifempty
missingok
copytruncate
}
π₯ finding non-O_DIRECT IO
to find all IO to /ora/data that was not done with O_DIRECT, just do:
awk '$11~/\/ora\/data/ && $8 !~/DIR/ {print $1,$2,$3,$8,$11}'
/var/log/lsof.log | sort -u
β finding ASYNC IO
to see which processes have done ASYNC IO to /ora/data, just do:
awk '$11~/\/ora\/data/ && $8 ~/AIO/ {print $1,$2,$3,$8,$11}'
/var/log/lsof.log | sort -u
π EXIT STATUS π
0β successful program execution π slay>0β usage, syntax or execution errors π¬ something went sideways
π FILES π
/usr/sbin/lsoflogβ the script itself π«Ά/var/log/lsof.logβ the default logfile π/etc/cron.d/ClusterTools2β the cron entry β°/etc/logrotate.d/ClusterTools2β the logrotate entry π
π BUGS π
non-existing directories cause lsoflog to fail. that's the bug. it's real. plan accordingly bestie π
feedback is welcome, please mail to feedback@suse.com π (they literally want to hear from you, fr fr)
π SEE ALSO π
lsof(1), crontab(5), logrotate(8), open(2), fcntl(2), ClusterTools2(7)
πΈ COPYRIGHT πΈ
(c) 2011-2019 L.Pinne, Germany.
lsoflog comes with ABSOLUTELY NO WARRANTY π«£ β like, none, zero, don't come for them.
for details see the GNU General Public License at http://www.gnu.org/licenses/gpl.html π
ok that's the whole page, every flag, path, number and awk one-liner intact β the vibe is mine, the facts are theirs π
and that's the tea π this was lsoflog(8) from ClusterTools2, dated 01 Nov 2019 β mwah, go log responsibly β¨π
π¦ where this page comes from
- opensuse-leap 16.0: ClusterTools2 3.1.3-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms