From d83d5e302d4d9d0e6fc46de2e01ee888bddbac3b Mon Sep 17 00:00:00 2001 From: "Matt McCormick (thewtex)" Date: Wed, 24 Feb 2010 23:49:36 -0600 Subject: [PATCH] Add load average. --- tmux-mem-cpu-load.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tmux-mem-cpu-load.cpp b/tmux-mem-cpu-load.cpp index d12ef9c..928daf4 100644 --- a/tmux-mem-cpu-load.cpp +++ b/tmux-mem-cpu-load.cpp @@ -131,11 +131,21 @@ string mem_string() return oss.str(); } +string load_string() +{ + ifstream loadavg_file( "/proc/loadavg" ); + string load_line; + getline( loadavg_file, load_line ); + loadavg_file.close(); + + return load_line.substr( 0, 14 ); +} + int main(int argc, char** argv) { try { - std::cout << mem_string() << ' ' << cpu_string(); + std::cout << mem_string() << ' ' << cpu_string() << ' ' << load_string(); } catch(const exception &e) {