develooper Front page | perl.module-authors | Postings from August 2020

Re: Extending Proc::ProcessTable::Process with number of file openedand Naming a new package

Thread Previous
Paul "LeoNerd" Evans
August 22, 2020 15:10
Re: Extending Proc::ProcessTable::Process with number of file openedand Naming a new package
Message ID:
On Thu, 20 Aug 2020 16:08:43 -0400
"Sven F." <> wrote:

> Dear readers,
> I recently find myself using Prometheus database,
> I found about the perl `binding` Net::Prometheus
> Net::Prometheus provides a way to export metrics to
> the databases.
> The Any::Metrics generalize the concept to make perl code
> not 'glued' to Prometheus.

ITYM Metrics::Any

> Net::Prometheus provides a few metrics which are linux dependant,
> in Net::Prometheus::ProcessCollector::linux
> For example , the Package is using the `/proc/$pid/fd` info .
> Perl posses an abstract for processes with Proc::ProcessTable::Process
> but this , just like the 'ps' command, lacks the amount of file
> opened by a process (which could be quite helpful, this resource
> is limited).
> Personally I will -unless strongly advised against-
> write a XS package to get that metric in OpenBSD
> with kvm_getfiles.
> The only way i currently know to get this info is using `fstat $pid |
> wc -l`, fstat , being a lsof in bsds.
> BSD::Process does not have this either but is using the 'kvm' system.
> Linking all of this may create too many dependencies,
> nevertheless I know some perl code could be quite smart to
> opt in certains sub routines if the right module is available .
> So this could be done through 'soft'  dependencies. - I do not know
> what you call those packages that are optional but work together.

If it's an optional dependency that opportunistically loads and works
if available, that should be fine.

> Of course i will have to name the package, i saw OpenBSD::Checkpass
> so it could be OpenBSD::Kvm_getfiles
> But it also is a specific implementation so if
> Proc::ProcessTable::Process::Files ( which would be the number of
> file open and maybe some limits info like the one found in the class
> limits/login.conf ) It would look like
> Proc::ProcessTable::Process::OpenBSD which seems way too long.
> So i guess OpenBSD::Kvm_getfiles is completely enough
> Especially since BSD::Process is not OpenBSD compatible
> and  freebsd use procstat_getfiles  while openbsd use kvm_getfiles.
> Thank you for reading that far, stay safe and
> have a good one.

I don't have any specific suggestions about OpenBSD, but overall having
some process metrics exported from OpenBSD would be good. Whatever's
available - don't feel you *have* to support every single one as an
exact copy of the Linux ones. Just do whatever makes sense there -
different OSes can differ slightly in shape and that's fine.

Maybe have a look around some other Prometheus client libs for other
langauges, and see if they have any OpenBSD support. Try to copy what
they do - different language clients on the same OS should act the same.

Maybe also try asking in #prometheus on Freenode.

Paul "LeoNerd" Evans      |  |

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About