Re: [PATCH v2] kernel/ucounts: expose count of inotify watches in use

From: Albert Vaca Cintora
Date: Thu Apr 25 2019 - 17:40:27 EST


On Thu, Apr 25, 2019 at 10:07 PM Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 1 Feb 2019 21:39:59 +0100 Albert Vaca Cintora <albertvaka@xxxxxxxxx> wrote:
>
> > Adds a readonly 'current_inotify_watches' entry to the user sysctl table.
> > The handler for this entry is a custom function that ends up calling
> > proc_dointvec. Said sysctl table already contains 'max_inotify_watches'
> > and it gets mounted under /proc/sys/user/.
> >
> > Inotify watches are a finite resource, in a similar way to available file
> > descriptors. The motivation for this patch is to be able to set up
> > monitoring and alerting before an application starts failing because
> > it runs out of inotify watches.
>
> Matthias said "Albert found this problem while working on montitoring
> software, so it fixes a real problem out there", so please include full
> details of the problem which you encountered so that we are better able
> to understand the value of the patch.
>

This is an important metric to track as a sysadmin. Currently,
monitoring software have to workaround the lack of a single metric by
iterating all the file descriptors for all processes and checking
which ones are inotify watches [1].

If this seems enough justification to you, please say so and I will
submit a patch v3 with the requested implementation changes.

[1] https://github.com/prometheus/node_exporter/blob/master/text_collector_examples/inotify-instances

Albert