procps_misc(3) — Linux manual page


PROCPS_MISC(3)          Library Functions Manual          PROCPS_MISC(3)

NAME         top

       procps_misc - API for miscellaneous information in the /proc

SYNOPSIS         top

       #include <libproc2/misc.h>

       Platform Particulars

           long         procps_cpu_count (void);
           long         procps_hertz_get (void);
           unsigned int procps_pid_length (void);
           int          procps_linux_version (void);

       Runtime Particulars

           int   procps_loadavg (double *av1, double *av5, double *av15);
           int   procps_uptime (double *uptime_secs, double *idle_secs);
           char *procps_uptime_sprint (void);
           char *procps_uptime_sprint_short (void);

       Namespace Particulars

           int         procps_ns_get_id (const char *name);
           const char *procps_ns_get_name (int id);
           int         procps_ns_read_pid (int pid, struct procps_ns *nsp);

       Link with -lproc2.

DESCRIPTION         top

       procps_cpu_count() returns the number of CPUs that are currently
       online as sysconf(_SC_NPROCESSORS_ONLY) or an assumed 1.

       procps_hertz_get() returns the number of clock ticks per second
       as sysconf(_SC_CLK_TCK) or an assumed 100.  Dividing tics by this
       value yields seconds.

       procps_pid_length() returns the maximum string length for a PID
       on the system. For example, if the largest possible PID value on
       was 123, then the length would be 3. If the file
       /proc/sys/kernel/pid_max is unreadable, the value is assumed to
       be 5.

       procps_linux_version() returns the current Linux version as an
       encoded integer. On non-Linux systems that have an emulated proc
       filesystem this function returns the version of the Linux
       emulation instead.  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.

           LINUX_VERSION( major , minor , patch )

           LINUX_VERSION_MAJOR( ver )

           LINUX_VERSION_MINOR( ver )

           LINUX_VERSION_PATCH( ver )

       procps_loadavg() fetches the system load average and puts the 1,
       5 and 15 minute averages into location(s) specified by any
       pointer which is not NULL.

       procps_uptime() returns uptime and/or idle seconds into
       location(s) specified by any pointer which is not NULL.  The
       sprint varieties return a human-readable string in one of two

           HH:MM:SS up HH:MM, # users, load average: 1, 5, 15 MM

           up HH, MM

       procps_ns_get_id() returns the integer id (enum namespace_type)
       of the namespace for the given namespace name.

       procps_ns_get_name() returns the name of the namespace for the
       given id (enum namespace_type).

       procps_ns_read_pid() returns the inodes for the namespaces of the
       given process in the procps_ns structure pointed to by nsp.
       Those inodes will appear in the order proscribed by enum

           enum namespace_type {

RETURN VALUE         top

   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.

   Functions Returning an `address'
       An error will be indicated by a NULL return pointer with the
       reason found in the formal errno value.

FILES         top

              The raw values for load average.

              Contains the release version of the Linux kernel or proc

              Contains the value at which PIDs wrap around, one greater
              than the maximum PID value.

              The raw values for uptime and idle time.

              contains the set of namespaces for a particular PID.

SEE ALSO         top

       procps(3), procps_pids(3), proc(5).

COLOPHON         top

       This page is part of the procps-ng (/proc filesystem utilities)
       project.  Information about the project can be found at 
       ⟨⟩.  If you have a bug report
       for this manual page, see
       This page was obtained from the project's upstream Git repository
       ⟨⟩ on 2022-12-18.  (At
       that time, the date of the most recent commit that was found in
       the repository was 2022-12-13.)  If you discover any rendering
       problems in this HTML version of the page, or you believe there
       is a better or more up-to-date source for the page, or you have
       corrections or improvements to the information in this COLOPHON
       (which is not part of the original manual page), send a mail to

libproc2                       August 2022                PROCPS_MISC(3)

Pages that refer to this page: procps(3)procps_pids(3)