ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/docs/sg_get_mem_stats.xml
Revision: 1.1
Committed: Thu Oct 2 16:20:23 2003 UTC (21 years, 1 month ago) by tdb
Content type: text/xml
Branch: MAIN
Log Message:
Add final manpage - swap and memory.

File Contents

# User Rev Content
1 tdb 1.1 <?xml version="1.0"?>
2    
3     <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4     "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5    
6     <refentry id="get_memory_stats">
7    
8     <refentryinfo>
9     <date>$Date$</date>
10     <releaseinfo>$Id$</releaseinfo>
11     </refentryinfo>
12    
13     <refmeta>
14     <refentrytitle>get_memory_stats</refentrytitle>
15     <manvolnum>3</manvolnum>
16     <refmiscinfo>i-scream</refmiscinfo>
17     </refmeta>
18    
19     <refnamediv>
20     <refname>get_memory_stats</refname>
21     <refname>get_swap_stats</refname>
22     <refpurpose>get VM statistics</refpurpose>
23     </refnamediv>
24    
25     <refsynopsisdiv>
26     <funcsynopsis>
27     <funcsynopsisinfo>#include &lt;statgrab.h&gt;</funcsynopsisinfo>
28     <funcprototype>
29     <funcdef>mem_stat_t *<function>get_memory_stats</function></funcdef>
30     <void/>
31     </funcprototype>
32     <funcprototype>
33     <funcdef>swap_stat_t *<function>get_swap_stats</function></funcdef>
34     <void/>
35     </funcprototype>
36     </funcsynopsis>
37     </refsynopsisdiv>
38    
39     <refsect1>
40     <title>Description</title>
41     <para>
42     Memory statistics are accessed through the
43     <function>get_memory_stats</function> function. It returns a
44     pointer to a static <structname>mem_stat_t</structname>.
45     </para>
46     <para>
47     The <function>get_swap_stats</function> returns returns swap
48     statistics. It returns a pointer to a static
49     <structname>swap_stat_t</structname>.
50     </para>
51     <para>
52     On the FreeBSD operating system elevated privileges are required
53     to access the swap statistics. Making the program setgid kmem
54     should be sufficient. Programs running as root will not have this
55     problem.
56     </para>
57     </refsect1>
58    
59     <refsect1>
60     <title>Return Values</title>
61    
62     <para>
63     The VM system calls can return a pointer to either a
64     <structname>mem_stat_t</structname> or a
65     <structname>swap_stat_t</structname>.
66     </para>
67    
68     <programlisting>
69     typedef struct{
70     long long total;
71     long long free;
72     long long used;
73     long long cache;
74     }mem_stat_t;
75     </programlisting>
76    
77     <variablelist>
78     <varlistentry>
79     <term>
80     <structfield>total</structfield>
81     </term>
82     <listitem>
83     <para>
84     The total amount of memory in bytes.
85     </para>
86     </listitem>
87     </varlistentry>
88     <varlistentry>
89     <term>
90     <structfield>free</structfield>
91     </term>
92     <listitem>
93     <para>
94     The total free memory in bytes.
95     </para>
96     </listitem>
97     </varlistentry>
98     <varlistentry>
99     <term>
100     <structfield>used</structfield>
101     </term>
102     <listitem>
103     <para>
104     The total used memory in bytes.
105     </para>
106     </listitem>
107     </varlistentry>
108     <varlistentry>
109     <term>
110     <structfield>cache</structfield>
111     </term>
112     <listitem>
113     <para>
114     The amount of cache used in bytes.
115     </para>
116     </listitem>
117     </varlistentry>
118     </variablelist>
119    
120     <programlisting>
121     typedef struct{
122     long long total;
123     long long used;
124     long long free;
125     }swap_stat_t;
126     </programlisting>
127    
128     <variablelist>
129     <varlistentry>
130     <term>
131     <structfield>total</structfield>
132     </term>
133     <listitem>
134     <para>
135     The total swap space in bytes.
136     </para>
137     </listitem>
138     </varlistentry>
139     <varlistentry>
140     <term>
141     <structfield>used</structfield>
142     </term>
143     <listitem>
144     <para>
145     The used swap in bytes.
146     </para>
147     </listitem>
148     </varlistentry>
149     <varlistentry>
150     <term>
151     <structfield>free</structfield>
152     </term>
153     <listitem>
154     <para>
155     The free swap in bytes.
156     </para>
157     </listitem>
158     </varlistentry>
159     </variablelist>
160     </refsect1>
161    
162     <refsect1>
163     <title>Todo</title>
164     <para>
165     Add a function to hold open the file descriptor to the kernel
166     memory structures. Doing this would allow the elevated privileges
167     to be dropped early on.
168     </para>
169     </refsect1>
170    
171     <refsect1>
172     <title>See Also</title>
173     <para>Nothing yet</para>
174     </refsect1>
175    
176     <refsect1>
177     <title>Website</title>
178    
179     <simplelist type="vert">
180     <member>
181     <ulink url="http://www.i-scream.org">http://www.i-scream.org</ulink>
182     </member>
183     </simplelist>
184     </refsect1>
185    
186     </refentry>