1sg_get_user_stats(3) sg_get_user_stats(3)
2
3
4
6 sg_get_user_stats, sg_get_user_stats_r, sg_free_user_stats - get the
7 current logged in users
8
10 #include <statgrab.h>
11
12
13 sg_user_stats *sg_get_user_stats (size_t *entries);
14
15 sg_user_stats *sg_get_user_stats_r (size_t *entries);
16
17 sg_error sg_free_user_stats (sg_user_stats *data);
18
20 The user statistics module delivers some information about logged on
21 users. Each logon is treated separately. Both statistic get functions,
22 sg_get_user_stats() and sg_get_user_stats_r(), return a vector of
23 sg_user_stats with entries elements.
24
25 API Shortcut
26
27 ┌────────────────────┬─────────────────┬─────────────────────┐
28 │function │ returns │ data owner │
29 ├────────────────────┼─────────────────┼─────────────────────┤
30 │sg_get_user_stats │ sg_user_stats * │ libstatgrab (thread │
31 │ │ │ local) │
32 ├────────────────────┼─────────────────┼─────────────────────┤
33 │sg_get_user_stats_r │ sg_user_stats * │ caller │
34 └────────────────────┴─────────────────┴─────────────────────┘
35 The sg_user_stats vector received from sg_get_user_stats_r() must be
36 freed using sg_free_user_stats() when not needed any more. The caller
37 is responsible for doing it.
38
40 The structure returned is of type sg_user_stats.
41
42 typedef struct {
43 char *login_name;
44 char *record_id;
45 size_t record_id_size;
46 char *device;
47 char *hostname;
48 pid_t pid;
49 time_t login_time;
50 time_t systime;
51 } sg_user_stats;
52
53
54 login_name
55 The username which was used to log in
56
57 record_id
58 Record identifier of host database containing login information
59 (not necessarily 0-terminated)
60
61 record_id_size
62 Size of the record identifier
63
64 device Device name (eg. "pts/0") of the tty assigned to the login ses‐
65 sion
66
67 hostname
68 (remote) Hostname from where the user is logged on, eg. "in‐
69 foterm7.some.kind.of.domain.local", "localhost", "10.42.17.4" or
70 ":0.0" (in case it's a local logon via new xterm)
71
72 pid Process identifier of the process which made the entry to the
73 logged on users database
74
75 login_time
76 Timestamp (time in seconds since epoch) when the user logged on
77
78 systime
79 The timestamp when the above stats where collected in seconds
80 since epoch
81
83 statgrab(3)
84
86 ⟨http://www.i-scream.org/libstatgrab/⟩
87
88
89
90i-scream 2013-06-07 sg_get_user_stats(3)