This patch adds two new metrics (kbactive and kbinact) to sar -r.
Also update sar manual page and DTD and XSD documents.
activities.
* Added a new metric (number of tasks waiting for I/O) to
sar -q.
+ * Added two new metrics (amount of active and inactive
+ memory) to sar -r.
* [Ivana Varekova]: Fix segfaults on bogus localtime input.
* Fixed bogus CPU statistics output, which happened when
CPU user value from /proc/stat wasn't incremented whereas
.f_render = render_memory_stats,
.f_xml_print = xml_print_memory_stats,
.hdr_line = "frmpg/s;bufpg/s;campg/s|"
- "kbmemfree;kbmemused;%memused;kbbuffers;kbcached;kbcommit;%commit|"
+ "kbmemfree;kbmemused;%memused;kbbuffers;kbcached;kbcommit;%commit;kbactive;kbinact|"
"kbswpfree;kbswpused;%swpused;kbswpcad;%swpcad",
.name = "A_MEMORY",
#endif
.RS
Percentage of memory needed for current workload in relation to the total amount of memory (RAM+swap).
This number may be greater than 100% because the kernel usually overcommits memory.
+.RE
+.B kbactive
+.RS
+Amount of active memory in kilobytes (memory that has been used more recently
+and usually not reclaimed unless absolutely necessary).
+.RE
+
+.B kbinact
+.RS
+Amount of inactive memory in kilobytes (memory which has been less recently
+used. It is more eligible to be reclaimed for other purposes).
.RE
.RE
.IP -R
*smc = (struct stats_memory *) a->buf[curr],
*smp = (struct stats_memory *) a->buf[prev];
static unsigned long long
- avg_frmkb = 0,
- avg_bufkb = 0,
- avg_camkb = 0,
- avg_comkb = 0;
+ avg_frmkb = 0,
+ avg_bufkb = 0,
+ avg_camkb = 0,
+ avg_comkb = 0,
+ avg_activekb = 0,
+ avg_inactkb = 0;
static unsigned long long
avg_frskb = 0,
avg_tlskb = 0,
if (DISPLAY_MEM_AMT(a->opt_flags)) {
if (dis) {
printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
- " kbcommit %%commit\n", timestamp[!curr]);
+ " kbcommit %%commit kbactive kbinact\n", timestamp[!curr]);
}
if (!dispavg) {
/* Display instantaneous values */
- printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f\n",
+ printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f %9lu %9lu\n",
timestamp[curr],
smc->frmkb,
smc->tlmkb - smc->frmkb,
smc->camkb,
smc->comkb,
(smc->tlmkb + smc->tlskb) ?
- SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0);
+ SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0,
+ smc->activekb,
+ smc->inactkb);
/*
* Will be used to compute the average.
* We assume that the total amount of memory installed can not vary
* during the interval given on the command line.
*/
- avg_frmkb += smc->frmkb;
- avg_bufkb += smc->bufkb;
- avg_camkb += smc->camkb;
- avg_comkb += smc->comkb;
+ avg_frmkb += smc->frmkb;
+ avg_bufkb += smc->bufkb;
+ avg_camkb += smc->camkb;
+ avg_comkb += smc->comkb;
+ avg_activekb += smc->activekb;
+ avg_inactkb += smc->inactkb;
}
else {
/* Display average values */
- printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f\n",
+ printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f %9.0f %9.0f\n",
timestamp[curr],
(double) avg_frmkb / avg_count,
(double) smc->tlmkb - ((double) avg_frmkb / avg_count),
(double) avg_comkb / avg_count,
(smc->tlmkb + smc->tlskb) ?
SP_VALUE(0.0, (double) (avg_comkb / avg_count),
- smc->tlmkb + smc->tlskb) :
- 0.0);
+ smc->tlmkb + smc->tlskb) : 0.0,
+ (double) avg_activekb / avg_count,
+ (double) avg_inactkb / avg_count);
/* Reset average counters */
avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
+ avg_activekb = avg_inactkb = 0;
}
}
/* Read the amount of cached swap in kB */
sscanf(line + 11, "%lu", &st_memory->caskb);
}
+ else if (!strncmp(line, "Active:", 7)) {
+ /* Read the amount of active memory in kB */
+ sscanf(line + 7, "%lu", &st_memory->activekb);
+ }
+ else if (!strncmp(line, "Inactive:", 9)) {
+ /* Read the amount of inactive memory in kB */
+ sscanf(line + 9, "%lu", &st_memory->inactkb);
+ }
else if (!strncmp(line, "SwapTotal:", 10)) {
/* Read the total amount of swap memory in kB */
sscanf(line + 10, "%lu", &st_memory->tlskb);
unsigned long tlskb __attribute__ ((aligned (8)));
unsigned long caskb __attribute__ ((aligned (8)));
unsigned long comkb __attribute__ ((aligned (8)));
+ unsigned long activekb __attribute__ ((aligned (8)));
+ unsigned long inactkb __attribute__ ((aligned (8)));
};
#define STATS_MEMORY_SIZE (sizeof(struct stats_memory))
"-\tkbcommit", NULL, NULL,
smc->comkb, DNOVAL);
- render(isdb, pre, pt_newlin,
+ render(isdb, pre, PT_NOFLAG,
"-\t%%commit", NULL, NULL, NOVAL,
(smc->tlmkb + smc->tlskb) ?
SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
0.0);
+
+ render(isdb, pre, PT_USEINT,
+ "-\tkbactive", NULL, NULL,
+ smc->activekb, DNOVAL);
+
+ render(isdb, pre, PT_USEINT | pt_newlin,
+ "-\tkbinact", NULL, NULL,
+ smc->inactkb, DNOVAL);
}
if (DISPLAY_SWAP(a->opt_flags)) {
<!ELEMENT campg (#PCDATA)>
<!ELEMENT commit (#PCDATA)>
<!ELEMENT commit-percent (#PCDATA)>
+<!ELEMENT active (#PCDATA)>
+<!ELEMENT inactive (#PCDATA)>
<!ELEMENT cpu EMPTY>
<!ATTLIST cpu
number CDATA #REQUIRED
pty-nr CDATA #REQUIRED
>
<!ELEMENT memfree (#PCDATA)>
-<!ELEMENT memory (memfree, memused, memused-percent, buffers, cached, commit, commit-percent, swpfree, swpused, swpused-percent, swpcad, swpcad-percent, frmpg, bufpg, campg)>
+<!ELEMENT memory (memfree, memused, memused-percent, buffers, cached, commit, commit-percent, active, inactive, swpfree, swpused, swpused-percent, swpcad, swpcad-percent, frmpg, bufpg, campg)>
<!ATTLIST memory
per CDATA #REQUIRED
unit CDATA #REQUIRED
<xs:element name="cached" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="commit" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="commit-percent" type="hundredth-type"></xs:element>
+ <xs:element name="active" type="xs:nonNegativeInteger"></xs:element>
+ <xs:element name="inactive" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="swpfree" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="swpused" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="swpused-percent" type="hundredth-type"></xs:element>
xprintf(tab, "<commit>%lu</commit>",
smc->comkb);
- xprintf(tab--, "<commit-percent>%.2f</commit-percent>",
+ xprintf(tab, "<commit-percent>%.2f</commit-percent>",
(smc->tlmkb + smc->tlskb) ?
SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
0.0);
+
+ xprintf(tab, "<active>%lu</active>",
+ smc->activekb);
+
+ xprintf(tab--, "<inactive>%lu</inactive>",
+ smc->inactkb);
}
if (DISPLAY_SWAP(a->opt_flags)) {