2020-05-18 16:40:03 +05:30
|
|
|
.\" (C) Copyright 2016-2020 Craig Small <csmall@dropbear.xyz>
|
2016-04-16 17:32:10 +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
|
|
|
|
.\"
|
2020-05-18 16:40:03 +05:30
|
|
|
.TH PROCPS_UPTIME 3 2020-05-18 "libproc-2"
|
2016-04-16 17:32:10 +05:30
|
|
|
.\" Please adjust this date whenever revising the manpage.
|
|
|
|
.\"
|
|
|
|
.SH NAME
|
2020-05-18 16:40:03 +05:30
|
|
|
procps_uptime, procps_sprint, procps_uptime_sprint_short \-
|
2016-04-16 17:32:10 +05:30
|
|
|
provide the uptime and idle time in seconds
|
|
|
|
.SH SYNOPSIS
|
2020-05-18 16:40:03 +05:30
|
|
|
.nf
|
2016-04-16 17:32:10 +05:30
|
|
|
.B #include <proc/procps.h>
|
2020-05-18 16:40:03 +05:30
|
|
|
.PP
|
2016-04-16 17:32:10 +05:30
|
|
|
.BI "int procps_uptime(double * " uptime_secs ", double * " idle_secs ");"
|
2020-05-18 16:40:03 +05:30
|
|
|
.B char *procps_uptime_sprint(void);
|
|
|
|
.B char *procps_uptime_sprint_short(void);
|
2016-04-16 17:32:10 +05:30
|
|
|
.sp
|
|
|
|
Link with \fI\-lprocps\fP.
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.BR procps_uptime ()
|
2020-05-18 16:40:03 +05:30
|
|
|
returns the uptime and idle time of the system. Either the
|
|
|
|
\fIuptime_secs\fR or \fIidle_secs\fR can be \fBNULL\fR in which case that
|
|
|
|
variable will not be returned.
|
|
|
|
|
|
|
|
The \fBsprint\fR variety of the functions return a human-readable
|
|
|
|
string of the uptime and other statistics.
|
|
|
|
|
2016-04-16 17:32:10 +05:30
|
|
|
.SH RETURN VALUE
|
|
|
|
.BR procps_uptime ()
|
2016-05-01 12:20:25 +05:30
|
|
|
returns 0 on success. On failure, it
|
2016-04-16 17:32:10 +05:30
|
|
|
returns a negative integer to one of the values defined below.
|
|
|
|
.TP
|
|
|
|
.B -ERANGE
|
|
|
|
Unable to parse the uptime file.
|
|
|
|
.PP
|
|
|
|
.BR procps_uptime ()
|
|
|
|
may also return any (negated) value that \fBfopen\fR() may set errno to.
|
|
|
|
|
2020-05-18 16:40:03 +05:30
|
|
|
.BR procps_uptime_sprint_short ()
|
|
|
|
return a string from a statically allocated buffer which displays uptime.
|
|
|
|
|
|
|
|
.BR procps_uptime_sprint ()
|
|
|
|
also displays users and load average in the buffer. The formats are the
|
|
|
|
same as
|
|
|
|
.BR uptime (1)
|
|
|
|
with and without the
|
|
|
|
.B \-p
|
|
|
|
option.
|
|
|
|
|
2016-04-16 17:32:10 +05:30
|
|
|
.SH FILES
|
|
|
|
.TP
|
|
|
|
.I /proc/uptime
|
|
|
|
The raw values for uptime and idle time.
|
|
|
|
|
|
|
|
.SH VERSIONS
|
|
|
|
.B procps_uptime()
|
|
|
|
first appeared in libproc-2 version 0.0.
|
|
|
|
|
|
|
|
.SH SEE ALSO
|
2020-05-18 16:40:03 +05:30
|
|
|
.BR uptime (1),
|
2016-04-16 17:32:10 +05:30
|
|
|
.BR fopen (3),
|
|
|
|
.BR proc (5).
|