]> git.itanic.dy.fi Git - rrdd/commitdiff
Add support for reading swap usage from meminfo
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 17 Sep 2009 19:27:02 +0000 (22:27 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 17 Sep 2009 19:27:02 +0000 (22:27 +0300)
parser.c

index c427ad3d84301ec6ee200072b9674dc97fba6157..24e8fade8938ba639c5b26cbc20958deccf35bad 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -49,7 +49,7 @@ int mem_parser(char *data)
 {
        char buf[1024], word[1024];
        int free = 0, buffered = 0, cache = 0, active = 0, inactive = 0,
-               swapfree = 0, anon = 0, slab = 0, tables = 0;
+               swapfree = 0, anon = 0, slab = 0, tables = 0, swaptotal = 0;
        FILE *file = fopen(MEMFILE, "r");
 
        if (file == NULL) {
@@ -78,11 +78,13 @@ int mem_parser(char *data)
                        slab = dec_to_int(buf, 0);
                } else if (!strcmp(word, "PageTables:")) {
                        tables = dec_to_int(buf, 0);
+               } else if (!strcmp(word, "SwapTotal:")) {
+                       swaptotal = dec_to_int(buf, 0);
                }
        }
        fclose(file);
 
-       sprintf(data, "%f:%f:%f:%f:%f:%f:%f:%f:%f",
+       sprintf(data, "%f:%f:%f:%f:%f:%f:%f:%f:%f:%f",
                free / 1024.0,
                buffered / 1024.0,
                cache / 1024.0,
@@ -91,7 +93,8 @@ int mem_parser(char *data)
                swapfree / 1024.0,
                anon / 1024.0,
                slab / 1024.0,
-               tables / 1024.0);
+               tables / 1024.0,
+               (swaptotal - swapfree) / 1024.0);
 
        return 0;
 }