2020-10-24 12:55:48 +05:30
|
|
|
.\" (C) Copyright 2020 Craig Small <csmall@dropbear.xyz>
|
2022-01-07 11:30:00 +05:30
|
|
|
.\" (C) Copyright 2021-2022 Jim Warner <james.warner@comcast.net>
|
2020-10-24 12:55:48 +05:30
|
|
|
.\"
|
|
|
|
.\" %%%LICENSE_START(LGPL_2.1+)
|
|
|
|
.\" This manual is free software; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU Lesser General Public
|
|
|
|
.\" License as published by the Free Software Foundation; either
|
|
|
|
.\" version 2.1 of the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
.\" Lesser General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU Lesser General Public
|
|
|
|
.\" License along with this library; if not, write to the Free Software
|
|
|
|
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
.\" %%%LICENSE_END
|
|
|
|
.\"
|
2022-01-01 11:30:00 +05:30
|
|
|
.TH PROCPS_MISC 3 "January 2022" "libproc-2"
|
2020-10-24 12:55:48 +05:30
|
|
|
.\" Please adjust this date whenever revising the manpage.
|
|
|
|
.\"
|
2021-01-20 11:30:00 +05:30
|
|
|
.nh
|
2020-10-24 12:55:48 +05:30
|
|
|
.SH NAME
|
2021-01-20 11:30:00 +05:30
|
|
|
procps_misc \- API for miscellaneous information in the /proc filesystem
|
2020-10-24 12:55:48 +05:30
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
2021-01-20 11:30:00 +05:30
|
|
|
.B #include <procps/misc.h>
|
2020-12-21 07:11:10 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
Platform Particulars
|
|
|
|
.RS 4
|
2020-10-24 12:55:48 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
.B "long procps_cpu_count (void);"
|
|
|
|
.B "long procps_hertz_get (void);"
|
|
|
|
.B "unsigned int procps_pid_length (void);"
|
|
|
|
.B "int procps_linux_version (void);"
|
|
|
|
.RE
|
2020-12-21 07:02:57 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
Runtime Particulars
|
2020-12-21 07:18:06 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
.RS 4
|
|
|
|
.BI "int procps_loadavg (double * " av1 ", double * " av5 ", double * " av15 ");"
|
|
|
|
.BI "int procps_uptime (double * " uptime_secs ", double * " idle_secs ");"
|
|
|
|
.B "char * procps_uptime_sprint (void);"
|
|
|
|
.B "char * procps_uptime_sprint_short (void);"
|
|
|
|
.RE
|
2020-12-21 07:18:06 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
Namespace Particulars
|
2020-12-21 07:02:57 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
.RS 4
|
|
|
|
.BI "int procps_ns_get_id (const char * " name ");"
|
|
|
|
.BI "const char * procps_ns_get_name (int " id ");"
|
|
|
|
.BI "int procps_ns_read_pid (int " pid ", struct procps_ns * " nsp ");"
|
|
|
|
.RE
|
2021-02-20 22:41:11 +05:30
|
|
|
|
|
|
|
Link with \fI\-lproc-2\fP.
|
2020-12-21 07:02:57 +05:30
|
|
|
|
2021-01-20 11:30:00 +05:30
|
|
|
.SH DESCRIPTION
|
2020-10-24 12:55:48 +05:30
|
|
|
.BR procps_cpu_count ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the number of CPUs that are currently online as
|
2020-12-21 07:13:00 +05:30
|
|
|
.BI sysconf( _SC_NPROCESSORS_ONLY )
|
2021-01-20 11:30:00 +05:30
|
|
|
or an assumed \fI1\fR.
|
2020-10-24 12:55:48 +05:30
|
|
|
|
|
|
|
.BR procps_hertz_get ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the number of clock ticks per second as
|
2020-10-24 12:55:48 +05:30
|
|
|
.BI sysconf( _SC_CLK_TCK )
|
2021-01-20 11:30:00 +05:30
|
|
|
or an assumed \fI100\fR.
|
|
|
|
Dividing tics by this value yields seconds.
|
2020-10-24 12:55:48 +05:30
|
|
|
|
|
|
|
.BR procps_pid_length ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the maximum string length for a PID on the system. For example, if the largest
|
2020-10-24 12:55:48 +05:30
|
|
|
possible PID value on was 123, then the length would be 3. If the file
|
2021-01-20 11:30:00 +05:30
|
|
|
\fI/proc/sys/kernel/pid_max\fR is unreadable, the value is assumed to be \fI5\fR.
|
2020-10-24 12:55:48 +05:30
|
|
|
|
2020-12-21 07:02:57 +05:30
|
|
|
.BR procps_linux_version ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the current Linux version as an encoded integer. On non-Linux systems that
|
2020-12-21 07:02:57 +05:30
|
|
|
have an emulated proc filesystem this function returns the version of the
|
|
|
|
Linux emulation instead.
|
2021-01-20 11:30:00 +05:30
|
|
|
The version consists of three positive integers representing the major,
|
|
|
|
minor and patch levels.
|
|
|
|
The following macros are provided for encoding a given Linux version or
|
|
|
|
separating out the components of the current version.
|
2020-12-21 07:02:57 +05:30
|
|
|
.RS 4
|
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
LINUX_VERSION(\ major\ ,\ minor\ ,\ patch\ )
|
2020-12-21 07:11:10 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
LINUX_VERSION_MAJOR(\ ver\ )
|
|
|
|
.PP
|
|
|
|
LINUX_VERSION_MINOR(\ ver\ )
|
|
|
|
.PP
|
|
|
|
LINUX_VERSION_PATCH(\ ver\ )
|
|
|
|
.RE
|
2020-10-24 12:55:48 +05:30
|
|
|
|
|
|
|
.BR procps_loadavg ()
|
2021-01-20 11:30:00 +05:30
|
|
|
fetches the system load average and puts the 1, 5 and 15 minute averages into
|
|
|
|
location(s) specified by any pointer which is not \fINULL\fR.
|
2020-10-24 12:55:48 +05:30
|
|
|
|
2021-01-20 11:30:00 +05:30
|
|
|
.BR procps_uptime ()
|
|
|
|
returns uptime and/or idle seconds into location(s) specified by any pointer
|
|
|
|
which is not \fINULL\fR.
|
|
|
|
The \fBsprint\fR varieties return a human-readable string in one of two forms.
|
|
|
|
.RS 4
|
2020-12-21 07:02:57 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
HH:MM:SS up HH:MM, # users, load average: 1, 5, 15 MM averages
|
|
|
|
.PP
|
|
|
|
up HH, MM
|
|
|
|
.RE
|
2020-12-21 07:02:57 +05:30
|
|
|
|
2020-12-21 07:11:10 +05:30
|
|
|
.BR procps_ns_get_id ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the integer id (enum namespace_type) of the namespace for the given namespace \fIname\fR.
|
2020-12-21 07:11:10 +05:30
|
|
|
|
|
|
|
.BR procps_ns_get_name ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the name of the namespace for the given \fIid\fR (enum namespace_type).
|
2020-12-21 07:11:10 +05:30
|
|
|
|
|
|
|
.BR procps_ns_read_pid ()
|
2021-01-20 11:30:00 +05:30
|
|
|
returns the inodes for the namespaces of the given process in the
|
|
|
|
procps_ns structure pointed to by \fInsp\fR.
|
|
|
|
Those inodes will appear in the order proscribed by enum namespace_type.
|
2020-12-21 07:18:06 +05:30
|
|
|
.PP
|
2021-01-20 11:30:00 +05:30
|
|
|
.RS 4
|
|
|
|
.nf
|
|
|
|
enum namespace_type {
|
|
|
|
PROCPS_NS_IPC,
|
|
|
|
PROCPS_NS_MNT,
|
|
|
|
PROCPS_NS_NET,
|
|
|
|
PROCPS_NS_PID,
|
|
|
|
PROCPS_NS_USER,
|
|
|
|
PROCPS_NS_UTS
|
|
|
|
};
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
2020-12-21 07:18:06 +05:30
|
|
|
|
2021-01-20 11:30:00 +05:30
|
|
|
.SH RETURN VALUE
|
|
|
|
.SS Functions Returning an `int' or `long'
|
|
|
|
An error will be indicated by a negative number that
|
|
|
|
is always the inverse of some well known errno.h value.
|
2020-12-21 07:18:06 +05:30
|
|
|
|
2021-01-20 11:30:00 +05:30
|
|
|
.SS Functions Returning an `address'
|
|
|
|
An error will be indicated by a NULL return pointer
|
|
|
|
with the reason found in the formal errno value.
|
2020-12-21 07:18:06 +05:30
|
|
|
|
2020-10-24 12:55:48 +05:30
|
|
|
.SH FILES
|
|
|
|
.TP
|
|
|
|
.I /proc/loadavg
|
|
|
|
The raw values for load average.
|
|
|
|
.TP
|
2020-12-21 07:02:57 +05:30
|
|
|
.I /proc/sys/kernel/osrelease
|
|
|
|
Contains the release version of the Linux kernel or proc filesystem.
|
|
|
|
.TP
|
2020-10-24 12:55:48 +05:30
|
|
|
.I /proc/sys/kernel/pid_max
|
|
|
|
Contains the value at which PIDs wrap around, one greater than the maximum PID value.
|
2020-12-21 07:18:06 +05:30
|
|
|
.TP
|
|
|
|
.I /proc/uptime
|
|
|
|
The raw values for uptime and idle time.
|
|
|
|
.TP
|
2021-01-20 11:30:00 +05:30
|
|
|
.IB /proc/<PID>/ns
|
2020-12-21 07:11:10 +05:30
|
|
|
contains the set of namespaces for a particular \fBPID\fR.
|
2020-10-24 12:55:48 +05:30
|
|
|
|
|
|
|
.SH SEE ALSO
|
2021-01-20 11:30:00 +05:30
|
|
|
.BR procps (3).
|
|
|
|
.BR procps_pids (3).
|
2020-10-24 12:55:48 +05:30
|
|
|
.BR proc (5).
|