sg_get_load_stats(3)

NAME
sg_get_load_stats, sg_get_load_stats_r, sg_free_load_stats - get system load

SYNOPSIS
\FC#include <statgrab.h>\F[]

\FCsg_load_stats *sg_get_load_stats\F[]
\FC(size_t *entries);\F[]

\FCsg_load_stats *sg_get_load_stats_r\F[]
\FC(size_t *entries);\F[]

\FCsg_error sg_free_load_stats\F[]
\FC(sg_load_stats *data);\F[]

DESCRIPTION
These calls returns a pointer to a buffer containing information about cumulated machine load.

API Shortcut
function | returns | data owner
sg_get_load_stats | \FCsg_load_stats\F[] * | libstatgrab (thread local)
sg_get_load_stats_r | \FCsg_load_stats\F[] * | caller

The \FCsg_load_stats\F[] buffer received from \FCsg_get_load_stats_r\F[]() must be freed using \FCsg_free_load_stats\F[]() when not needed any more. The caller is responsible for doing it.

On most systems this function is just a wrapper to the \FCgetloadavg\F[] system call.

RETURN VALUES
The structure returned is of type \FCsg_load_stats\F[].

\FC
typedef struct{
        double min1;
        double min5;
        double min15;
        time_t systime;
}sg_load_stats;
    \F[]

\FCmin1\F[]
    The load average over 1 minute.

\FCmin5\F[]
    The load average over 5 minutes.

\FCmin15\F[]
    The load average over 15 minutes.

\FCsystime\F[]
    The timestamp when the above stats where collected in seconds since epoch

SEE ALSO
statgrab(3)

WEBSITE
⟨https://libstatgrab.org/⟩