sg_get_user_stats(3)

sg_get_user_stats3

Get the current logged in users

Usage

FC#include <statgrab.h>F[0]

FCsg_user_stats *sg_get_user_statsF[0] FC(size_t *entries);F[0]

FCsg_user_stats *sg_get_user_stats_rF[0] FC(size_t *entries);F[0]

FCsg_error sg_free_user_statsF[0] FC(sg_user_stats *data);F[0]

Overview

The user statistics module delivers some information about logged on users. Each logon is treated separately. Both statistic get functions, FCsg_get_user_statsF[0]() and FCsg_get_user_stats_rF[0](), return a vector of FCsg_user_statsF[0] with FCentriesF[0] elements.

API Shortcut

functionreturnsdata owner
sg_get_user_statsFCsg_user_statsF[0] *libstatgrab (thread local)
sg_get_user_stats_rFCsg_user_statsF[0] *caller

The FCsg_user_statsF[0] vector received from FCsg_get_user_stats_rF[0]() must be freed using FCsg_free_user_statsF[0]() when not needed any more. The caller is responsible for doing it.

Return values

The structure returned is of type FCsg_user_statsF[0].

FC
typedef struct {
        char *login_name;
        char *record_id;
        size_t record_id_size;
        char *device;
        char *hostname;
        pid_t pid;
        time_t login_time;
        time_t systime;
} sg_user_stats;
    F[0]
FClogin_nameF[0]

The username which was used to log in

FCrecord_idF[0]

Record identifier of host database containing login information (not necessarily 0-terminated)

FCrecord_id_sizeF[0]

Size of the record identifier

FCdeviceF[0]

Device name (eg. "pts/0") of the tty assigned to the login session

FChostnameF[0]

(remote) Hostname from where the user is logged on, eg. "infoterm7.some.kind.of.domain.local", "localhost", "10.42.17.4" or ":0.0" (in case it's a local logon via new xterm)

FCpidF[0]

Process identifier of the process which made the entry to the logged on users database

FClogin_timeF[0]

Timestamp (time in seconds since epoch) when the user logged on

FCsystimeF[0]

The timestamp when the above stats where collected in seconds since epoch

Website

⟨https://libstatgrab.org/⟩

Releases

11 releases since Debian 4.0 (Etch); the text changed 4 times.

  1. 4.0–7
  2. 8–10
  3. 11
  4. 12–13
  5. Arch

From libstatgrab 0.92.1-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.