From 81fea73e79f104efcb9f5207a7f4af2f59f7c6af Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:38:50 -0500 Subject: [PATCH 1/8] Move MEMORY_MODE enum inside include guard. --- common/memory.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/memory.h b/common/memory.h index cefbf82..e71dc99 100644 --- a/common/memory.h +++ b/common/memory.h @@ -16,6 +16,11 @@ * limitations under the License. */ +#ifndef MEMORY_H_ +#define MEMORY_H_ + +#include + enum { MEMORY_MODE_DEFAULT, @@ -23,11 +28,6 @@ enum MEMORY_MODE_USAGE_PERCENTAGE }; -#ifndef MEMORY_H_ -#define MEMORY_H_ - -#include - std::string mem_string( bool, int ); #endif From c5f369ae00be0bbf4ae2be8ab68e957a0915f170 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:41:36 -0500 Subject: [PATCH 2/8] Fix trailing whitespace in linux/memory.cc. --- linux/memory.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux/memory.cc b/linux/memory.cc index 7ccd406..2d76978 100644 --- a/linux/memory.cc +++ b/linux/memory.cc @@ -38,12 +38,12 @@ std::string mem_string( bool use_colors = false, int mode = 0 ) unsigned int total_mem, used_mem; - /* Since linux uses some RAM for disk caching, the actuall used ram is lower - * than what sysinfo(), top or free reports. htop reports the usage in a + /* Since linux uses some RAM for disk caching, the actuall used ram is lower + * than what sysinfo(), top or free reports. htop reports the usage in a * correct way. The memory used for caching doesn't count as used, since it * can be freed in any moment. Usually it hapens automatically, when an * application requests memory. - * In order to calculate the ram that's actually used we need to use the + * In order to calculate the ram that's actually used we need to use the * following formula: * total_ram - free_ram - buffered_ram - cached_ram * @@ -89,10 +89,10 @@ std::string mem_string( bool use_colors = false, int mode = 0 ) oss << mem_lut[(100 * used_mem) / total_mem]; } - // we want megabytes on output, but since the values already come as + // we want megabytes on output, but since the values already come as // kilobytes we need to divide them by 1024 only once, thus we use // KILOBYTES - oss << convert_unit(used_mem, MEGABYTES, KILOBYTES) << '/' + oss << convert_unit(used_mem, MEGABYTES, KILOBYTES) << '/' << convert_unit(total_mem, MEGABYTES, KILOBYTES) << "MB"; if( use_colors ) From 4fd854ce16ae61bf4a5a8ff1958d9642f620b485 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:47:13 -0500 Subject: [PATCH 3/8] Give the MEMORY_MODE enum a name. This improves readability. Also, set the default value in one place in the declaration. --- common/main.cc | 4 ++-- common/memory.h | 5 +++-- freebsd/memory.cc | 2 +- linux/memory.cc | 2 +- netbsd/memory.cc | 2 +- openbsd/memory.cc | 2 +- osx/memory.cc | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/main.cc b/common/main.cc index d111ee0..24c64e1 100644 --- a/common/main.cc +++ b/common/main.cc @@ -93,7 +93,7 @@ int main( int argc, char** argv ) unsigned cpu_usage_delay = 990000; short graph_lines = 10; // max 32767 should be enough bool use_colors = false; - int mem_mode = MEMORY_MODE_DEFAULT; + MEMORY_MODE mem_mode = MEMORY_MODE_DEFAULT; static struct option long_options[] = { @@ -143,7 +143,7 @@ int main( int argc, char** argv ) std::cerr << "Memory mode argument must be zero or greater.\n"; return EXIT_FAILURE; } - mem_mode = atoi( optarg ); + mem_mode = static_cast< MEMORY_MODE >( atoi( optarg ) ); break; case '?': // getopt_long prints error message automatically diff --git a/common/memory.h b/common/memory.h index e71dc99..e3d6164 100644 --- a/common/memory.h +++ b/common/memory.h @@ -21,13 +21,14 @@ #include -enum +enum MEMORY_MODE { MEMORY_MODE_DEFAULT, MEMORY_MODE_FREE_MEMORY, MEMORY_MODE_USAGE_PERCENTAGE }; -std::string mem_string( bool, int ); +std::string mem_string( bool, + MEMORY_MODE mode = MEMORY_MODE_DEFAULT ); #endif diff --git a/freebsd/memory.cc b/freebsd/memory.cc index 64f84d2..41ca9aa 100644 --- a/freebsd/memory.cc +++ b/freebsd/memory.cc @@ -29,7 +29,7 @@ #include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors = false, int mode = 0 ) +std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) { // These values are in bytes //u_int total; diff --git a/linux/memory.cc b/linux/memory.cc index 2d76978..dfd4f4e 100644 --- a/linux/memory.cc +++ b/linux/memory.cc @@ -24,7 +24,7 @@ #include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors = false, int mode = 0 ) +std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) { using std::string; using std::ifstream; diff --git a/netbsd/memory.cc b/netbsd/memory.cc index 08444a3..40c291f 100644 --- a/netbsd/memory.cc +++ b/netbsd/memory.cc @@ -28,7 +28,7 @@ #include "conversions.h" #include "memory.h" -std::string mem_string( bool use_colors = false, int mode = 0 ) +std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) { std::ostringstream oss; diff --git a/openbsd/memory.cc b/openbsd/memory.cc index c94eb5e..7e521b2 100644 --- a/openbsd/memory.cc +++ b/openbsd/memory.cc @@ -47,7 +47,7 @@ static int pageshift; #endif #define pagesh(size) ((size) << pageshift) -std::string mem_string( bool use_colors = false, int mode = 0 ) +std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) { std::ostringstream oss; diff --git a/osx/memory.cc b/osx/memory.cc index 15498d6..3f20506 100644 --- a/osx/memory.cc +++ b/osx/memory.cc @@ -25,7 +25,7 @@ #include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors, int mode ) +std::string mem_string( bool use_colors, MEMORY_MODE mode ) { std::ostringstream oss; From 7eef3670e0a9a37883d7947e8e71be719336004e Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:48:37 -0500 Subject: [PATCH 4/8] Fix whitespace in osx/memory.cc. --- osx/memory.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osx/memory.cc b/osx/memory.cc index 3f20506..ba8761b 100644 --- a/osx/memory.cc +++ b/osx/memory.cc @@ -48,8 +48,8 @@ std::string mem_string( bool use_colors, MEMORY_MODE mode ) mach_port_t mach_port = mach_host_self(); mach_msg_type_number_t count = sizeof( vm_stats ) / sizeof( natural_t ); if( KERN_SUCCESS == host_page_size( mach_port, &page_size ) && - KERN_SUCCESS == host_statistics( mach_port, HOST_VM_INFO, - ( host_info_t )&vm_stats, &count ) + KERN_SUCCESS == host_statistics( mach_port, HOST_VM_INFO, + ( host_info_t )&vm_stats, &count ) ) { //unused_mem = static_cast( vm_stats.free_count * page_size ); @@ -77,22 +77,22 @@ std::string mem_string( bool use_colors, MEMORY_MODE mode ) if( free_mem_in_gigabytes < 1 ) { oss << convert_unit( free_mem, MEGABYTES ) << "MB"; - } - else + } + else { oss << free_mem_in_gigabytes << "GB"; } break; case MEMORY_MODE_USAGE_PERCENTAGE: // Calculate the percentage of used memory - percentage_mem = used_mem / + percentage_mem = used_mem / static_cast( total_mem ) * 100.0; oss << percentage_mem << '%'; break; - default: // Default mode, just show the used/total memory in MB - oss << convert_unit( used_mem, MEGABYTES ) << '/' - << convert_unit( total_mem, MEGABYTES ) << "MB"; + default: // Default mode, just show the used/total memory in MB + oss << convert_unit( used_mem, MEGABYTES ) << '/' + << convert_unit( total_mem, MEGABYTES ) << "MB"; } if( use_colors ) From e50d34873f8b9a693d16e05870de476b50450203 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:54:09 -0500 Subject: [PATCH 5/8] Add header guard to conversions.h --- common/conversions.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/conversions.h b/common/conversions.h index ac18bc3..c895690 100644 --- a/common/conversions.h +++ b/common/conversions.h @@ -16,6 +16,9 @@ * limitations under the License. */ +#ifndef CONVERSIONS_H_ +#define CONVERSIONS_H_ + enum { BYTES = 0, @@ -33,3 +36,5 @@ inline T convert_unit( T num, int to, int from = BYTES) } return num; } + +#endif From fb8e3c6ad0e39c31afe481411814d98acb53db42 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 16:59:39 -0500 Subject: [PATCH 6/8] Add .gitattributes to check whitespace errors. --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1f9bc28 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.cc whitespace=tab-in-indent,no-lf-at-eof,trailing-whitespace +*.h whitespace=tab-in-indent,no-lf-at-eof,trailing-whitespace +*.rst whitespace=tab-in-indent,no-lf-at-eof,trailing-whitespace +*.txt whitespace=tab-in-indent,no-lf-at-eof,trailing-whitespace From 42275e094d65afe36402dec234398b413e79299c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 10 Feb 2016 17:22:34 -0500 Subject: [PATCH 7/8] Memory mode output for platforms other than osx. Refactor status string generation into a common function. --- CMakeLists.txt | 2 +- common/main.cc | 4 ++- common/memory.cc | 78 +++++++++++++++++++++++++++++++++++++++++++++++ common/memory.h | 24 +++++++++++++-- freebsd/memory.cc | 20 ++---------- linux/memory.cc | 35 ++++++--------------- netbsd/memory.cc | 24 +++------------ openbsd/memory.cc | 21 ++----------- osx/memory.cc | 50 ++---------------------------- 9 files changed, 126 insertions(+), 132 deletions(-) create mode 100644 common/memory.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c2aafc..9109314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ else() endif() # set common source files -set(COMMON_SOURCES "common/main.cc" "common/graph.cc") +set(COMMON_SOURCES "common/main.cc" "common/memory.cc" "common/graph.cc") # add binary tree so we find version.h include_directories("${PROJECT_BINARY_DIR}") diff --git a/common/main.cc b/common/main.cc index 24c64e1..a4a7b3a 100644 --- a/common/main.cc +++ b/common/main.cc @@ -163,7 +163,9 @@ int main( int argc, char** argv ) return EXIT_FAILURE; } - std::cout << mem_string( use_colors, mem_mode ) + MemoryStatus memory_status; + mem_status( memory_status ); + std::cout << mem_string( memory_status, mem_mode, use_colors ) << cpu_string( cpu_usage_delay, graph_lines, use_colors ) << load_string( use_colors ); diff --git a/common/memory.cc b/common/memory.cc new file mode 100644 index 0000000..23a4ea5 --- /dev/null +++ b/common/memory.cc @@ -0,0 +1,78 @@ +/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap + * + * Copyright 2012 Matthew McCormick + * Copyright 2015 Pawel 'l0ner' Soltys + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "memory.h" +#include "luts.h" +#include "conversions.h" + +std::string mem_string( const MemoryStatus & mem_status, + MEMORY_MODE mode, + bool use_colors ) +{ + std::ostringstream oss; + // Change the percision for floats, for a pretty output + oss.precision( 2 ); + oss.setf( std::ios::fixed | std::ios::right ); + + if( use_colors ) + { + oss << mem_lut[static_cast< unsigned int >((100 * mem_status.used_mem) / mem_status.total_mem)]; + } + + switch( mode ) + { + case MEMORY_MODE_FREE_MEMORY: // Show free memory in MB or GB + { + const float free_mem = mem_status.total_mem - mem_status.used_mem; + const float free_mem_in_gigabytes = convert_unit( free_mem, GIGABYTES, MEGABYTES ); + + // if free memory is less than 1 GB, use MB instead + if( free_mem_in_gigabytes < 1.0f ) + { + oss << free_mem << "MB"; + } + else + { + oss << free_mem_in_gigabytes << "GB"; + } + break; + } + case MEMORY_MODE_USAGE_PERCENTAGE: + { + // Calculate the percentage of used memory + const float percentage_mem = mem_status.used_mem / + static_cast( mem_status.total_mem ) * 100.0; + + oss << percentage_mem << '%'; + break; + } + default: // Default mode, just show the used/total memory in MB + oss << static_cast< unsigned int >( mem_status.used_mem ) << '/' + << static_cast< unsigned int >( mem_status.used_mem ) << "MB"; + } + + if( use_colors ) + { + oss << "#[fg=default,bg=default]"; + } + + return oss.str(); +} + diff --git a/common/memory.h b/common/memory.h index e3d6164..8fac41a 100644 --- a/common/memory.h +++ b/common/memory.h @@ -21,6 +21,25 @@ #include +/** Memory status in megabytes */ +struct MemoryStatus +{ + float used_mem; + float total_mem; +}; + +/** Get the current memory status */ +void mem_status( MemoryStatus & status ); + + +/** Memory status string output mode. + * + * Examples: + * + * MEMORY_MODE_DEFAULT: 11156/16003MB + * MEMORY_MODE_FREE_MEMORY: + * MEMORY_MODE_USAGE_PERCENTAGE: + */ enum MEMORY_MODE { MEMORY_MODE_DEFAULT, @@ -28,7 +47,8 @@ enum MEMORY_MODE MEMORY_MODE_USAGE_PERCENTAGE }; -std::string mem_string( bool, - MEMORY_MODE mode = MEMORY_MODE_DEFAULT ); +std::string mem_string( const MemoryStatus & mem_status, + MEMORY_MODE mode = MEMORY_MODE_DEFAULT, + bool use_colors = false ); #endif diff --git a/freebsd/memory.cc b/freebsd/memory.cc index 41ca9aa..5500032 100644 --- a/freebsd/memory.cc +++ b/freebsd/memory.cc @@ -26,10 +26,9 @@ #include "getsysctl.h" #include "memory.h" -#include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) +void mem_status( MemoryStatus & status ) { // These values are in bytes //u_int total; @@ -40,7 +39,6 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) u_int active; u_int page_size; u_int page_count; - std::ostringstream oss; // Get total physical memory, page size, and some other needed info // instead of using realmem which reports quantity of ram installed on @@ -67,18 +65,6 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) // Used memory on FreeBSD is active + wired. u_int used = ( active + wired ) * page_size; - if( use_colors ) - { - oss << mem_lut[ ( 100 * used ) / ( page_count * page_size ) ]; - } - - oss << convert_unit( used, MEGABYTES ) << '/' - << convert_unit( page_count * (page_size >> 10), MEGABYTES, KILOBYTES) << "MB"; - - if( use_colors ) - { - oss << "#[fg=default,bg=default]"; - } - - return oss.str(); + status.used_mem = convert_unit( static_cast< float >( used ), MEGABYTES ); + status.total_mem = convert_unit( static_cast< float >( page_count * (page_size >> 10) ), MEGABYTES, KILOBYTES); } diff --git a/linux/memory.cc b/linux/memory.cc index dfd4f4e..f6ac406 100644 --- a/linux/memory.cc +++ b/linux/memory.cc @@ -21,22 +21,17 @@ #include #include "memory.h" -#include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) +void mem_status( MemoryStatus & status ) { - using std::string; - using std::ifstream; - using std::stoi; - - std::ostringstream oss; - - string line, substr; + std::string line; + std::string substr; size_t substr_start; size_t substr_len; - unsigned int total_mem, used_mem; + unsigned int total_mem; + unsigned int used_mem; /* Since linux uses some RAM for disk caching, the actuall used ram is lower * than what sysinfo(), top or free reports. htop reports the usage in a @@ -59,9 +54,9 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) * SwapFree: 60352 kB old */ - ifstream memory_info("/proc/meminfo"); + std::ifstream memory_info("/proc/meminfo"); - while( getline( memory_info, line ) ) + while( std::getline( memory_info, line ) ) { substr_start = 0; substr_len = line.find_first_of( ':' ); @@ -84,22 +79,10 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) } } - if( use_colors ) - { - oss << mem_lut[(100 * used_mem) / total_mem]; - } - // we want megabytes on output, but since the values already come as // kilobytes we need to divide them by 1024 only once, thus we use // KILOBYTES - oss << convert_unit(used_mem, MEGABYTES, KILOBYTES) << '/' - << convert_unit(total_mem, MEGABYTES, KILOBYTES) << "MB"; - - if( use_colors ) - { - oss << "#[fg=default,bg=default]"; - } - - return oss.str(); + status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES, KILOBYTES); + status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES, KILOBYTES); } diff --git a/netbsd/memory.cc b/netbsd/memory.cc index 40c291f..d064583 100644 --- a/netbsd/memory.cc +++ b/netbsd/memory.cc @@ -24,14 +24,11 @@ #include // uvmexp struct #include "error.h" -#include "luts.h" #include "conversions.h" #include "memory.h" -std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) +void mem_status( MemoryStatus & status ) { - std::ostringstream oss; - // get vm memory stats static int vm_totalmem[] = { CTL_VM, VM_UVMEXP2 }; struct uvmexp_sysctl mem; @@ -42,23 +39,10 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) } int64_t total_mem = ( mem.npages << mem.pageshift ); - int64_t used_mem = + int64_t used_mem = ( mem.active + mem.wired - mem.filepages ) << mem.pageshift; - if( use_colors ) - { - oss << mem_lut[( 100 * used_mem ) / total_mem]; - } - // add 1 to used which gets lost somewhere along conversions - oss << convert_unit( used_mem, MEGABYTES ) - << '/' << convert_unit( total_mem, MEGABYTES ) << "MB"; - - if( use_colors ) - { - oss << "#[fg=default,bg=default]"; - } - - return oss.str(); - + status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES ); + status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES ); } diff --git a/openbsd/memory.cc b/openbsd/memory.cc index 7e521b2..709e228 100644 --- a/openbsd/memory.cc +++ b/openbsd/memory.cc @@ -37,7 +37,6 @@ #include "error.h" #include "memory.h" -#include "luts.h" #include "conversions.h" static int pageshift; @@ -47,10 +46,8 @@ static int pageshift; #endif #define pagesh(size) ((size) << pageshift) -std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) +void mem_status( MemoryStatus & status ) { - std::ostringstream oss; - // These values are in bytes int64_t total_mem = 0; int64_t used_mem = 0; @@ -106,18 +103,6 @@ std::string mem_string( bool use_colors = false, MEMORY_MODE mode ) // calculate total memory total_mem = (uint64_t) pagesh( uvmexp.npages ) << LOG1024; - if( use_colors ) - { - oss << mem_lut[( 100 * used_mem ) / total_mem]; - } - - oss << convert_unit( used_mem, MEGABYTES ) - << '/' << convert_unit( total_mem, MEGABYTES ) << "MB"; - - if( use_colors ) - { - oss << "#[fg=default,bg=default]"; - } - - return oss.str(); + status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES ); + status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES ); } diff --git a/osx/memory.cc b/osx/memory.cc index ba8761b..fb61f60 100644 --- a/osx/memory.cc +++ b/osx/memory.cc @@ -22,13 +22,10 @@ #include // for sysctl #include "memory.h" -#include "luts.h" #include "conversions.h" -std::string mem_string( bool use_colors, MEMORY_MODE mode ) +void mem_status( MemoryStatus & status ) { - std::ostringstream oss; - // These values are in bytes u_int64_t total_mem; float used_mem; @@ -58,47 +55,6 @@ std::string mem_string( bool use_colors, MEMORY_MODE mode ) ( vm_stats.active_count + vm_stats.wire_count ) * page_size); } - if( use_colors ) - { - oss << mem_lut[( 100 * static_cast(used_mem) ) / total_mem]; - } - - // Change the percision for floats, for a pretty output - oss.precision( 2 ); - oss.setf( std::ios::fixed | std::ios::right ); - - switch( mode ) - { - case MEMORY_MODE_FREE_MEMORY: // Show free memory in MB or GB - free_mem = total_mem - used_mem; - free_mem_in_gigabytes = convert_unit( free_mem, GIGABYTES ); - - // if free memory is less than 1 GB, use MB instead - if( free_mem_in_gigabytes < 1 ) - { - oss << convert_unit( free_mem, MEGABYTES ) << "MB"; - } - else - { - oss << free_mem_in_gigabytes << "GB"; - } - break; - case MEMORY_MODE_USAGE_PERCENTAGE: - // Calculate the percentage of used memory - percentage_mem = used_mem / - static_cast( total_mem ) * 100.0; - - oss << percentage_mem << '%'; - break; - default: // Default mode, just show the used/total memory in MB - oss << convert_unit( used_mem, MEGABYTES ) << '/' - << convert_unit( total_mem, MEGABYTES ) << "MB"; - } - - if( use_colors ) - { - oss << "#[fg=default,bg=default]"; - } - - return oss.str(); + status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES ); + status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES ); } From 6938941b990e9e2fd78eaa73e55e4eaac1087cdd Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 14 Feb 2016 23:52:56 -0500 Subject: [PATCH 8/8] Add help for memory display mode. --- common/main.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/main.cc b/common/main.cc index a4a7b3a..80ae922 100644 --- a/common/main.cc +++ b/common/main.cc @@ -85,6 +85,8 @@ void print_help() << "\tSet tmux status refresh interval in seconds. Default: 1 second\n" << "-g , --graph-lines \n" << "\tSet how many lines should be drawn in a graph. Default: 10\n" + << "-m , --mem-mode \n" + << "\tSet memory display mode. 0: Default, 1: Free memory, 2: Usage percent.\n" << endl; } @@ -105,6 +107,7 @@ int main( int argc, char** argv ) { "colors", no_argument, NULL, 'c' }, { "interval", required_argument, NULL, 'i' }, { "graph-lines", required_argument, NULL, 'g' }, + { "mem-mode", required_argument, NULL, 'm' }, { 0, 0, 0, 0 } // used to handle unknown long options };