Commit Graph

341 Commits

Author SHA1 Message Date
Matt McCormick
39dc52f23c Merge pull request #22 from jasperla/openbsd_memory
Switch to using uvmexp which is the prefered way of retrieving memory information
2015-03-01 19:19:39 -05:00
Jasper Lievisse Adriaanse
52540329e5 Switch to using uvmexp which is the prefered way of retrieving memory information
Also fixup some page shifting and casting issues which led to incorrect
amounts of memory being displayed. This also fixes a crash with --colors (#20)
2015-03-01 13:45:31 +01:00
Matt McCormick
e70a16c936 Version bump to 3.2.0. v3.2.0 2015-02-19 22:42:29 -05:00
Matt McCormick
32d9083326 Add NetBSD to the list of supported platforms. 2015-02-19 22:41:53 -05:00
Matt McCormick
ec1959128d Merge pull request #18 from l0ner/devel
Code Refactoring and NetBSD port
2015-02-19 22:39:31 -05:00
Matt McCormick
395ac49e83 Suggest status-left-length 60 in the README.
Addresses #19.
2015-02-19 20:46:17 -05:00
Pawel "l0ner" Soltys
72b8493a59 Code Refactoring and NetBSD support.
* Added NetBSD support.
* removed per-platform header files: all the supported platforms were using
  identical header files for cpu, memory and load (except a few differences).
  Since this was unnecessary code duplication I've gathered what was common
  among the platforms, removed duplicates and moved what was left to the
  common/ dir.
* implemented get_cpu_count() function across all platforms. We are using it
  on every platform, yet not on every one this was implemented as a separate
  function.
* removed platform detection through preprocessor from main: we don't need this
  there anymore, since the headers are common for all platforms. CMake will
  handle setting of correct source files for us now.
* Unified used defines for CPU states across all platforms and made linux use
  them. Added some platform detection to cpu.h in order to set them correctly
  across the platforms.
* moved getsysctl.h to common/ dir, since it's used on Net and Free BSD, and
  thus become a common include.
* Unified load_string() across all platforms. Same case as with the header
  files. We can use the same getloadavg() based logic for getting load averages
  on all platforms. *BSD and OS X code was already the pretty much identical.
  Removed duplicated code and made linux adhere to getloadavg() logic.
2015-02-19 21:29:58 +01:00
Pawel "l0ner" Soltys
87cc9b1ce8 Code Refactoring part 2: unified load_string() function on all platforms
All the platforms were using identical logic based on getloadavg() function to
get the load avg stats (except linux, which was using sinfo struct, but can use getloadavg() function). I've noticed this while working on NetBSD port.

Also: fixed a typo on freebsd.
2015-02-19 21:26:35 +01:00
Pawel "l0ner" Soltys
240752d800 Code Refactornig
Since the headers for cpu, memory and load functions are virtually the same for
all platforms, I've decided to move them into common/ dir and do some
refacotring:

* removed per-platform header files
* implemented get_cpu_count() function across all platforms. We are using it cpu
  on every platform, yet not on every one this was implemented as a separate
  function.
* removed platform detection through preprocessor from main: we don't need this
  there anymore, since the headers are common for all platforms. CMake will
  handle setting of correct source files for us now.
* Unified used defines for CPU states across all platforms and made linux use
  them. Added some platform detection to cpu.h in order to set them correctly
  across the platforms.
* moved getsysctl.h to common/ dir, since it's used on Net and Free BSD, and
  thus become a common include.
2015-02-19 19:47:45 +01:00
Pawel "l0ner" Soltys
e8bea10056 Merge branch 'netbsd' into devel 2015-02-19 15:55:46 +01:00
Pawel "l0ner" Soltys
1512a0bda0 NetBSD port.
NetBSD port shares with FreeBSD:
 - load_string()
 - getsysctl()

With OpenBSD:
 - error()
2015-02-16 23:29:27 +01:00
Pawel "l0ner" Soltys
91594b7a5a Use u_long for storing cpu stats instead of detecting architecture
As suggested to me by "Jasper Lievisse Adriaanse" in an email:

On 2015-02-16 09:02 Jasper Lievisse Adriaanse <jasper@openbsd.org> wrote:
> You can actually use 'long' instead of juggling between 64 and 32 bit return
> types. I've impemented something similiar for libgtop years ago and never had
> any issues when using 'long' for both 64 and 32 platforms. Here's the
> refernce: https://git.gnome.org/browse/libgtop/tree/sysdeps/openbsd/cpu.c#n62

This is a better idea than what I've implemented. Also this should resolve
eventual occurrence of "unable to get cpu stats" problem on 64bit platforms we
do not detect.
2015-02-16 18:38:21 +01:00
Matt McCormick
4ca1ab01e4 Version bump to 3.1.0. v3.1.0 2015-02-14 21:23:02 -05:00
Matt McCormick
1481ba09dc Merge pull request #17 from l0ner/freebsd_ramusage
Freebsd ramusage
2015-02-14 21:18:55 -05:00
Pawel "l0ner" Soltys
33d64bc53b OSX: exclude cached memory from used 2015-02-15 01:17:51 +01:00
Matt McCormick
7cb154f267 Merge pull request #15 from l0ner/openbsd_new
OpenBSD port
2015-02-14 17:12:13 -05:00
Pawel "l0ner" Soltys
cf2a094f13 Fix for cpu sysctl failing on 64bit FreeBSD
same as commit  80d70b7a4d5ee9a4ba79deae0e840c65ccaf4131
2015-02-13 19:56:47 +01:00
Pawel "l0ner" Soltys
869d43f102 Fixed RAM usage calculation on FreeBSD
- Instead of displaying hardware ram quantity, display ram available to be
  allocated by applications. FreeBSD uses some ram for kernel, segment mappings
  and other stuff. Those memory pages are not available for allocation by
  applications.
- Calculate correctly ram usage. Active + Wired (buffers). Nothing else.

For more info see:
- http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
- conky source code on github
- output of top and vmstat on FreeBSD
- http://www.zabbix.com/forum/showthread.php?t=21826
- https://support.zabbix.com/browse/ZBXNEXT-774

htop on FreeBSD uses linux procfs compatibility layer, and thus it's readings
are a little off.
2015-02-13 18:46:28 +01:00
Pawel "l0ner" Soltys
80d70b7a4d fix for cpu systctl failing on 64 bit OpenBSD
On 64bit system KERN_CPTIME systctl gets returned as 64bit uint.
On 32bit system it's returned as 32bit uint. This is not documented anywhere
(or maybe I've missed it). I've added preprocessor test for 64bit system.
2015-02-12 20:00:30 +01:00
Pawel "l0ner" Soltys
d21be2b87c openbsd: use unsigned ints to store cpu stats 2015-02-01 17:29:04 +01:00
Pawel "l0ner" Soltys
a727edef8f Openbsd: output error message on error 2015-02-01 17:10:52 +01:00
Pawel "l0ner" Soltys
33eac9d16d openbsd: changed cpu stats errors 2015-02-01 17:09:21 +01:00
Pawel "l0ner" Soltys
ea98710e16 removed messages about experimental *BSD support 2015-01-28 11:32:44 +01:00
Matt McCormick
d07e07ba01 Merge pull request #16 from thewtex/OSX-travis
Also run an OSX Travis build.
2015-01-27 23:04:05 -05:00
Matt McCormick
9dbf8086d4 Also run an OSX Travis build. 2015-01-26 15:57:36 -05:00
Pawel "l0ner" Soltys
c052f58eab Workaround for compilation on OpenBSD 5.6
On OpenBSD 5.6 sys/ucred.h uses NGROUP define, but misses include to
sys/param.h in which NGROUP is defined. sys/ucred.h is included in
sys/mount.h which we need to get the cached ram. Because of this include
chain our compilation will fail with missing NGROUP define. This can be
resolved by including in our code (and in correct order) system headers.
2015-01-26 20:25:00 +01:00
Pawel "l0ner" Soltys
d516985146 fix missing headers on OpenBSD 2015-01-21 13:43:42 +01:00
Pawel "l0ner" Soltys
1ea2fe6d56 Merge branch 'openbsd_new' of github.com:l0ner/tmux-mem-cpu-load into openbsd_new
Conflicts:
	CMakeLists.txt
2015-01-20 15:15:11 +01:00
Pawel "l0ner" Soltys
668a1d97dd suggestion about script that can be used to strip whitespaces 2015-01-20 15:13:39 +01:00
Pawel "l0ner" Soltys
b5a2fcfd34 update readme with supported platforms 2015-01-20 15:11:32 +01:00
Pawel "l0ner" Soltys
69df3a37bf STATUS on OS message detection, consistent spacing 2015-01-20 15:08:47 +01:00
Pawel "l0ner" Soltys
cc8eb47868 remove useless bsd/memory_openbsd.cc 2015-01-20 15:04:14 +01:00
Pawel "l0ner" Soltys
9bd9e79d36 Strip unnecessary whitespaces 2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
3e7ce96903 removed junk, reindentation to adhere to style guidelines 2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
580b076b79 OpenBSD: missing headers, typos
cpu.h: underscores in get_cpu_count()
load.cc: underscores in get_cpu_count(), typos
memory.cc: missing headers
2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
112004f3db FreeBSD and OpenBSD ports
- Removed OpenBSD stuff from freebsd port
- Renamed bsd folder to freebsd since now it contains only
  freebsd-relevant files.
- Changed CMake instructions to account for bsd port changes
- modified main source file to account for openbsd port
2015-01-20 15:03:48 +01:00
Pawel "l0ner" Soltys
8afed01977 Openbsd port. Should work. 2015-01-20 15:02:47 +01:00
Pawel "l0ner" Soltys
243487903a Strip unnecessary whitespaces 2015-01-20 14:50:07 +01:00
Matt McCormick
360ef2e9f2 Version bump to 3.0.0. v3.0.0 2015-01-20 08:11:40 -05:00
Matt McCormick
3e0789b3d3 CMakeLists.txt formatting. 2015-01-20 08:11:20 -05:00
Matt McCormick
68ab061cb4 Rename tmux-mem-cpu-load.cc to main.cc. 2015-01-20 08:05:28 -05:00
Matt McCormick
9498e06ac4 Collect top level code files into common directory.
A little more organized.
2015-01-20 08:04:02 -05:00
Matt McCormick
5132f338fd Merge pull request #14 from thewtex/option-compatibility
Option compatibility
2015-01-20 07:53:48 -05:00
Matt McCormick
040857a4e8 Fix unused expression result warnings on OSX. 2015-01-19 23:28:38 -05:00
Matt McCormick
ea0e620a46 Update the README for new usage. 2015-01-19 23:02:48 -05:00
Matt McCormick
fa4a5b5c2b Print error message to std::cerr. 2015-01-19 23:02:48 -05:00
Matt McCormick
1bfda9484a Detect old option specification fail informatively.
Print the information message to std::cout so it gets printed on the tmux
status line so users of 2.X know how to update their configuration.
2015-01-19 23:02:04 -05:00
Matt McCormick
4c00be77ff Fix trailing whitespace. 2015-01-19 22:17:36 -05:00
Matt McCormick
5cd5a2468b Change tmux-mem-cpu-load extension to .cc for consistency. 2015-01-19 22:16:23 -05:00
Matt McCormick
05d226964a Fix trailing whitespace. 2015-01-19 22:14:36 -05:00