]> git.itanic.dy.fi Git - rrdd/commitdiff
Add "other" memory counter
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 22 Feb 2012 20:09:33 +0000 (22:09 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 22 Feb 2012 20:09:33 +0000 (22:09 +0200)
The current memory counters taken from proc/meminfo don't add up
taking the entire usable physical memory. There is always a little bit
of memory left out from the equation that doesn't sum up. In some
situations that can be actualyl quite significant. Now this "Other"
memory has its own counter and the total amount of height of the
memory graph stays constant over time.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
database.h
parser.c

index fdf7c398ed71a80e8d1d9a944b239ac737d8e04e..0c171f074c544df0f064d5c5c4defd098a3a1324 100644 (file)
@@ -81,6 +81,7 @@ const char *memtext[] = {
        "DEF:an=" SYSINFO_RRD_PATH ":Anon:AVERAGE",
        "DEF:sl=" SYSINFO_RRD_PATH ":Slab:AVERAGE",
        "DEF:ta=" SYSINFO_RRD_PATH ":Tables:AVERAGE",
+       "DEF:ot=" SYSINFO_RRD_PATH ":Other:AVERAGE",
        "DEF:sw=" SYSINFO_RRD_PATH ":Swap:AVERAGE",
        "COMMENT:\\n",
        blank,
@@ -123,6 +124,12 @@ const char *memtext[] = {
        "GPRINT:ta:AVERAGE:" numfmt,
        "GPRINT:ta:LAST:" numfmt "\\n",
        blank,
+       "STACK:ot#a0a0a0:Other      ",
+       "GPRINT:ot:MIN:" numfmt,
+       "GPRINT:ot:MAX:" numfmt,
+       "GPRINT:ot:AVERAGE:" numfmt,
+       "GPRINT:ot:LAST:" numfmt "\\n",
+       blank,
        "STACK:sw#ff0000:Swap       ",
        "GPRINT:sw:MIN:" numfmt,
        "GPRINT:sw:MAX:" numfmt,
@@ -360,6 +367,7 @@ struct rrd_data_source cpumem_sources[] = {
        SOURCE_ENTRY("Anon",    "GAUGE", 240, 0, 32768)
        SOURCE_ENTRY("Slab",    "GAUGE", 240, 0, 32768)
        SOURCE_ENTRY("Tables",  "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Other",   "GAUGE", 240, 0, 32768)
        SOURCE_ENTRY("Swap",    "GAUGE", 240, 0, 32768)
        {},
 };
index 76ee671eae24d6acb4f032e3402a3c041f51f152..23955e35042e8b0118889f8d8383b1961e63c615 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -49,7 +49,8 @@ int mem_parser(char *data, void *p)
 {
        char buf[1024], word[1024];
        int free = 0, buffered = 0, cache = 0, active = 0, inactive = 0,
-               swapfree = 0, anon = 0, slab = 0, tables = 0, swaptotal = 0;
+               swapfree = 0, anon = 0, slab = 0, tables = 0, other = 0,
+               swaptotal = 0, total = 0;
        FILE *file = fopen(MEMFILE, "r");
 
        if (file == NULL) {
@@ -62,6 +63,8 @@ int mem_parser(char *data, void *p)
                
                if (!strcmp(word, "MemFree:")) {
                        free = dec_to_int(buf, NULL);
+               } else if (!strcmp(word, "MemTotal:")) {
+                       total = dec_to_int(buf, NULL);
                } else if (!strcmp(word, "Buffers:")) {
                        buffered = dec_to_int(buf, NULL);
                } else if (!strcmp(word, "Cached:")) {
@@ -84,7 +87,9 @@ int mem_parser(char *data, void *p)
        }
        fclose(file);
 
-       snprintf(data, RRD_DATA_MAX_LEN, "%f:%f:%f:%f:%f:%f:%f:%f:%f:%f",
+       other = total - free - buffered - cache - anon - slab - tables;
+
+       snprintf(data, RRD_DATA_MAX_LEN, "%f:%f:%f:%f:%f:%f:%f:%f:%f:%f:%f",
                free / 1024.0,
                buffered / 1024.0,
                cache / 1024.0,
@@ -94,6 +99,7 @@ int mem_parser(char *data, void *p)
                anon / 1024.0,
                slab / 1024.0,
                tables / 1024.0,
+               other / 1024.0,
                (swaptotal - swapfree) / 1024.0);
 
        return 0;