GetMem fixed
This commit is contained in:
parent
0bb1464704
commit
c30ef2f523
@ -186,19 +186,20 @@ int GetMem(const char *title, const FETCH fetch) {
|
|||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
off_t free = 0, total = 0;
|
off_t free = 0, total = 0, cached = 0, buffer = 0, unused = 0;
|
||||||
if (fscanf(fp, "MemTotal: %lu kB\nMemFree: %lu kB", &total, &free) < 0)
|
if (fscanf(fp, "MemTotal: %lu kB\nMemFree: %lu kB\nMemAvailable: %lu kB\nBuffers: %lu kB\nCached: %lu kB", &total, &free, &unused, &buffer, &cached) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
off_t used = (total - (cached + free + buffer)) / 1024;
|
||||||
#ifdef PRINT_USED_AND_TOTAL_MEM
|
#ifdef PRINT_USED_AND_TOTAL_MEM
|
||||||
printf("%s%s%s%lumb / %lumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - free) / 1024, (uintmax_t)total / 1024);
|
printf("%s%s%s%lumb / %lumb", fetch.color, title, fetch.font_color, (uintmax_t)used, (uintmax_t)total / 1024);
|
||||||
|
|
||||||
#elif PRINT_TOTALMEM
|
#elif PRINT_TOTALMEM
|
||||||
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)total / 1024);
|
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)total / 1024);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - free) / 1024);
|
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)used);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user