]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - bindings.c
Merge pull request #234 from stgraber/master
[mirror_lxcfs.git] / bindings.c
index 885eb64936c9921653f5a66d0d44204698bfedbf..9657160fe485cf70a2248b3f9b8345dc818f76cc 100644 (file)
@@ -2961,23 +2961,23 @@ static void parse_memstat(char *memstat, unsigned long *cached,
        char *eol;
 
        while (*memstat) {
-               if (startswith(memstat, "cache")) {
-                       sscanf(memstat + 5, "%lu", cached);
+               if (startswith(memstat, "total_cache")) {
+                       sscanf(memstat + 11, "%lu", cached);
                        *cached /= 1024;
-               } else if (startswith(memstat, "active_anon")) {
-                       sscanf(memstat + 11, "%lu", active_anon);
+               } else if (startswith(memstat, "total_active_anon")) {
+                       sscanf(memstat + 17, "%lu", active_anon);
                        *active_anon /= 1024;
-               } else if (startswith(memstat, "inactive_anon")) {
-                       sscanf(memstat + 13, "%lu", inactive_anon);
+               } else if (startswith(memstat, "total_inactive_anon")) {
+                       sscanf(memstat + 19, "%lu", inactive_anon);
                        *inactive_anon /= 1024;
-               } else if (startswith(memstat, "active_file")) {
-                       sscanf(memstat + 11, "%lu", active_file);
+               } else if (startswith(memstat, "total_active_file")) {
+                       sscanf(memstat + 17, "%lu", active_file);
                        *active_file /= 1024;
-               } else if (startswith(memstat, "inactive_file")) {
-                       sscanf(memstat + 13, "%lu", inactive_file);
+               } else if (startswith(memstat, "total_inactive_file")) {
+                       sscanf(memstat + 19, "%lu", inactive_file);
                        *inactive_file /= 1024;
-               } else if (startswith(memstat, "unevictable")) {
-                       sscanf(memstat + 11, "%lu", unevictable);
+               } else if (startswith(memstat, "total_unevictable")) {
+                       sscanf(memstat + 17, "%lu", unevictable);
                        *unevictable /= 1024;
                }
                eol = strchr(memstat, '\n');
@@ -3167,7 +3167,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
                        snprintf(lbuf, 100, "MemFree:        %8lu kB\n", memlimit - memusage);
                        printme = lbuf;
                } else if (startswith(line, "MemAvailable:")) {
-                       snprintf(lbuf, 100, "MemAvailable:   %8lu kB\n", memlimit - memusage);
+                       snprintf(lbuf, 100, "MemAvailable:   %8lu kB\n", memlimit - memusage + cached);
                        printme = lbuf;
                } else if (startswith(line, "SwapTotal:") && memswlimit > 0) {
                        sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal);
@@ -3593,24 +3593,6 @@ static uint64_t get_reaper_age(pid_t pid)
        return procage;
 }
 
-static uint64_t get_reaper_btime(pid)
-{
-       int ret;
-       struct sysinfo sys;
-       uint64_t procstart;
-       uint64_t uptime;
-
-       ret = sysinfo(&sys);
-       if (ret < 0) {
-               lxcfs_debug("%s\n", "failed to retrieve system information");
-               return 0;
-       }
-
-       uptime = (uint64_t)time(NULL) - (uint64_t)sys.uptime;
-       procstart = get_reaper_start_time_in_sec(pid);
-       return uptime + procstart;
-}
-
 #define CPUALL_MAX_SIZE (BUF_RESERVE_SIZE / 2)
 static int proc_stat_read(char *buf, size_t size, off_t offset,
                struct fuse_file_info *fi)