1PROCPS_MISC(3) Library Functions Manual PROCPS_MISC(3)
2
3
4
6 procps_misc - API for miscellaneous information in the /proc filesystem
7
9 #include <libproc2/misc.h>
10
11 Platform Particulars
12
13 long procps_cpu_count (void);
14 long procps_hertz_get (void);
15 unsigned int procps_pid_length (void);
16 int procps_linux_version (void);
17
18 Runtime Particulars
19
20 int procps_loadavg (double *av1, double *av5, double *av15);
21 int procps_uptime (double *uptime_secs, double *idle_secs);
22 char *procps_uptime_sprint (void);
23 char *procps_uptime_sprint_short (void);
24
25 Namespace Particulars
26
27 int procps_ns_get_id (const char *name);
28 const char *procps_ns_get_name (int id);
29 int procps_ns_read_pid (int pid, struct procps_ns *nsp);
30
31 Link with -lproc2.
32
33
35 procps_cpu_count() returns the number of CPUs that are currently online
36 as sysconf(_SC_NPROCESSORS_ONLY) or an assumed 1.
37
38 procps_hertz_get() returns the number of clock ticks per second as
39 sysconf(_SC_CLK_TCK) or an assumed 100. Dividing tics by this value
40 yields seconds.
41
42 procps_pid_length() returns the maximum string length for a PID on the
43 system. For example, if the largest possible PID value on was 123, then
44 the length would be 3. If the file /proc/sys/kernel/pid_max is
45 unreadable, the value is assumed to be 5.
46
47 procps_linux_version() returns the current Linux version as an encoded
48 integer. On non-Linux systems that have an emulated proc filesystem
49 this function returns the version of the Linux emulation instead. The
50 version consists of three positive integers representing the major,
51 minor and patch levels. The following macros are provided for encoding
52 a given Linux version or separating out the components of the current
53 version.
54
55 LINUX_VERSION( major , minor , patch )
56
57 LINUX_VERSION_MAJOR( ver )
58
59 LINUX_VERSION_MINOR( ver )
60
61 LINUX_VERSION_PATCH( ver )
62
63 procps_loadavg() fetches the system load average and puts the 1, 5 and
64 15 minute averages into location(s) specified by any pointer which is
65 not NULL.
66
67 procps_uptime() returns uptime and/or idle seconds into location(s)
68 specified by any pointer which is not NULL. The sprint varieties
69 return a human-readable string in one of two forms.
70
71 HH:MM:SS up HH:MM, # users, load average: 1, 5, 15 MM averages
72
73 up HH, MM
74
75 procps_ns_get_id() returns the integer id (enum namespace_type) of the
76 namespace for the given namespace name.
77
78 procps_ns_get_name() returns the name of the namespace for the given id
79 (enum namespace_type).
80
81 procps_ns_read_pid() returns the inodes for the namespaces of the given
82 process in the procps_ns structure pointed to by nsp. Those inodes
83 will appear in the order proscribed by enum namespace_type.
84
85 enum namespace_type {
86 PROCPS_NS_CGROUP,
87 PROCPS_NS_IPC,
88 PROCPS_NS_MNT,
89 PROCPS_NS_NET,
90 PROCPS_NS_PID,
91 PROCPS_NS_TIME,
92 PROCPS_NS_USER,
93 PROCPS_NS_UTS
94 };
95
96
97
99 Functions Returning an `int' or `long'
100 An error will be indicated by a negative number that is always the
101 inverse of some well known errno.h value.
102
103
104 Functions Returning an `address'
105 An error will be indicated by a NULL return pointer with the reason
106 found in the formal errno value.
107
108
110 /proc/loadavg
111 The raw values for load average.
112
113 /proc/sys/kernel/osrelease
114 Contains the release version of the Linux kernel or proc
115 filesystem.
116
117 /proc/sys/kernel/pid_max
118 Contains the value at which PIDs wrap around, one greater than
119 the maximum PID value.
120
121 /proc/uptime
122 The raw values for uptime and idle time.
123
124 /proc/<PID>/ns
125 contains the set of namespaces for a particular PID.
126
127
129 procps(3), procps_pids(3), proc(5).
130
131
132
133libproc2 August 2022 PROCPS_MISC(3)