procps/doc/procps_uptime.3

78 lines
2.3 KiB
Groff
Raw Normal View History

.\" (C) Copyright 2016-2020 Craig Small <csmall@dropbear.xyz>
.\"
.\" %%%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
.\"
.TH PROCPS_UPTIME 3 2020-05-18 "libproc-2"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
procps_uptime, procps_sprint, procps_uptime_sprint_short \-
provide the uptime and idle time in seconds
.SH SYNOPSIS
.nf
.B #include <proc/procps.h>
.PP
.BI "int procps_uptime(double * " uptime_secs ", double * " idle_secs ");"
.B char *procps_uptime_sprint(void);
.B char *procps_uptime_sprint_short(void);
.sp
Link with \fI\-lprocps\fP.
.SH DESCRIPTION
.BR procps_uptime ()
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.
.SH RETURN VALUE
.BR procps_uptime ()
returns 0 on success. On failure, it
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.
.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.
.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
.BR uptime (1),
.BR fopen (3),
.BR proc (5).