Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
SUSE:SLE-12-SP1:GA
procps.31624
procps.git-ba6396f886f1a9911221e1c7c4b66dc75acb...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File procps.git-ba6396f886f1a9911221e1c7c4b66dc75acb6948.patch of Package procps.31624
Based on ba6396f886f1a9911221e1c7c4b66dc75acb6948 Mon Sep 17 00:00:00 2001 From: Jaromir Capik <jcapik@redhat.com> Date: Fri, 11 Jul 2014 22:34:06 +0200 Subject: [PATCH] free: support for MemAvailable This commit adds a new switch -a/--available that appends a new column called 'available' to the output. The column displays an estimation of how much memory is available for starting new applications, without swapping. Unlike the data provided by the 'cached' or 'free' fields, this field takes into account page cache and also that not all reclaimable memory slabs will be reclaimed due to items being in use. --- free.1 | 12 ++++++++++++ free.c | 13 +++++++++++-- proc/libprocps.sym | 1 + proc/sysinfo.c | 2 ++ proc/sysinfo.h | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) --- free.1 +++ free.1 2019-10-15 10:53:50.870189727 +0000 @@ -33,6 +33,14 @@ Memory used by kernel buffers (Buffers i .TP \fBcached\fR Memory used by the page cache (Cached in /proc/meminfo) +.TP +\fBavailable\fR +Estimation of how much memory is available for starting +new applications, without swapping. Unlike the data +provided by the \fBcached\fR or \fBfree\fR fields, +this field takes into account page cache and also that +not all reclaimable memory slabs will be reclaimed +due to items being in use (MemAvailable in /proc/meminfo) .SH OPTIONS .TP \fB\-b\fR, \fB\-\-bytes\fR @@ -65,6 +73,10 @@ display the units of print out. Followi If unit is missing, and you have petabyte of RAM or swap, the number is in terabytes and columns might not be aligned with header. .TP +\fB\-a\fR, \fB\-\-available\fR +Display the estimation of memory available for starting new applications, +without swapping. This switch makes the output wider than 80 characters. +.TP \fB\-c\fR, \fB\-\-count\fR \fIcount\fR Display the result .I count --- free.c +++ free.c 2019-10-15 10:53:50.870189727 +0000 @@ -54,6 +54,7 @@ #define FREE_SI (1 << 5) #define FREE_REPEAT (1 << 6) #define FREE_REPEATCOUNT (1 << 7) +#define FREE_AVAILABLE (1 << 8) struct commandline_arguments { int exponent; /* demanded in kilos, magas... */ @@ -85,6 +86,7 @@ static void __attribute__ ((__noreturn__ fputs(_(" -t, --total show total for RAM + swap\n"), out); fputs(_(" -s N, --seconds N repeat printing every N seconds\n"), out); fputs(_(" -c N, --count N repeat printing N times, then exit\n"), out); + fputs(_(" -a, --available show available memory\n"), out); fputs(USAGE_SEPARATOR, out); fputs(_(" --help display this help and exit\n"), out); fputs(USAGE_VERSION, out); @@ -214,6 +216,7 @@ int main(int argc, char **argv) { "total", no_argument, NULL, 't' }, { "seconds", required_argument, NULL, 's' }, { "count", required_argument, NULL, 'c' }, + { "available", no_argument, NULL, 'a' }, { "help", no_argument, NULL, HELP_OPTION }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } @@ -234,7 +237,7 @@ int main(int argc, char **argv) atexit(close_stdout); errno = errsv; - while ((c = getopt_long(argc, argv, "bkmghlotc:s:V", longopts, NULL)) != -1) + while ((c = getopt_long(argc, argv, "bkmghlotc:as:V", longopts, NULL)) != -1) switch (c) { case 'b': args.exponent = 1; @@ -287,6 +290,9 @@ int main(int argc, char **argv) error(EXIT_FAILURE, ERANGE, _("failed to parse count argument: '%s'"), optarg); break; + case 'a': + flags |= FREE_AVAILABLE; + break; case HELP_OPTION: usage(stdout); case 'V': @@ -302,7 +308,9 @@ int main(int argc, char **argv) /* Translation Hint: You can use 9 character words in * the header, and the words need to be right align to * beginning of a number. */ - printf("%s\n", _(" total used free shared buffers cached")); + printf(_(" total used free shared buffers cached")); + if (flags & FREE_AVAILABLE) printf(_(" available")); + printf("\n"); printf("%-7s", _("Mem:")); printf(" %10s", scale_size(kb_main_total, flags, args)); printf(" %10s", scale_size(kb_main_used, flags, args)); @@ -310,6 +318,7 @@ int main(int argc, char **argv) printf(" %10s", scale_size(kb_main_shared, flags, args)); printf(" %10s", scale_size(kb_main_buffers, flags, args)); printf(" %10s", scale_size(kb_main_cached, flags, args)); + if (flags & FREE_AVAILABLE) printf(" %10s", scale_size(kb_main_available, flags, args)); printf("\n"); /* * Print low vs. high information, if the user requested it. --- proc/libprocps.sym +++ proc/libprocps.sym 2019-10-15 10:53:50.870189727 +0000 @@ -27,6 +27,7 @@ global: kb_inactive; kb_low_free; kb_low_total; + kb_main_available; kb_main_buffers; kb_main_cached; kb_main_free; --- proc/sysinfo.c +++ proc/sysinfo.c 2019-10-15 10:53:50.870189727 +0000 @@ -575,6 +575,7 @@ unsigned long kb_high_free; unsigned long kb_high_total; unsigned long kb_low_free; unsigned long kb_low_total; +unsigned long kb_main_available; /* 2.4.xx era */ unsigned long kb_active; unsigned long kb_inact_laundry; @@ -631,6 +632,7 @@ void meminfo(void){ {"LowFree", &kb_low_free}, {"LowTotal", &kb_low_total}, {"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped + {"MemAvailable", &kb_main_available}, // important {"MemFree", &kb_main_free}, // important {"MemTotal", &kb_main_total}, // important {"NFS_Unstable", &kb_nfs_unstable}, --- proc/sysinfo.h +++ proc/sysinfo.h 2019-10-15 10:53:50.870189727 +0000 @@ -40,6 +40,7 @@ extern unsigned long kb_high_free; extern unsigned long kb_high_total; extern unsigned long kb_low_free; extern unsigned long kb_low_total; +extern unsigned long kb_main_available; /* 2.4.xx era */ extern unsigned long kb_active; extern unsigned long kb_inact_laundry; // grrr...
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor