mikesart / inotify-info Goto Github PK
View Code? Open in Web Editor NEWLinux inotify info reporting app
License: MIT License
Linux inotify info reporting app
License: MIT License
Hi,
When running make
I get failures. I've also tried compiling the code against the Developer Toolset 7..10.
When using g++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
# make
Using gold linker...
Building _release/inotify-info...
---- inotify-info.cpp ----
g++: error: unrecognized command line option ‘-Wimplicit-fallthrough=2’
make: *** [_release/inotify-info.o] Error 1
When using Developer Toolset 9 - g++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Using gold linker...
Building _release/inotify-info...
---- inotify-info.cpp ----
inotify-info.cpp:342:67: error: return type ‘struct statx’ is incomplete
342 | struct statx mystatx( const char *filename, unsigned int mask = 0 )
| ^
inotify-info.cpp: In function ‘void mystatx(const char*, unsigned int)’:
inotify-info.cpp:344:18: error: aggregate ‘statx statxbuf’ has incomplete type and cannot be defined
344 | struct statx statxbuf;
| ^~~~~~~~
inotify-info.cpp:345:57: error: ‘AT_STATX_DONT_SYNC’ was not declared in this scope
345 | int flags = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC;
| ^~~~~~~~~~~~~~~~~~
inotify-info.cpp:347:53: error: invalid use of incomplete type ‘struct statx’
347 | if ( statx( 0, filename, flags, mask, &statxbuf ) == -1 )
| ^
inotify-info.cpp:342:8: note: forward declaration of ‘struct statx’
342 | struct statx mystatx( const char *filename, unsigned int mask = 0 )
| ^~~~~
inotify-info.cpp: In member function ‘void thread_info_t::add_filename(ino64_t, const char*, const char*, bool)’:
inotify-info.cpp:365:22: error: variable ‘statx statxbuf’ has initializer but incomplete type
365 | struct statx statxbuf = mystatx( filename.c_str() );
| ^~~~~~~~
inotify-info.cpp: In function ‘uint32_t find_files_in_inode_set(const std::vector<procinfo_t>&, std::vector<filename_info_t>&)’:
inotify-info.cpp:672:53: error: ‘STATX_INO’ was not declared in this scope; did you mean ‘STA_INS’?
672 | thread_info.add_filename( mystatx( "/", STATX_INO ).stx_ino, "/", "", false );
| ^~~~~~~~~
| STA_INS
make: *** [Makefile:107: _release/inotify-info.o] Error 1
It compiled successfully on Rocky 8.
gdb shows
Reading symbols from ./_release/inotify-info...
(gdb) run
Starting program: /tmp/inotify-info/_release/inotify-info
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
------------------------------------------------------------------------------
INotify Limits:
max_queued_events 16384
max_user_instances 524288
max_user_watches 524288
------------------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
_IO_fgets (buf=buf@entry=0x7fffffffde10 "Uid:\t0\t0\t0\t0\n", n=n@entry=256, fp=fp@entry=0x0) at ./libio/iofgets.c:47
47 ./libio/iofgets.c: No such file or directory.
enviroments:
Hi, I installed the AUR package and wanted to play wih this interesting tool on my (fully updated) Arch Linux box. Sadly I'm seeing the below errors and wanted to ask if I need to change something to get it working as expected.
I took out the color codes from the output for readibility here. Seeing the same output when using appname
or PID
flag. Adding -vv
doesn't give more details, neither does a debug build, so I'm a bit at a loss as to what might be going wrong. Any advice would be very welcome!
$ gcc --version
gcc (GCC) 12.2.1 20230111
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ inotify-info geany
------------------------------------------------------------------------------
INotify Limits:
max_queued_events 16384
max_user_instances 1024
max_user_watches 100000
------------------------------------------------------------------------------
Pid App Watches Instances
1067 systemd 52 3
1341 gsd-xsettings 23 1
1757 thunar 21 1
1222 gnome-session-binary 6 2
1743 gnome-pie 5 1
1756 python2.7 4 2
1089 dbus-daemon 3 1
3678 journalctl 3 1
1509 pulseaudio 2 2
6632 tumblerd 1 1
6389 xfce4-terminal 1 1
4775 geany 1 1
3755 inotifywait 1 1
3735 inotifywait 1 1
1815 inotifywait 1 1
1809 inotifywait 1 1
1444 devilspie2 1 1
1333 gsd-color 1 1
1245 gvfs-udisks2-volume-monitor 1 1
1076 nss-tlsd 1 1
------------------------------------------------------------------------------
Total inotify Watches: 130
Total inotify Instances: 25
------------------------------------------------------------------------------
Searching '/' for listed inodes... (2 threads)
ERROR: sys_getdents64 failed on '/proc/555/net/': -1 errno:22
ERROR: sys_getdents64 failed on '/proc/1227/map_files/': -1 errno:13
ERROR: sys_getdents64 failed on '/proc/3031/map_files/': -1 errno:13
ERROR: sys_getdents64 failed on '/proc/3127/map_files/': -1 errno:13
ERROR: sys_getdents64 failed on '/proc/3353/map_files/': -1 errno:13
ERROR: sys_getdents64 failed on '/proc/3407/map_files/': -1 errno:13
[hangs here until Ctrl-C]
(note: that it was about flatpaks was only revealed later on)
Running without arguments is fine
OS: Fedora release 37 (Thirty Seven) x86_64
Host: Framework FRANBMCP0B
Kernel: 6.1.11-200.fc37.x86_64
Uptime: 7 hours, 10 mins
Packages: 3424 (dnf), 12 (nix-user), 43 (nix-default), 79 (flatpak)
Shell: fish 3.6.0
Hello
im getting this error quite randomly:
❯ ./_debug/inotify-info
------------------------------------------------------------------------------
INotify Limits:
max_queued_events 16384
max_user_instances 512
max_user_watches 524288
------------------------------------------------------------------------------
AddressSanitizer:DEADLYSIGNAL
=================================================================
==221236==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f0029e7fa74 bp 0x7ffe7df0c910 sp 0x7ffe7df0c070 T0)
==221236==The signal is caused by a READ memory access.
==221236==Hint: address points to the zero page.
#0 0x7f0029e7fa74 in _IO_fgets libio/iofgets.c:47
#1 0x7f002a9d860d in __interceptor_fgets ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1324
#2 0x562f56d8916c in get_uid(char const*) (/home/su/workspace_kantor/inotify-info/_debug/inotify-info+0x13b16c) (BuildId: c7d4437f0a723a7a984f9bcb109b16f5db24ac2c)
#3 0x562f56d8da6c in init_inotify_proclist(std::__debug::vector<procinfo_t, std::allocator<procinfo_t> >&) (/home/su/workspace_kantor/inotify-info/_debug/inotify-info+0x13fa6c) (BuildId: c7d4437f0a723a7a984f9bcb109b16f5db24ac2c)
#4 0x562f56d937b6 in main (/home/su/workspace_kantor/inotify-info/_debug/inotify-info+0x1457b6) (BuildId: c7d4437f0a723a7a984f9bcb109b16f5db24ac2c)
#5 0x7f0029e2aa8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#6 0x7f0029e2ab48 in __libc_start_main_impl ../csu/libc-start.c:360
#7 0x562f56d88474 in _start (/home/su/workspace_kantor/inotify-info/_debug/inotify-info+0x13a474) (BuildId: c7d4437f0a723a7a984f9bcb109b16f5db24ac2c)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV libio/iofgets.c:47 in _IO_fgets
==221236==ABORTING
When I first ran this as 'inotify-info splunkd' to see what splunk was watching, it was taking over four hours before I just killed it.
I then found out it was crawling down my automount mount points and my maps have over 1000 entries. Not sure if there is a way to make it avoid crawling down automount mounts that are not mounted yet.
For my purposes I am only interested in finding watches on the local, non-data filesystems so I modified parse_dirqueue_entry() at the beginning to avoid my paths used for automounting and large local data volumes with lines like
char *pch;
pch = strstr(path, "/autofs");
if (pch == path)
{
return -1;
}
pch = strstr(path, "/local_mount");
if (pch == path)
{
return -1;
}
pch = strstr(path, "/data");
if (pch == path)
{
return -1;
}
There are alignment issues in the Watches
and Instances
columns. It's hard to tell why they sometimes seem aligned on one boundary and elsewhere on another, but I am guessing there are some tabulator boundaries messing up the formatting most of the time.
There is also the issue of the App
column not being constrained in any way, overflowing into/pushing the content of the Watches
column, like on on the lines containing (deleted)
.
------------------------------------------------------------------------------
INotify Limits:
max_queued_events 16384
max_user_instances 128
max_user_watches 524288
------------------------------------------------------------------------------
Pid App Watches Instances
2886516 fsnotifier 24742 1
110678 fsnotifier 24740 1
291730 node 313 1
1474 systemd (deleted) 130 4
1508545 gsd-xsettings 78 1
1509036 xdg-desktop-portal-gtk 77 1
1508426 gvfsd-trash 47 1
1508606 snap-store 23 1
2358356 nautilus 18 1
1508327 gnome-shell (deleted) 15 1
1508721 tracker-miner-fs-3 11 1
1508427 thunar 9 1
3113125 chrome (deleted) 9 1
1508303 gnome-session-binary 8 2
125323 gnome-terminal-server 7 1
1508495 evolution-alarm-notify (deleted) 7 1
113058 code 6 2
1508118 dbus-daemon (deleted) 4 1
110362 java 4 1
113422 code 4 1
1508906 gjs-console (deleted) 4 1
113332 code 4 1
3113196 chrome (deleted) 3 1
111650 jcef_helper 3 1
113109 code 3 1
113392 code 3 1
1509341 seahorse 2 1
2116577 flameshot 2 2
1508356 evolution-source-registry (deleted) 2 1
1508529 gsd-sound 2 1
1513 pulseaudio 2 2
3007946 gedit 2 1
1509017 xdg-desktop-portal 1 1
1508381 goa-identity-service 1 1
1508704 evolution-addressbook-factory (deleted) 1 1
1508483 gsd-housekeeping 1 1
1508472 gsd-color 1 1
1508397 evolution-calendar-factory (deleted) 1 1
1508389 gvfs-afc-volume-monitor 1 1
1508370 gvfs-udisks2-volume-monitor 1 1
1508365 goa-daemon 1 1
1508271 dbus-daemon (deleted) 1 1
513523 node 1 1
113331 code 1 1
1511 pipewire-media-session 1 1
------------------------------------------------------------------------------
Total inotify Watches: 50297
Total inotify Instances: 52
------------------------------------------------------------------------------
The the overflowing text should probably be clipped on column width or the column width could be dynamically computed from the longest string in the app list to make room for even the longest one. Alternatively, one could just switch the columns around and have the App column as the last one, which would just avoid the entire issue 😄
This was originally created as #4, but the fix that closed it only contained the padding fix for the PID column, so reposting the other half.
I'm using this in an Arch Linux docker container and getting this error when using an appname:
ERROR: sys_getdents64 failed on '/sys/kernel/slab/': -1 errno:5
My gcc version is 13.1.1 20230429
Thanks for this little gem. It is a really neat little util. I found it hidden along on one of my more popular answers on StackOverflow and the Unix StackExchange and I just tested it. I see it covers most of the stuff in the script I shared there, looks nicer, is faster and is IMHO just missing one improvement to make it more useful: sort processes by the number of inotify watches by default.
Who cares about the order of pids? They want the main offender, so it makes sense to sort by watch count by default, perhaps offering to sort by pid as an alternative CLI option.
P.S. Added a reference to this repo in my script to guide more people here 😸
Now that inotify-info starts being included to distros, we (I) may need some "signal' when it' worthwhile to update it downstream.
I could follow all commits and arbitrarily decide when I feel like a "release" is worthy by taking a snapshot.
Or you may think "this is something that should end up downstream" and just cut & push a tag. That has a higher chance to have it consistent across distros, when there are more.
If ut wouldn't be too much to ask, it would be great if you could make a tag from time to time. Distro packagers will do the rest.
Feel free to close it and keep not making tags, I will just keep following the commits.
Thank you for the product!
Would be nice to have thousands separator, e.g. 12,345
or 12.345
depending on locale.
Maybe: inotify-info -s
or inotify-info --separators
.
On such a server, you will get the error:
$ make
Using gold linker...
Building _release/inotify-info...
---- inotify-info.cpp ----
g++: error: unrecognized command line option ‘-Wimplicit-fallthrough=2’
make: *** [_release/inotify-info.o] Error 1
The g++ version is
$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Is it possible to update the make process so that it can cover platforms?
Thanks
Richard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.