lsoflog(8)

πŸ“¦ version 3.1.3, in opensuse-leap 16.0

πŸ’… 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)


(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