Compare commits

...

396 commits

Author SHA1 Message Date
Matt McCormick 640eac3069
Merge pull request #120 from thewtex/dependabot/github_actions/actions/stale-11
Some checks failed
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-armv7l-musl, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-armv7l-musl, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-mips, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-mips, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-ppc64le, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv32, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv32, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-s390x, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-s390x, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64-clang, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64-clang, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-ppc64le, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x86, Release) (push) Has been cancelled
Bump actions/stale from 10 to 11
2026-08-04 15:24:07 -04:00
dependabot[bot] 0b4c5e9894
Bump actions/stale from 10 to 11
Bumps [actions/stale](https://github.com/actions/stale) from 10 to 11.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v10...v11)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: '11'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 04:22:14 +00:00
Matt McCormick 96405e16ea
Merge pull request #118 from arrowd/patch-1
Some checks failed
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-armv7l-musl, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-armv7l-musl, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-mips, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-mips, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-ppc64le, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-ppc64le, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv32, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv32, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-riscv64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-s390x, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-s390x, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64-clang, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x64-clang, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (linux-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux1-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2010-x86, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x64, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x64, Release) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x86, Debug) (push) Has been cancelled
tmux-mem-cpu-load / build ${{ matrix.arch_name }} ${{ matrix.build_type }} (manylinux2014-x86, Release) (push) Has been cancelled
README.rst: Add FreeBSD installation instructions
2026-06-25 15:34:32 -04:00
Gleb Popov ec3448c5c9
README.rst: Add FreeBSD installation instructions 2026-06-25 22:12:39 +03:00
Matt McCormick 606622eb38 Bump version to 3.8.3 2026-06-25 14:37:41 -04:00
Matt McCormick 006b834b9c
Merge pull request #117 from iztanos/codex/fix-load-averages-array
Avoid variable length load average array
2026-06-25 14:36:44 -04:00
Matt McCormick 1922b61f3d
Merge pull request #116 from iztanos/codex/handle-powerline-none
Handle empty powerline direction
2026-06-25 14:36:02 -04:00
Matt McCormick ec284cc78f
Merge pull request #115 from iztanos/codex/major-scout
Use unique release artifact names
2026-06-25 14:35:39 -04:00
Matt McCormick 041d53d7d0
Merge pull request #114 from iztanos/codex/fix-invalid-graph-lines-test
Fix invalid graph-lines test option
2026-06-22 20:27:34 -04:00
itzTanos29 5aa51ed196 Use unique release artifact names 2026-06-22 13:09:35 -04:00
itzTanos29 6b0f365a86 Avoid variable length load average array 2026-06-22 13:06:40 -04:00
itzTanos29 11b856c72d Handle empty powerline direction 2026-06-22 12:46:37 -04:00
itzTanos29 fdcde82be0 Fix graph-lines validation test 2026-06-22 12:26:37 -04:00
Matt McCormick ab991091be
Merge pull request #113 from thewtex/dependabot/github_actions/actions/checkout-7
Bump actions/checkout from 6 to 7
2026-06-19 13:44:51 -04:00
dependabot[bot] b5772c1bfb
Bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-19 04:22:14 +00:00
Matt McCormick df30c399fc
Merge pull request #112 from thewtex/dependabot/github_actions/actions/checkout-6
Bump actions/checkout from 4 to 6
2026-05-13 16:07:41 -04:00
Matt McCormick 90f1845d51
Merge pull request #111 from thewtex/dependabot/github_actions/actions/download-artifact-8
Bump actions/download-artifact from 4 to 8
2026-05-13 16:07:16 -04:00
Matt McCormick 451107b7eb
Merge pull request #110 from thewtex/dependabot/github_actions/actions/stale-10
Bump actions/stale from 9 to 10
2026-05-13 16:07:02 -04:00
Matt McCormick a5662eaca0
Merge pull request #109 from thewtex/dependabot/github_actions/actions/upload-artifact-7
Bump actions/upload-artifact from 4 to 7
2026-05-13 16:06:48 -04:00
dependabot[bot] ef67d00820
Bump actions/checkout from 4 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-30 04:36:36 +00:00
dependabot[bot] 4ecb3f52d8
Bump actions/download-artifact from 4 to 8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-30 04:36:33 +00:00
dependabot[bot] 40d42459f5
Bump actions/stale from 9 to 10
Bumps [actions/stale](https://github.com/actions/stale) from 9 to 10.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v9...v10)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: '10'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-30 04:36:30 +00:00
dependabot[bot] 036e627089
Bump actions/upload-artifact from 4 to 7
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-30 04:36:27 +00:00
Matt McCormick 6549a6cf2f
Merge pull request #108 from jpomykala/patch-1
Update README.rst
2025-05-22 14:46:41 -04:00
Jakub 359a595d73
Update README.rst
Using single quotes breaks the script and it shows just for a one second and disappears.
2025-05-19 22:55:39 +02:00
Matt McCormick 9adf9470c7
Bump version to 3.8.2 2025-04-16 12:13:12 -04:00
Matt McCormick 192e31a62c
Merge pull request #107 from slybart77/memory_report_macos
Fix to report memory usage as Activity Monitor on macOS.
2025-04-16 12:12:18 -04:00
Nicolas Duflot abe531fffb Fix to report memory usage as Activity Monitor on macOS. 2025-04-16 17:05:51 +02:00
Matt McCormick 8d062a7e36
Merge pull request #105 from lljbash/patch-1
fix: build with `cmake --build .` instead of `make`
2025-03-13 14:08:06 -04:00
Lingjie 83820d97a0
fix: build with cmake --build . instead of make 2025-03-13 19:47:41 +08:00
Matt McCormick df71d2123a
Remove TravisCI badge 2024-06-07 15:09:55 -04:00
Matt McCormick 42bf188155 Bump version to 3.8.1 2024-05-22 12:04:44 -04:00
Matt McCormick 93525a5517
Merge pull request #104 from jameshanlon/fix-103
Use stol() for determining Linux memory use
2024-05-22 12:04:07 -04:00
James Hanlon 13160c7e80 Use stol() for determining Linux memory use
To acommodate large memory machines.
2024-05-22 09:23:58 +01:00
Matt McCormick bf0b2721df
Merge pull request #102 from thewtex/dependabot/github_actions/actions/download-artifact-4
Bump actions/download-artifact from 3 to 4
2024-01-06 23:17:20 -05:00
Matt McCormick 06fe4850db
Merge pull request #101 from thewtex/dependabot/github_actions/actions/upload-artifact-4
Bump actions/upload-artifact from 3 to 4
2024-01-06 23:17:13 -05:00
Matt McCormick 9c273230a8
Merge pull request #100 from thewtex/dependabot/github_actions/actions/stale-9
Bump actions/stale from 8 to 9
2024-01-06 23:17:05 -05:00
dependabot[bot] 8d7911abe1
Bump actions/download-artifact from 3 to 4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 04:52:12 +00:00
dependabot[bot] 79804bc3e1
Bump actions/upload-artifact from 3 to 4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 04:52:07 +00:00
dependabot[bot] 9c83be94d4
Bump actions/stale from 8 to 9
Bumps [actions/stale](https://github.com/actions/stale) from 8 to 9.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v8...v9)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 04:40:46 +00:00
Matt McCormick 9a9abc5d13
Merge pull request #99 from thewtex/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-10-19 21:59:45 -04:00
dependabot[bot] 4aa31eb80c
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 04:13:28 +00:00
Matt McCormick 1dcf3f92fb
Merge pull request #97 from rnagy/master
OpenBSD fixes
2023-05-25 21:50:07 -04:00
Robert Nagy 525c6a28b2 cast the return value of get_cpu_count() and fix cpu usage calculation 2023-05-12 17:08:52 +02:00
Robert Nagy 4cf0dad920 use the correct CP_* definitions and number of CPUSTATES on OpenBSD 2023-05-12 17:08:39 +02:00
Matt McCormick 451300eda2 Bump version to 3.8.0 2023-05-12 06:29:08 -04:00
Matt McCormick 8f7027f1fd
Merge pull request #96 from milesfrain/patch-1
Use single quotes for TPM example
2023-05-08 10:29:36 -04:00
Matt McCormick b06c049d0f
Merge pull request #94 from henrypotgieter/improved_segment_adjacency
Improved segment adjacency
2023-05-08 10:29:04 -04:00
milesfrain d1676552dc
Use single quotes for TPM example
This was not working on startup with double quotes.

Issue and fix originally reported here:
https://github.com/thewtex/tmux-mem-cpu-load/issues/53#issuecomment-393083641
2023-05-05 15:44:27 -07:00
henry.potgieter aa8fe65529 Fixed spacing/tabing indent 2023-05-03 23:50:11 -04:00
henry.potgieter ba8489917d Updated usage output from main executable and one other minor change to README.rst 2023-05-03 23:48:20 -04:00
Matt McCormick a991497b9f
Merge pull request #95 from thesamesam/gcc13
Fix build with GCC 13
2023-04-27 14:39:01 -04:00
Sam James 59cca005e4
Fix build with GCC 13
GCC 13 (as usual for new compiler releases) shuffles around some internal includes so some
are no longer transitively included.

See https://gnu.org/software/gcc/gcc-13/porting_to.html.

Bug: https://bugs.gentoo.org/895304
2023-04-18 04:25:00 +01:00
henry.potgieter 35f9618d1f Add additional usage instructions 2023-03-30 23:44:55 -04:00
henry.potgieter 0c9a8d4612 Correct usage output for -r option 2023-03-30 23:31:09 -04:00
henry.potgieter c058ed6f21 Update README.rst 2023-03-30 23:30:45 -04:00
henry.potgieter 6eec6350be Condense lines 2023-03-30 23:24:11 -04:00
henry.potgieter d900b3a546 Merge branch 'nerdfont_graph' into improved_segment_adjacency
Merge vertical graph branch with improved_segment_adjacency branch
2023-03-29 22:39:48 -04:00
Matt McCormick 6d96a8a490 Bump version to 3.7.0 2023-03-27 21:37:42 -04:00
Matt McCormick f08fce0f83
Merge pull request #93 from henrypotgieter/nerdfont_graph
Add option to display CPU graph as vertical bar chart
2023-03-27 21:36:46 -04:00
Matt McCormick 73b7f6c29f
Merge pull request #92 from thewtex/dependabot/github_actions/actions/stale-8
Bump actions/stale from 7 to 8
2023-03-27 21:30:12 -04:00
henry.potgieter 94aed0352c Corrected a character in usage output and updated README.rst 2023-03-27 12:21:36 -04:00
henry.potgieter e232eef156 Change naming from --nerd-graph to --vertical-graph 2023-03-27 11:57:01 -04:00
henry.potgieter f9663c8f2f Add options to allow embedding tmux-mem-cpu-load segments within/beside other segments 2023-03-27 11:11:55 -04:00
henry.potgieter dc298e162a Prepend nerd_graph boolean with use_ so it doesn't look odd 2023-03-26 08:52:59 -04:00
henry.potgieter 6178ba9aa3 Add option to display CPU graph as vertical bar chart 2023-03-25 11:07:55 -04:00
dependabot[bot] 88a219a36d
Bump actions/stale from 7 to 8
Bumps [actions/stale](https://github.com/actions/stale) from 7 to 8.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 05:01:16 +00:00
Matt McCormick 2c3484286e Bump version to 3.6.2 2023-03-20 17:12:07 -04:00
Matt McCormick 5420cf8696
Merge pull request #91 from assistcontrol/master
Increase CPU percent width by 1 (fixes #81)
2023-03-16 20:59:59 -04:00
Adam Weinberger 2b19ca8a0a Increase CPU percent width by 1 (fixes #81)
CPU percent width is 5, which accommodates the maximum possible width
(100.0). When it's at full width, though, the percent string runs right
up against the item before it.

When the graph is enabled, running up against the graph just looks
strange, but still readable ([   |||]100.0%). With the graph disabled
(-g 0) though, it runs into the memory widget, which makes both of them
very difficult to read (11/32GB100%).

This commit adds one space to the CPU percent width. It offsets
a non-pegged load by one, but it ensures there's always at least one
space to separate the widgets.
2023-03-06 15:56:05 -05:00
Matt McCormick b2c6cd43e0 Bump version to 3.6.1 2023-03-05 22:50:52 -05:00
Matt McCormick a5d66aac16
Merge pull request #89 from perfectra1n/master
Fix log messages when attempting to rebuild the plugin, and detect if the binary already exists to trigger rebuild.
2023-03-05 22:50:05 -05:00
Matt McCormick bc279dd2cb
Merge pull request #88 from 0-wiz-0/netbsd
Adapt NetBSD code to signature change.
2023-03-05 21:56:39 -05:00
Matt McCormick 018c03b131
Merge pull request #87 from ngocphamm/patch-1
Update version number to match latest release
2023-03-05 21:56:14 -05:00
perfectra1n b0644d7372 Test to see if the binary already exists. 2023-02-19 21:57:12 -08:00
perfectra1n 626253d791
Fix log messages when attempting to rebuild the plugin.
Fix log messages when attempting to rebuild the plugin, as the previous messages were showing the incorrect output if `cmake` failed, or if `make` failed to execute.
2023-02-19 18:38:46 -08:00
Thomas Klausner 66dfb979b8 Adapt NetBSD code to signature change. 2023-01-19 14:59:30 +01:00
Ngoc Pham adfed692ad
Update version number to match latest release
I guess it wasn't updated for the release of version `3.6.0` back in March.
2022-12-29 23:41:00 -05:00
Matt McCormick 5dccd1801f
Merge pull request #86 from thewtex/dependabot/github_actions/actions/stale-7
Bump actions/stale from 6 to 7
2022-12-22 14:41:51 -05:00
dependabot[bot] 721cb67a80
Bump actions/stale from 6 to 7
Bumps [actions/stale](https://github.com/actions/stale) from 6 to 7.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-21 04:05:50 +00:00
Matt McCormick c158cdd71e
Merge pull request #82 from thewtex/dependabot/github_actions/actions/stale-6
Bump actions/stale from 5 to 6
2022-09-30 16:39:13 -04:00
dependabot[bot] 37220619a2
Bump actions/stale from 5 to 6
Bumps [actions/stale](https://github.com/actions/stale) from 5 to 6.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-22 04:23:31 +00:00
Matt McCormick 171917715d
Merge pull request #76 from thewtex/dependabot/github_actions/actions/upload-artifact-3
Bump actions/upload-artifact from 2 to 3
2022-05-06 22:42:10 -04:00
Matt McCormick 56b71ea699
Merge pull request #77 from thewtex/dependabot/github_actions/actions/download-artifact-3
Bump actions/download-artifact from 2 to 3
2022-05-06 22:42:00 -04:00
Matt McCormick 651b134b09
Merge pull request #78 from thewtex/dependabot/github_actions/actions/stale-5
Bump actions/stale from 4 to 5
2022-05-06 22:41:50 -04:00
dependabot[bot] a449ed042c
Bump actions/stale from 4 to 5
Bumps [actions/stale](https://github.com/actions/stale) from 4 to 5.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 04:21:40 +00:00
dependabot[bot] bc4c0ddbad
Bump actions/download-artifact from 2 to 3
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 04:21:36 +00:00
dependabot[bot] 961351433c
Bump actions/upload-artifact from 2 to 3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 04:21:33 +00:00
Matt McCormick 0b6cd002b3 Update required CMake version in the README 2022-03-07 16:48:05 -05:00
Matt McCormick d87de550f4
Merge pull request #74 from thewtex/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-03 11:23:14 -05:00
Matt McCormick 4de9c077f5
Merge pull request #75 from thewtex/aarch-string
Aarch string
2022-03-03 11:22:19 -05:00
Matt McCormick 974e40bcb5 Disable manylinux2014-aarch64 builds
Odd linker errors:

: && /usr/xcc/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-g++ --sysroot=/usr/xcc/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/sysroot -I /usr/xcc/aarch64-unknown-linux-gnueabi/include/ -std=c++11 -g  CMakeFiles/tmux-mem-cpu-load.dir/common/main.cc.o CMakeFiles/tmux-mem-cpu-load.dir/common/memory.cc.o CMakeFiles/tmux-mem-cpu-load.dir/common/graph.cc.o CMakeFiles/tmux-mem-cpu-load.dir/common/powerline.cc.o CMakeFiles/tmux-mem-cpu-load.dir/linux/memory.cc.o CMakeFiles/tmux-mem-cpu-load.dir/linux/cpu.cc.o CMakeFiles/tmux-mem-cpu-load.dir/common/load.cc.o -o tmux-mem-cpu-load   && :
CMakeFiles/tmux-mem-cpu-load.dir/common/main.cc.o: In function `cpu_string[abi:cxx11](CPU_MODE, unsigned int, unsigned int, bool, bool, bool)':
/work/build-manylinux2014-aarch64/../common/main.cc:47: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
/work/build-manylinux2014-aarch64/../common/main.cc:86: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/build-manylinux2014-aarch64/../common/main.cc:86: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/work/build-manylinux2014-aarch64/../common/main.cc:107: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str() const'
/work/build-manylinux2014-aarch64/../common/main.cc:47: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()'
/work/build-manylinux2014-aarch64/../common/main.cc:86: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/work/build-manylinux2014-aarch64/../common/main.cc:47: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()'
CMakeFiles/tmux-mem-cpu-load.dir/common/main.cc.o: In function `main':
2022-03-03 09:25:18 -05:00
dependabot[bot] 486e618f41
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 04:26:30 +00:00
Matt McCormick f29c4ff5c5 Use standard CMake C++11 enablement 2022-02-17 15:19:02 -05:00
Matt McCormick 8052318680 Undefined references to std::string in aarch64 build 2022-02-17 12:32:51 -05:00
Matt McCormick 0077534b96
Merge pull request #72 from blackheaven/master
More consistent CPU load colors and lower memory usage threshold
2022-02-16 17:16:52 -05:00
Gautier DI FOLCO 1ac6729ef1 Less sensitive memory default thresholds 2021-12-07 23:19:49 +01:00
Gautier DI FOLCO 04419c8cdf Progressive colors for CPU usage 2021-12-07 23:19:09 +01:00
Matt McCormick b6afa5c5e9
Merge pull request #71 from thewtex/freebsd-sig
Consistent get_cpu_count for FreeBSD
2021-08-04 17:43:16 -04:00
Matt McCormick 96ea7dc050 Consistent get_cpu_count for FreeBSD 2021-08-04 15:05:19 -04:00
Matt McCormick 0ca29c4ecd
Merge pull request #69 from thewtex/consistent-precision
consistent precision
2021-08-03 18:43:21 -04:00
Matt McCormick 4be44f35f7 Specify precision in CPU percent output
More consistent formatting.
2021-08-03 18:38:28 -04:00
Matt McCormick 8c2f0e2cfd Use consistent precision for load output
Reduce variations in output.
2021-08-03 18:29:09 -04:00
Matt McCormick 37b08090f1
Merge pull request #68 from thewtex/dependabot/github_actions/actions/stale-4
Bump actions/stale from 3 to 4
2021-08-03 17:36:10 -04:00
Matt McCormick c83d7ee712
DOC: Add GitHub Actions badge to README 2021-08-03 17:35:37 -04:00
dependabot[bot] 8b6e394dd3
Bump actions/stale from 3 to 4
Bumps [actions/stale](https://github.com/actions/stale) from 3 to 4.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-03 21:28:38 +00:00
Matt McCormick 31768a203b
Merge pull request #67 from bensuperpc/multi-arch-ci
Add Github CI and Multi-arch builder
2021-08-03 17:28:14 -04:00
Bensuperpc 9113cefccc Merge branch 'master' into multi-arch-ci 2021-07-07 02:59:23 +02:00
Bensuperpc 39348840c1 Merge branch 'improve_release' 2021-07-07 02:58:35 +02:00
Bensuperpc 3ec357c63c Improve release trigger
Improve release trigger

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:57:38 +02:00
Bensuperpc acea452957 Fix workflow
Fix Release workflow

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:53:42 +02:00
Bensuperpc 705830d1df
Merge pull request #1 from bensuperpc/multi-arch-ci
Multi arch ci
2021-07-07 02:51:17 +02:00
Bensuperpc 8c9c31798c Add Release workflow
Add Release workflow

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:46:40 +02:00
Bensuperpc bf41ae4393 Remove Emscripten
Remove Emscripten

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:38:25 +02:00
Bensuperpc e652a93b72 Add contributor in README
Add contributor in README

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:36:25 +02:00
Bensuperpc db4edaeecc Remove unsupported system
Remove unsupported system

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:30:01 +02:00
Bensuperpc 39c6c57bf3 Add github CI and builder scripts (dockcross)
Add github CI and builder scripts (dockcross)

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-07-07 02:15:22 +02:00
Matt McCormick d5007d4694
Merge pull request #62 from littlewu2508/master
uint32_t get_cpu_count() : support >255 threads
2020-03-05 18:00:15 -05:00
WuYiyang 10ad0b29fd delete the accidentally added header 2020-03-01 09:53:37 +00:00
WuYiyang fc78a0bdad display mem in GB when >100000MB in default mode 2020-03-01 09:44:31 +00:00
WuYiyang d34821cb95 uint32_t get_cpu_count() : support >255 threads 2020-02-23 02:40:10 +00:00
Matt McCormick f96ae7a76a
Merge pull request #61 from fluffykhv/fbsd-mem
Fix calculate memory usage on FreeBSD
2019-12-20 17:25:15 -05:00
Dima Panov e24890652e Fix calculate memory usage on FreeBSD 2019-12-20 02:47:32 +10:00
Matt McCormick 12417dc358
Merge pull request #60 from jasperla/openbsd/ncpuonline
openbsd: use actual number of cpus being used
2019-12-02 16:18:38 -05:00
Jasper Lievisse Adriaanse 2107ea84f1 openbsd: use actual number of cpus being used 2019-12-02 14:06:38 +01:00
Matt McCormick 67657e6312
Merge pull request #58 from tony/patch-1
🙈 Ignore ninja generated files
2019-06-18 18:22:45 -04:00
Tony Narlock 15da3e0a59
🙈 Ignore ninja generated files
Generated when using `cmake -GNinja .`
2019-04-22 13:12:21 -05:00
Matt McCormick 2fdcf93296
Merge pull request #54 from thewtex/windows
Windows
2018-04-23 21:59:20 -04:00
Matt McCormick 7cf58a8367 windows: Initial addition 2018-04-23 21:52:17 -04:00
Matt McCormick 3fad77c3ac Use target_include_directories 2018-04-14 09:47:35 -04:00
Matt McCormick abe7290511
Merge pull request #52 from jmmweismiller/master
Updated used memory calculation.
2018-04-13 23:35:56 -04:00
John Weismiller 22f4db4b0e Updated used memory calculation.
Changed used memory calculation to account for shared memory in accordance with this:
https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716
2018-01-18 13:25:54 -06:00
Matt McCormick 75b9ea756e Merge pull request #49 from qqshfox/patch-1
fix tmux init
2017-04-22 09:37:52 -04:00
Hanfei Shen 26b53ea94b fix tmux init 2017-04-22 20:38:09 +08:00
Matt McCormick 0e227c1e88 Merge pull request #47 from NHDaly/tmux-error-messages
Added error message printing to the tmux plugin.
2016-09-27 21:28:45 -04:00
Nathan Daly 5c37494d11 Added error message printing to the tmux plugin:
Added output error messsages to the tmux plugin file so that if either
cmake or make fail, you can find out why.

For example, if cmake is missing, the output looks like this:

```
'cmake /usr/local/google/home/nhdaly/.tmux/plugins/tmux-mem-cpu-load' failed.
/usr/local/google/home/nhdaly/.tmux/plugins//tmux-mem-cpu-load/tmux-mem-cpu-load.plugin.tmux: line 23: cmake: command not found
```

If there is some error during make, the output looks like this:

```
tmux-mem-cpu-load failed to build.
make: <make output error message>
```
2016-09-27 18:24:13 -05:00
Matt McCormick 35fea56625 Merge pull request #46 from NHDaly/master
Reordered install instructions: moved `tpm` higher && adds nhdaly to Contributions
2016-09-08 22:12:04 -04:00
Nathan Daly 8018a0c761 Reordered install instructions: moved tpm higher.
Since it's the most tmux-native install option, I've moved it higher in
the list of installation options.

Also adds @nhdaly to the Contributions section per @thewtex's suggestion
in
[#43](https://github.com/thewtex/tmux-mem-cpu-load/issues/43#issuecomment-244767735).
2016-09-08 19:36:19 -05:00
Matt McCormick d1f95acada Improve package manager command markup 2016-09-04 15:44:16 -04:00
Matt McCormick 8b1f07ccca Document how to install with package managers 2016-09-04 15:38:49 -04:00
Matt McCormick d7db6d8c8b Merge pull request #44 from NHDaly/master
Added .tmux script so the plugin works with tpm.
2016-09-04 15:22:41 -04:00
Nathan Daly 58564ae6b7 Added .tmux script so the plugin works with tpm.
Now the plugin can be installed via tmux-plugins/tpm in addition to
being installed through zsh's antigen package manager.

It now only calls `make install` when installed through antigen; the
tmux plugin automatically compiles the binary, but leaves it in the
plugin directory.

This also allows skipping the "if exists" check, which means plugin
updates can also automatically rebuild any changes to the compiled part
of the plugin.

Updated the README to reflect this new install option.

This is part of Issue #43.
2016-08-24 11:13:23 -05:00
Matt McCormick 54fdf3c68c Version bump to 3.4.0 2016-08-02 18:51:47 -04:00
Matt McCormick e5595e21f4 Fix memory background color with --powerline-right 2016-08-02 18:48:43 -04:00
Matt McCormick 13c3205ec0 Remove extra spaces with --powerline-right 2016-08-02 18:41:13 -04:00
Matt McCormick 1b11c308ac Remove extra space with --powerline-left 2016-08-01 12:46:31 -04:00
Matt McCormick dcadec63a2 Remove implementation details from --powerline- docs 2016-07-31 22:06:56 -04:00
Matt McCormick 0941898c02 Document --powerline-left 2016-07-31 22:03:18 -04:00
Matt McCormick 1456c16cf8 Test --powerline-left 2016-07-31 21:59:52 -04:00
Matt McCormick 6960e27dc4 Implement --powerline-left 2016-07-31 21:57:56 -04:00
Matt McCormick a26f0ae59d Recognize the documented -p flag 2016-07-28 21:25:58 -04:00
Matt McCormick 18b4ed638a Merge pull request #40 from jodavies/cpu-mode
Cpu mode
2016-06-30 13:11:12 -04:00
jodavies 8af6dc22b8 Update README.rst 2016-06-30 07:56:55 +01:00
Josh Davies b7d2d2a73e Print CPU usage without decimal point if >= 100
Also:
add --colours shortopt to help/readme,
Conform to coding style.
2016-06-27 08:00:09 +01:00
Josh Davies 4a2c4efb9a Added tests for "cpu-mode", short opt --colour
Also fixed (properly) ad83d9b
2016-06-26 14:47:02 +01:00
Josh Davies ad83d9b3a9 Fix: allow -c short option for --color 2016-06-26 14:33:05 +01:00
Josh Davies c623ca889d Added cpu-mode option
Default as before, full load = 100%.
Option 1, full load = 100% * number of cpu threads.
2016-06-26 14:31:34 +01:00
Matt McCormick 3e12a64309 Merge pull request #36 from jasperla/openbsd_mem
Simplify memory calculations on OpenBSD by using uvmexp.pageshift
2016-05-15 07:52:33 -04:00
Matt McCormick 0bc57a9ac8 Tweak description to avoid redundancy.
RAM memory -> RAM.
2016-05-06 09:25:33 -04:00
Matt McCormick ce9de3f9aa Merge pull request #35 from compilenix/master
added averages-count option
2016-05-06 09:24:10 -04:00
Compilenix 710be9e355 Added tests for "averages-count" 2016-05-06 09:03:18 +02:00
Jasper Lievisse Adriaanse 3f647a9b2b Simplify memory calculations on OpenBSD by using uvmexp.pageshift 2016-05-03 20:33:43 +02:00
Compilenix 97a655c856 cleanup 2016-04-28 22:27:19 +02:00
Compilenix cbe3074c6b Update README.rst and AUTHORS 2016-04-28 22:13:05 +02:00
Compilenix 1d1a516eda added averages-count option 2016-04-28 22:05:43 +02:00
Matt McCormick 34b9d39b57 Merge pull request #34 from golinski/master
Adding powerline support
2016-04-14 07:01:33 -04:00
Michał Goliński bac831cd69 Code refactoring for merging
- license header in new files
- changed "powerline" into "powerline-right"
- added braces around one-liners
- small fixes concerning whitespace
2016-04-14 12:30:20 +02:00
golinski e9a3726de7 Change CMakeLists.txt, so it builds on all systems, not only on Linux 2016-03-07 15:14:32 +01:00
Matt McCormick 6e1dbc6b1f Version bump to 3.3.0. 2016-03-06 20:33:34 -05:00
Matt McCormick b8594ecb82 Correct total memory output for the default mode. 2016-03-06 10:57:38 -05:00
Michał Goliński 159051079b Changes in README.rst 2016-03-05 19:34:37 +01:00
Michał Goliński cc59b4952f Powerline support 2016-03-05 11:19:31 +01:00
Matt McCormick 68fd497108 Update README with mem-mode instructions. 2016-02-15 00:02:58 -05:00
Matt McCormick be0b914c49 Merge pull request #32 from thewtex/mem-mode-all-platforms
Mem mode all platforms
2016-02-15 00:00:11 -05:00
Matt McCormick 6938941b99 Add help for memory display mode. 2016-02-14 23:52:56 -05:00
Matt McCormick 42275e094d Memory mode output for platforms other than osx.
Refactor status string generation into a common function.
2016-02-14 23:47:02 -05:00
Matt McCormick fb8e3c6ad0 Add .gitattributes to check whitespace errors. 2016-02-10 16:59:39 -05:00
Matt McCormick e50d34873f Add header guard to conversions.h 2016-02-10 16:54:09 -05:00
Matt McCormick 7eef3670e0 Fix whitespace in osx/memory.cc. 2016-02-10 16:48:37 -05:00
Matt McCormick 4fd854ce16 Give the MEMORY_MODE enum a name.
This improves readability. Also, set the default value in one place in the
declaration.
2016-02-10 16:47:29 -05:00
Matt McCormick c5f369ae00 Fix trailing whitespace in linux/memory.cc. 2016-02-10 16:41:36 -05:00
Matt McCormick 81fea73e79 Move MEMORY_MODE enum inside include guard. 2016-02-10 16:38:50 -05:00
Matt McCormick a6f57340d8 Merge pull request #31 from cousine/master
Added memory modes to show different memory calculations
2016-02-10 16:03:03 -05:00
cousine 635334b141 Adhere to the styling guide, added enum for memory modes, refractored memory mode if block to use switch instead and added test cases for free memory and user percentage memory modes 2016-02-10 22:49:49 +02:00
cousine 0e89998ee4 Add new mode to other platforms and indicate mac only support in README 2016-02-10 17:38:11 +02:00
cousine 1b8fa1ec3a Add new option to the readme 2016-02-10 17:35:15 +02:00
cousine 451aed4530 added memory mode to calculate %, and free memory 2016-02-10 17:32:01 +02:00
Matt McCormick 859c60976a Version bump to 3.2.3. 2016-01-09 17:01:28 -05:00
Matt McCormick cc85854323 Add new contributors to the README. 2016-01-09 17:00:56 -05:00
Matt McCormick 9ad57c906b Merge pull request #30 from tony/freebsd-memory
Fix FreeBSD memory usage
2016-01-09 16:56:53 -05:00
Tony Narlock c036017db3 Fix FreeBSD memory usage
Total memory would go out of bounds for machines ~ > 3.5gB of
memory due to the limit of what u_int can hold.

Use ``getpagesize()`` and bitshift pagesize so it fits.

See also: https://github.com/thewtex/tmux-mem-cpu-load/issues/29
2016-01-09 10:41:28 -06:00
Matt McCormick f80a026c45 Merge pull request #28 from allcatsarebeautiful/master
Allow Easy Installation Via Antigen
2015-09-30 22:27:01 -04:00
Travis Heller 7ca3efacad Merge branch 'master' of https://github.com/allcatsarebeautiful/tmux-mem-cpu-load 2015-09-30 13:03:05 -07:00
Travis Heller e9af4ea2c0 Added License Information 2015-09-30 13:02:36 -07:00
Travis Heller cd0ad5c8ff Why is the markdown formatting not propagating? 2015-09-30 13:00:36 -07:00
Travis Heller ff36892e29 Fixed formatting. 2015-09-30 12:27:29 -07:00
Travis Heller d273cbaf60 RST files don't use Markdown formatting; fixed the link. 2015-09-30 12:25:04 -07:00
Travis Heller e1908ebd13 Why is the markdown formatting not propagating? 2015-09-30 12:16:00 -07:00
Travis Heller 8e6d013c66 Formatting links in .md 2015-09-30 12:11:21 -07:00
Travis Heller ad0a88d1f2 Fixed readme linking error 2015-09-30 12:03:57 -07:00
Travis Heller 7cc6ff35cc Added a check to see if the file has already been installed. 2015-09-30 11:51:53 -07:00
Travis Heller 79e16ec38b Supports Antigen via plugin that builds and installs 2015-09-30 10:57:06 -07:00
Matt McCormick 62c18a0778 Merge pull request #27 from thewtex/circle-ci
Add circle-ci status badge.
2015-07-30 16:08:27 -04:00
Matt McCormick b61503e76a Add circle-ci status badge. 2015-07-30 16:03:52 -04:00
Matt McCormick 557528b946 Merge pull request #25 from jasperla/ws
Don't print trailing whitespace for last element
2015-04-02 09:49:51 -04:00
Matt McCormick 1fe9a33252 Merge branch 'load-whitespace' 2015-04-02 09:42:35 -04:00
Matt McCormick a8367d7f86 Fix color of space preceding the load.
The color preceding of the space preceding the load is
made to be consistent with the load color instead of the default. This is
consistent with the CPU percentage color and easier to read.
2015-04-02 09:37:58 -04:00
Jasper Lievisse Adriaanse 512185a6b3 Don't print trailing whitespace for last element
it's easier to add it in your tmux.conf, then it's to remove it.
2015-04-02 15:35:16 +02:00
Matt McCormick c6d8a19a24 Version bump to 3.2.1. 2015-03-01 19:23:55 -05:00
Matt McCormick 4355f8ffae Add Jasper to contributors. 2015-03-01 19:23:25 -05:00
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. 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. 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  80d70b7a4d
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. 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
Matt McCormick 7e72e47d2c Fix authors name spelling. 2015-01-19 21:59:13 -05:00
Matt McCormick 17dbdfe9ea More consistent spacing in CMakeLists.txt. 2015-01-19 21:54:35 -05:00
Matt McCormick 87a92fa108 Use message(STATUS for OS detection messages.
Changes message output.  Preceeds with "--" for CMake status messages.
2015-01-19 21:50:47 -05:00
Matt McCormick ca82149c10 Merge pull request #13 from l0ner/master
Pull l0ner/master into upstream.
2015-01-19 21:47:04 -05:00
Pawel "l0ner" Soltys 4d6c6760b3 removed junk, reindentation to adhere to style guidelines 2015-01-20 02:57:14 +01:00
Pawel "l0ner" Soltys 3a78f44e39 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 02:44:21 +01:00
Pawel "l0ner" Soltys ae5c71441b 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-19 23:57:53 +01:00
Pawel "l0ner" Soltys 3fd4a21d27 Openbsd port. Should work. 2015-01-19 23:41:51 +01:00
Pawel "l0ner" Soltys e459d40228 note about vim modelines and lower-case in CMake files 2015-01-19 18:01:53 +01:00
Pawel "l0ner" Soltys ec6b1c6cc7 remove leftover argParse.cc reference from CMakeList.txt 2015-01-19 17:55:29 +01:00
Pawel "l0ner" Soltys dd8253e6df added CONTRIBUTING file with instructions for eventual contributors 2015-01-19 17:51:40 +01:00
Pawel "l0ner" Soltys 08bc9b7ecf replaced argParser with getopt_long based one
Solves issue:
28040b61da (commitcomment-9327906)

No GPL2-based code anymore in the codebase.
2015-01-19 17:17:38 +01:00
Pawel "l0ner" Soltys eb338d92c5 rename config.h back to version.h since it contains only version after last commit 2015-01-18 20:04:28 +01:00
Pawel "l0ner" Soltys 2fb24571ef use inline function for unit conversion instead of macros 2015-01-18 20:02:46 +01:00
Pawel "l0ner" Soltys 7c883b924a restore parsing of /proc/meminfo to get memory usage
See issue:
e7f2dd25e8 (commitcomment-9327932)

Unfortunately we can't pull info about cached memory from sysinfo.
Thus we need stick to /proc/meminfo parsing. See code for more comments.
2015-01-18 19:20:55 +01:00
Pawel "l0ner" Soltys ed8ed793bf renamed bsd/common.h to getsysctl.h to better reflect it's function 2015-01-18 17:27:08 +01:00
Pawel "l0ner" Soltys a53bbddef8 added cmake generated config.h file to gitignore 2015-01-18 17:24:17 +01:00
Pawel "l0ner" Soltys d3eb9e3187 use macros from config.h to calculate megabyes
instead of using hard coded divisions to calculate ram stats it's better to use
macros defined in config.h. BSD port was doing this already, using macros
defined in it's common.h header. I pulled those macros out and applied them to
all platforms.
File version.h.in got renamed into config.h.in since it doesn't caontain only
the version anymore.
2015-01-18 17:21:19 +01:00
Pawel "l0ner" Soltys b2084ea3b3 better c++11 detection
2cc9efb187 (commitcomment-9327965)

Instead of checking for compiler version or whether it supports c++ features
through target_compile_features test whether compiler supports one of the c++11
flags (-std=c++11 or -std=c++0x). Cleaner and simplier code. And we can make it
fail loudly if comiler does not support c++11
2015-01-18 16:59:19 +01:00
Pawel "l0ner" Soltys ae4e160ede added test case for graph_lines = 0 2015-01-18 15:07:11 +01:00
Pawel "l0ner" Soltys 89a4b0c048 version defines prefixed with name, full version
now the version variables will be prefixed with 'tmux-mem-cpu-load'. This way we
won't clash with any future dependency that might redefine those variables.
This is exactly how CMake does it in their code, see:

f3e92d2816/Source/CMakeVersion.cmake
6ae98ee18f/Source/cmVersionConfig.h.in
6ae98ee18f/Source/CMakeVersionCompute.cmake

the only difference is that they have functions that return the versions and I
use those variables directly.

6ae98ee18f/Source/cmVersion.cxx

Since the partial version variables are not used anywhere in the code we might
as well remove them from version.h.in. I've deciced to leave them for now, since
we might need them in the future.
2015-01-18 15:04:09 +01:00
Pawel "l0ner" Soltys 51f85ba032 code syntax style, vim modelines, license
* Use std::sting instead of char[] in the graph drawing functions. This is the
  only change to the code. Rest is just styling.
* Corrected whole code to follow Allman/GNU coding style, with 2 spaces for each
  indentation step.
* Added license headers to all code files
* Added vim modelines to all files. They sit on the first line and enable the
  following settings: 2 space indentation, tab expansion to spaces, line at
  80th column, automatic line breaking on "\ !@*+-;:,./?" characters, automatic
  line break if line exceeds 80 colums. This should keep the code nice and tidy.
2015-01-18 14:36:59 +01:00
Pawel "l0ner" Soltys d5506ac797 added myself (l0ner) to contributors list 2015-01-18 14:30:38 +01:00
Pawel "l0ner" Soltys 3f4647a278 added AUTHORS file to store all contributors 2015-01-18 14:27:30 +01:00
Pawel "l0ner" Soltys f2b75f7531 graph.cc: coding style fixes 2015-01-17 23:48:54 +01:00
Pawel "l0ner" Soltys 1cc6b0c9ef CMake style corrections 2015-01-17 23:23:21 +01:00
Pawel "l0ner" Soltys 5fdb0e6227 remove merge leftovers from README 2015-01-17 17:15:01 +01:00
Pawel "l0ner" Soltys acaf9b0b2b fixed typo in CMakeLists.txt 2015-01-17 16:46:33 +01:00
Pawel "l0ner" Soltys 3475328dc4 added note to README about C++11 reqirement 2015-01-17 16:37:45 +01:00
Pawel "l0ner" Soltys 2cc9efb187 added compiler (and it's version) detection
This should fix problems with different flags for c++11 across different gcc
versions. Should compile on Clang and gcc >= 4.6. Lower versions of gcc are
untested. I don't even know wheteher they support c++11 (gcc 4.2.1 on OpenBSD
5.7 does not).
2015-01-17 16:30:31 +01:00
Pawel "l0ner" Soltys 7151b70c70 Fixed typos in linux/load.cc 2015-01-17 16:23:55 +01:00
Pawel "l0ner" Soltys ee39fccc65 Merge remote-tracking branch 'upstream/master'
Conflicts:
	CMakeLists.txt
	README.rst
	tmux-mem-cpu-load.cpp
2015-01-17 16:21:56 +01:00
Pawel "l0ner" Soltys d692eeaf93 added missing include "load.h" 2015-01-12 15:58:31 +01:00
Pawel "l0ner" Soltys f073450edd OSX: removed useless includes 2015-01-12 15:57:41 +01:00
Pawel "l0ner" Soltys 8264c6e2a2 drop OpenBSD support. See bsd/openBSD.txt for info 2015-01-12 15:21:43 +01:00
Pawel "l0ner" Soltys a2df46dae5 colorized output on *BSD systems 2015-01-11 18:27:08 +01:00
Pawel "l0ner" Soltys e8dd4b442f fixed functions headers to account for use_colors 2015-01-11 18:05:08 +01:00
Pawel "l0ner" Soltys a2e8459457 fixed uncorrect ram usage
While (as per specification) size of total ram reported by sysctl should be
64 bits it's actually 32.
2015-01-11 18:03:22 +01:00
Pawel "l0ner" Soltys df5d66fdbf fixed incorrect cpu usage
While (as for manual) correct size of cpu states variable sould be 64 bits,
the systctl actually return 32 bits for kern.cp_time.
2015-01-11 18:01:13 +01:00
Pawel "l0ner" Soltys dba56f1b56 Merge branch 'l0ner' of github.com:l0ner/tmux-mem-cpu-load into l0ner 2015-01-10 18:39:45 +01:00
Pawel "l0ner" Soltys f59b11971f *BDS port:
- split *BDS files
- add CMake confingure instructions on bsd systems
- add includes to main file
2015-01-10 18:34:37 +01:00
Pawel "l0ner" Soltys 6b8b746a0f pull initial *BDS port from Justin Crawford (see github.com/Justasic/tmux-mem-cpu-load) 2015-01-10 17:58:34 +01:00
Pawel "l0ner" Soltys ad096cbac6 Merge branch 'l0ner' of github.com:l0ner/tmux-mem-cpu-load into l0ner 2015-01-10 17:32:45 +01:00
Pawel "l0ner" Soltys 3e743ee1c2 Hide cpu usage graph if graph_lines == 0. 2015-01-10 17:32:08 +01:00
Pawel "l0ner" Soltys 220d260673 use sysinfo() to get load avg instead of parsing /proc/ file 2015-01-10 17:27:54 +01:00
Pawel "l0ner" Soltys e7f2dd25e8 use sysinfo() to get ram stats instead of parsing meminfo file.
Idea pulled from seculabird gihub user.
see:
880f8b1967
2015-01-09 14:52:50 +01:00
Pawel "l0ner" Soltys b02d0000e9 pulled Joe136 solution to MemAvailable being present in /proc/meminfo
on some systems
2015-01-09 14:10:26 +01:00
Pawel "l0ner" Soltys 5001bc4fe7 added custom interval test 2015-01-08 20:04:27 +01:00
Pawel "l0ner" Soltys c6fc061f9d instead of using istringstream to convert form strin to int use stoi() function 2015-01-08 19:53:22 +01:00
Pawel "l0ner" Soltys aadca0d325 cleanups, fix tests to follow new arguments 2015-01-08 19:52:46 +01:00
Pawel "l0ner" Soltys d92113644c use version generated by cmake, some vim auto reindent 2015-01-08 19:31:25 +01:00
Pawel "l0ner" Soltys 28040b61da easier to read argv parse using command line argument parser by Michael Hanke 2015-01-07 20:57:25 +01:00
Pawel "l0ner" Soltys e7ee4279f6 increase sleep time to full sec instead of 1-0.1s 2015-01-07 14:58:47 +01:00
Pawel "l0ner" Soltys 72f1b03078 shorter DEFINES for versioning 2015-01-07 14:31:49 +01:00
Pawel "l0ner" Soltys 42c93ac397 prune BOOST detection, minor tweaks
For not Boost is not needed, uncomment relative lines when it will be.
2015-01-07 14:15:28 +01:00
Pawel "l0ner" Soltys 8e9033ee1e restore headers 2015-01-07 14:15:08 +01:00
Matt McCormick 8aab7a817d Merge pull request #11 from PeterDaveHello/patch-1
Use svg instead of png to get better image quality
2015-01-05 17:00:26 -05:00
Peter Dave Hello ad1637f05b Use svg instead of png to get better image quality 2015-01-05 20:03:07 +08:00
Pawel "l0ner" Soltys 7a9209e243 grime removal: useless includes and code 2015-01-04 18:51:43 +01:00
Pawel "l0ner" Soltys 26e89f95fa wrap lines that exceed 80 columns 2015-01-04 17:33:03 +01:00
Pawel "l0ner" Soltys 223868f554 reindent one line 2015-01-04 17:23:39 +01:00
Pawel "l0ner" Soltys 080e1be24d use static_cast<> instead of c-like cast 2015-01-04 17:23:05 +01:00
Pawel "l0ner" Soltys 47b9f62a10 include fixes to make it compile on osx, added *~ files to gitignore 2015-01-04 17:21:20 +01:00
Matt McCormick 660481f23b Add Mark to contributors. 2014-05-07 23:23:41 -04:00
Matt McCormick 0c7ce142a2 Merge pull request #9 from mlp6/accomodate_MemAvailable
test/exclude line starting with MemAvailable
2014-05-07 23:17:21 -04:00
Mark Palmeri b12dfc6f29 test/exclude line starting with MemAvailable
tested for line starting w/ 'MemAvailable' and exclude from used memory
calculation by simply decrementing the index variable by 1 and
proceeding
2014-05-06 16:00:57 -04:00
l0ner 2040736dd6 CPU usage graph generation by getGraphByPercentage function. 2014-04-19 22:36:59 +00:00
l0ner 444bf2fa1c fixed typo in graph.cc 2014-04-19 22:30:21 +00:00
l0ner 634201aa2c fixed typos in graph.{cc,h} and linux/cpu.h 2014-04-19 22:25:53 +00:00
l0ner 03040e64f2 rm cpu_percentage function proto from main source
This is useless here, since this proto is provided by
   {linux,osx}/cpu.h
2014-04-19 21:13:36 +00:00
l0ner af8c544653 moved spark files to spark branch 2014-04-19 21:09:03 +00:00
l0ner ea22ccd63f spark.cc fixes 2014-04-19 20:29:59 +02:00
l0ner 0857cdbfe4 Spark graph functions 2014-04-14 22:32:03 +02:00
l0ner ccf33e2a26 Functions for generating vertical graphs 2014-04-14 21:46:32 +02:00
l0ner b0ab6ea57a cpu.cc - fixed missing header and variable misname 2014-04-14 20:57:00 +02:00
l0ner 5e354b9221 memory.cc - fixed typos and missing headers 2014-04-14 20:55:00 +02:00
l0ner 643fef3a7c Corrections in CMakeLists.txt 2014-04-14 20:51:46 +02:00
l0ner fed7b88ccd .gitignore add
Version generation by cmake
system type detection in cmake
Split file code for better management
2014-04-14 20:47:51 +02:00
Matt McCormick 4c9c9dde85 Change the default build type to MinSizeRel.
This changes the output size of the executable from 52K to 32K for GCC 4.6.3.
2013-07-15 23:23:11 +00:00
Matt McCormick a7200d2364 Change the default build type to MinSizeRel.
This changes the output size of the executable from 52K to 32K for GCC 4.6.3.
2013-07-15 23:23:11 +00:00
Matt McCormick a91673be3a Improve foreground contrast with colors.
A brightwhite is needed for the white text to have enough contrast.  It also
allows for non-bright black, which also has better contrast.
2013-07-15 23:20:35 +00:00
Matt McCormick fac8da7a0c Improve foreground contrast with colors.
A brightwhite is needed for the white text to have enough contrast.  It also
allows for non-bright black, which also has better contrast.
2013-07-15 23:20:35 +00:00
Matt McCormick 69880667e5 Add Travis icon to README. 2013-06-14 02:07:07 +00:00
Matt McCormick c81bcc3d84 Add Travis icon to README. 2013-06-14 02:07:07 +00:00
Matt McCormick 82d6687aee Do not run ctest in Travis.
The workers apparently do not present themselves as
a full linux system.
2013-06-14 01:56:46 +00:00
Matt McCormick c07c80b662 Do not run ctest in Travis.
The workers apparently do not present themselves as
a full linux system.
2013-06-14 01:56:46 +00:00
Matt McCormick 6c46121f4d Add .travis.yml. 2013-06-14 01:49:10 +00:00
Matt McCormick 6f00fc1daa Add .travis.yml. 2013-06-14 01:49:10 +00:00
Matt McCormick d413759f4e Add load_line variable for OSX. 2013-06-11 00:12:51 -04:00
Matt McCormick 4bb0a7676f Add load_line variable for OSX. 2013-06-11 00:12:51 -04:00
Matt McCormick 228639fa50 Add contributors to README. 2013-06-09 22:57:37 -04:00
Matt McCormick 8418e297ad Add contributors to README. 2013-06-09 22:57:37 -04:00
Matt McCormick 85e20f258c Update README to note OSX is now supported. 2013-06-09 22:55:08 -04:00
Matt McCormick f95aa23b75 Update README to note OSX is now supported. 2013-06-09 22:55:08 -04:00
Matt McCormick 98a53bc262 Add tests. 2013-06-09 22:50:03 -04:00
Matt McCormick e5f3dc1503 Add tests. 2013-06-09 22:50:03 -04:00
Matt McCormick c5e080218c Output error on status interval < 1. 2013-06-09 22:24:28 -04:00
Matt McCormick beea1a7cae Output error on status interval < 1. 2013-06-09 22:24:28 -04:00
Matt McCormick f375fc7b72 Use EXIT_SUCCESS/EXIT_FAILURE. 2013-06-09 21:01:32 -04:00
Matt McCormick 365502dbf8 Use EXIT_SUCCESS/EXIT_FAILURE. 2013-06-09 21:01:32 -04:00
Matt McCormick 1b012b0f46 Output error on graph_lines < 1. Issue #3. 2013-06-09 20:58:47 -04:00
Matt McCormick 1155ca7c77 Output error on graph_lines < 1. Issue #3. 2013-06-09 20:58:47 -04:00
Matt McCormick 9d072d4ec1 Merge remote-tracking branch 'Justastic/master' #1, #2, #5
Add support for Mac OSX from Justastic.  Refactors the code from Justastic so it
works with the Linux code and so it also works for the new colors support.

Still need to test on OSX.

Conflicts:
	tmux-mem-cpu-load.cpp
2013-06-09 20:49:21 -04:00
Matt McCormick 777452a83e Merge remote-tracking branch 'Justastic/master' #1, #2, #5
Add support for Mac OSX from Justastic.  Refactors the code from Justastic so it
works with the Linux code and so it also works for the new colors support.

Still need to test on OSX.

Conflicts:
	tmux-mem-cpu-load.cpp
2013-06-09 20:49:21 -04:00
Matt McCormick c13d4087b9 Merge branch 'colors'
Add support for colored output.
2013-06-05 11:55:18 -04:00
Justin Crawford 53ffd7ce10 Mac OS X support and BSD function stubs
Reorder the functions, begin OS X specific functions
Load averages and Memory usage now works on OSX (I hope the calculations are correct)
Minor edits
Finish OSX support - Fixes CPU usage
2013-05-20 20:02:13 -07:00
Justin Crawford 06ebd3e9ab Mac OS X support and BSD function stubs
Reorder the functions, begin OS X specific functions
Load averages and Memory usage now works on OSX (I hope the calculations are correct)
Minor edits
Finish OSX support - Fixes CPU usage
2013-05-20 20:02:13 -07:00
Matt McCormick 7186e5dbd0 Add instructions for color support in the README. 2013-05-03 14:28:12 -04:00
Matt McCormick b2f26bab3f Add support for colors.
Colors are added for terminals that have 256 color support when the
--colors flag is enabled.  The background colors are varied with different color
maps derived from their matplotlib versions.  The foreground color is a
contrasting black or white.
2013-04-30 06:38:39 -04:00
Matt McCormick 816a26bab5 No using namespace std.
Bad form, as Hook would say.
2013-04-24 22:13:50 -04:00
Justin Crawford dd3cb1e27d Fix the formatting to use tabs instead of spaces, easier to read this way. 2013-04-15 11:35:38 -07:00
Justin Crawford c14c56c7ef Fix the formatting to use tabs instead of spaces, easier to read this way. 2013-04-15 11:35:38 -07:00
Justin Crawford 7261b34ace Don't use namespace std. It makes things too confusing. 2013-04-15 11:33:28 -07:00
Justin Crawford 86bdac97f8 Don't use namespace std. It makes things too confusing. 2013-04-15 11:33:28 -07:00
Matt McCormick 2dc1716dd3 Add note in README that OSX is not supported. 2013-04-04 19:52:38 -04:00
Matt McCormick b00f53193b Add note in README that OSX is not supported. 2013-04-04 19:52:38 -04:00
Matt McCormick 91034d3d29 Add CMake error on OSX.
It is not currently supported.
2013-04-04 19:50:16 -04:00
Matt McCormick ec28a5615b Add CMake error on OSX.
It is not currently supported.
2013-04-04 19:50:16 -04:00
Matt McCormick c7c0063916 Merge pull request #4 from krieiter/patch-1
Update README.rst
2013-03-20 19:43:40 -07:00
Matt McCormick fd38877476 Merge pull request #4 from krieiter/patch-1
Update README.rst
2013-03-20 19:43:40 -07:00
krieiter 39c97db2b0 Update README.rst
I'm not actually sure whether it's typo or not. Feel free to reject this change.
2013-03-18 16:27:13 +09:00
krieiter 2fd8b67424 Update README.rst
I'm not actually sure whether it's typo or not. Feel free to reject this change.
2013-03-18 16:27:13 +09:00
Matt McCormick e1754b0d60 Parse a --colors flag. 2013-02-21 00:08:14 -05:00
Matt McCormick d28fb387ca Improve indentation style consistency. 2013-02-20 23:15:20 -05:00
Matt McCormick c40ab82bfa Merge branch 'license' 2012-11-25 17:20:58 +00:00
Matt McCormick f9f1342280 Add Apache-2.0 license.
Per request of Alex Alexander.
2012-11-25 17:20:31 +00:00
Matt McCormick (thewtex) b1109a31d9 Make number of bar graph lines optional.
The default is still 10.  If you have a machine with many cores, this can be
used to show how many cores are active.
2010-08-01 10:17:42 -05:00
Matt McCormick (thewtex) 457834ee1b Change annotation letters to numbers.
Because Github's ReST parser mangles them.
2010-02-25 11:20:27 -06:00
Matt McCormick (thewtex) 0926ee84f8 Update README for use with tmux. 2010-02-25 11:13:59 -06:00
Matt McCormick (thewtex) dbd3f8e3c7 Make cpu usage timing interval user option.
Also convert sleep to microseconds so the delay time can always be less than the
tmux status bar update interval.
2010-02-25 08:54:18 -06:00
Matt McCormick (thewtex) 00a85129fa Remove some parameter subscriptions to save space. 2010-02-25 00:03:02 -06:00
Matt McCormick (thewtex) d83d5e302d Add load average. 2010-02-24 23:49:36 -06:00
Matt McCormick (thewtex) 88938b24c3 Calculate used memory. 2010-02-24 23:37:21 -06:00
Matt McCormick (thewtex) edc15497e2 Total memory available. 2010-02-24 19:02:55 -06:00
Matt McCormick (thewtex) 83945d1a19 Move cpu usage from screen setup to tmux setup. 2010-02-24 18:49:10 -06:00
Matt McCormick (thewtex) dc5fe29f1d rename screen-cpu-mem to tmux-mem-cpu-load 2010-02-24 18:04:41 -06:00
53 changed files with 3294 additions and 209 deletions

4
.gitattributes vendored Normal file
View file

@ -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

9
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,9 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"

22
.github/workflows/expired.yml vendored Normal file
View file

@ -0,0 +1,22 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '0 */8 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v11
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
exempt-issue-milestones: 'future,alpha,beta,release'
exempt-pr-milestones: 'bugfix,improvement'
exempt-all-pr-assignees: true
stale-issue-message: 'This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 15 days.'
stale-pr-message: 'This PR is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 15 days.'
close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity.'
days-before-issue-stale: 120
days-before-pr-stale: 120
days-before-issue-close: 30
days-before-pr-close: 30

34
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: tmux-mem-cpu-load
on:
push:
branches:
- '*'
paths-ignore:
- '**/README.md'
- '**/README.rst'
pull_request:
branches:
- '*'
workflow_dispatch:
jobs:
image:
name: build ${{ matrix.arch_name }} ${{ matrix.build_type }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Disable: unsupported system: android-arm, android-arm64, android-x86, android-x86_64, web-wasm,
# Disable: missing header in linux(GCC): windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86,
# Disable: string-related vtable linker error: manylinux2014-aarch64
arch_name: [linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, manylinux2014-x64, manylinux2014-x86, linux-riscv64, linux-riscv32]
build_type: [Release, Debug]
steps:
- name: "📥 Checkout Code"
uses: actions/checkout@v7
with:
submodules: 'recursive'
fetch-depth: 0
- name: "🛠️ build"
run: ./builder/cmake.sh ${{ matrix.arch_name }}:latest -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}

63
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,63 @@
name: "tagged-release"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
jobs:
build:
name: build ${{ matrix.arch_name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Disable: unsupported system: android-arm, android-arm64, android-x86, android-x86_64, web-wasm,
# Disable: missing header in linux(GCC): windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86,
arch_name: [linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, manylinux2014-x64, manylinux2014-x86, manylinux2014-aarch64, linux-riscv64, linux-riscv32]
steps:
- name: "📥 Checkout Code"
uses: actions/checkout@v7
with:
submodules: 'recursive'
fetch-depth: 0
- name: "🛠️ cmake"
run: ./builder/cmake.sh ${{ matrix.arch_name }}:latest -DCMAKE_BUILD_TYPE=Release
- name: "✅ checksum"
run: cd build-${{ matrix.arch_name }} && find . -maxdepth 1 -name "tmux-mem-cpu-load*" | xargs sha256sum > checksum.sha256
- name: "🗜️ compress"
run: cd build-${{ matrix.arch_name }} && find . -maxdepth 1 -name "tmux-mem-cpu-load*" -o -name "*.sha256" | XZ_OPT=-e9 tar -cJf tmux-mem-cpu-load-${{ matrix.arch_name }}.tar.xz -T - && mv tmux-mem-cpu-load-${{ matrix.arch_name }}.tar.xz ..
- name: "💾 save binaries"
uses: actions/upload-artifact@v7
with:
name: bin-artifact-${{ matrix.arch_name }}
path: tmux-mem-cpu-load-${{ matrix.arch_name }}.tar.xz
retention-days: 1
release:
name: release
runs-on: ubuntu-latest
needs: build
steps:
- name: "📥 Checkout Code"
uses: actions/checkout@v7
with:
submodules: 'recursive'
fetch-depth: 0
- name: get artifact
uses: actions/download-artifact@v8
with:
pattern: bin-artifact-*
merge-multiple: true
path: .
- name: "✅ checksum"
run: find . -maxdepth 1 -name "*.tar.xz" | xargs sha256sum > checksum_all.sha256
- uses: "marvinpinto/action-automatic-releases@latest"
name: "📤 upload to github"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
LICENSE
*.tar.xz
*.sha256

61
.gitignore vendored Normal file
View file

@ -0,0 +1,61 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
sysstat
tmux-mem-cpu-load
# CMake generated #
###################
CMakeFiles
Makefile
cmake_install.cmake
CMakeCache.txt
install_manifest.txt
version.h
config.h
CTestTestfile.cmake
DartConfiguration.tcl
# Ninja generated #
###################
.ninja_deps
.ninja_log
*.ninja
# Packages #
############
# it's better to unpack this files and commit raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*.swp
*.swo
*~
dockcross-*
build-*

12
.travis.yml Normal file
View file

@ -0,0 +1,12 @@
os:
- linux
- osx
language: cpp
compiler:
- gcc
- clang
script:
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX:PATH=../install ..
- cmake --build . --target install

12
AUTHORS Normal file
View file

@ -0,0 +1,12 @@
Original author and maintainer:
Matthew McCormick
Contributors (in alphabetical order):
Jasper Lievisse Adriaanse <jasper@humppa.nl>
Justin Crawford <justin@pci-online.net>
krieiter <krieiter@gmail.com>
Mark Palmeri <mlp6@duke.edu>
Pawel 'l0ner' Soltys <pwslts@gmail.com>
Compilenix <Compilenix@compilenix.org>

View file

@ -1,22 +1,176 @@
cmake_minimum_required(VERSION 2.6)
if(COMMAND cmake_policy)
cmake_policy(VERSION 2.6)
endif(COMMAND cmake_policy)
# 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.
#
project(screen-cpu-mem)
cmake_minimum_required(VERSION 3.5)
### General Package stuff
project(tmux-mem-cpu-load)
set(tmux-mem-cpu-load_VERSION_MAJOR 3)
set(tmux-mem-cpu-load_VERSION_MINOR 8)
set(tmux-mem-cpu-load_VERSION_PATCH 3)
#Compute full version string
set(tmux-mem-cpu-load_VERSION
${tmux-mem-cpu-load_VERSION_MAJOR}.${tmux-mem-cpu-load_VERSION_MINOR}.${tmux-mem-cpu-load_VERSION_PATCH})
# Check whether we have support for c++11 in compiler and fail if we don't
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# generate header file to handle version
configure_file(
"${PROJECT_SOURCE_DIR}/common/version.h.in" "${PROJECT_BINARY_DIR}/version.h"
)
# set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
add_executable(screen-cpu-usage screen-cpu-usage.cpp)
install(TARGETS screen-cpu-usage
RUNTIME
DESTINATION bin
)
# detect system type
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
message(STATUS "Linux detected")
set(METER_SOURCES "linux/memory.cc" "linux/cpu.cc" "common/load.cc")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(STATUS "Darwin detected")
set(METER_SOURCES "osx/memory.cc" "osx/cpu.cc" "common/load.cc")
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
message(STATUS "FreeBSD detected")
set(METER_SOURCES "freebsd/memory.cc" "freebsd/cpu.cc" "common/load.cc")
elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
message(STATUS "OpenBSD detected")
set(METER_SOURCES "openbsd/memory.cc" "openbsd/cpu.cc" "common/load.cc")
if(CMAKE_SYSTEM_VERSION VERSION_LESS 5.7)
add_definitions(-DOPENBSD_WORKAROUND=1)
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
message(STATUS "NetBSD detected")
set(METER_SOURCES "netbsd/memory.cc" "netbsd/cpu.cc" "common/load.cc")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
message(STATUS "Windows detected")
set(METER_SOURCES "windows/memory.cc" "windows/cpu.cc" "windows/load.cc")
else()
message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} Cannot be compiled on this system")
message(FATAL_ERROR "Cannot be compiled on this system")
endif()
install(PROGRAMS screen-mem-usage
DESTINATION bin
)
# set common source files
set(COMMON_SOURCES "common/main.cc" "common/memory.cc" "common/graph.cc" "common/powerline.cc")
add_executable(tmux-mem-cpu-load ${COMMON_SOURCES} ${METER_SOURCES})
# add binary tree so we find version.h
target_include_directories(tmux-mem-cpu-load PUBLIC "${PROJECT_BINARY_DIR}")
target_include_directories(tmux-mem-cpu-load PUBLIC "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/common")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(tmux-mem-cpu-load Pdh)
endif()
install(TARGETS tmux-mem-cpu-load RUNTIME DESTINATION bin)
include(CTest)
if(BUILD_TESTING)
add_test(NAME usage
COMMAND tmux-mem-cpu-load -h
)
add_test(NAME no_arguments
COMMAND tmux-mem-cpu-load
)
add_test(NAME custom_interval
COMMAND tmux-mem-cpu-load -i 3
)
add_test(NAME no_cpu_graph
COMMAND tmux-mem-cpu-load -g 0
)
add_test(NAME colors
COMMAND tmux-mem-cpu-load --colors
)
add_test(NAME colors_short
COMMAND tmux-mem-cpu-load -c
)
add_test(NAME powerline-right
COMMAND tmux-mem-cpu-load --powerline-right
)
add_test(NAME powerline-left
COMMAND tmux-mem-cpu-load --powerline-left
)
add_test(NAME invalid_status_interval
COMMAND tmux-mem-cpu-load -i -1
)
add_test(NAME invalid_graph_lines
COMMAND tmux-mem-cpu-load --graph-lines -2
)
add_test(NAME old_option_specification
COMMAND tmux-mem-cpu-load 2 8
)
add_test(NAME memory_mode_free_memory
COMMAND tmux-mem-cpu-load -m 1
)
add_test(NAME memory_mode_used_percentage
COMMAND tmux-mem-cpu-load -m 2
)
add_test(NAME averages_count_0
COMMAND tmux-mem-cpu-load -a 0
)
add_test(NAME averages_count_1
COMMAND tmux-mem-cpu-load -a 1
)
add_test(NAME averages_count_2
COMMAND tmux-mem-cpu-load -a 2
)
add_test(NAME averages_count_3
COMMAND tmux-mem-cpu-load -a 3
)
add_test(NAME cpu_mode_0
COMMAND tmux-mem-cpu-load --cpu-mode 0
)
add_test(NAME cpu_mode_1
COMMAND tmux-mem-cpu-load --cpu-mode 1
)
add_test(NAME cpu_mode_short_0
COMMAND tmux-mem-cpu-load -t 0
)
add_test(NAME cpu_mode_short_1
COMMAND tmux-mem-cpu-load -t 1
)
set_tests_properties(usage
invalid_status_interval
invalid_graph_lines
old_option_specification
PROPERTIES WILL_FAIL TRUE)
endif()

56
CONTRIBUTING.rst Normal file
View file

@ -0,0 +1,56 @@
============
Contributing
============
Want to improve the quality of tmux-mem-cpu-load code? Great! Here's a quick
guide:
1. Fork, then clone the repo:
git clone git@github.com:your-username/tmux-mem-cpu-load
2. Make your change. Add tests for your change.
3. See if it compiles and runs like it should.
4. Run tests to check if you didn't break anything:
make test
Push to your fork and `submit a pull request`_.
At this point you're waiting on us. We'll review your changes as soon as we can.
Before merging your changes we may request you to make some changes or
corrections.
Style guidelines
----------------
You'll need to follow the subsequent rules in order to get your code merged:
* Use Allman_ style for block braces.
* No space before `(`
* Add space after each `(` and before each `)`
* Use braces single line statements
* Don't use mixed case naming style, use underscores instead.
Bad example:
int myAwesomeVariable = 0;
doSomething( myAwesomeVariable );
Good example:
int my_awesome_variable = 0;
do_something( my_awesome_variable );
* Don't vertically align tokens on consecutive lines.
* If you break up an argument list, align the line to opening brace
* Use 2 space indentation (no tabs)
* Use spaces around operators, except for unary operators, such as `!`.
* Add LICENSE header in new files you create.
* Put vim modeline as the first line of file header
* Use the lower-case for CMake commands
* Do not add trailing whitespace
You can use this bash script to strip unnecessary whitespaces:
http://git.io/z_GA3A
.. _`submit a pull request`: https://github.com/thewtex/tmux-mem-cpu-load/compare/
.. _Allman: http://en.wikipedia.org/wiki/Indent_style#Allman_style

202
LICENSE Normal file
View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View file

@ -1,53 +1,68 @@
====================================================
screen-cpu-mem
====================================================
----------------------------------------------------
CPU and RAM memory monitors for use with GNU Screen_
----------------------------------------------------
=============================================
tmux-mem-cpu-load
=============================================
---------------------------------------------
CPU, RAM, and load monitor for use with tmux_
---------------------------------------------
.. image:: https://circleci.com/gh/thewtex/tmux-mem-cpu-load.svg?style=svg
:target: https://circleci.com/gh/thewtex/tmux-mem-cpu-load
.. image:: https://github.com/thewtex/tmux-mem-cpu-load/actions/workflows/main.yml/badge.svg
:target: https://github.com/thewtex/tmux-mem-cpu-load/actions/workflows/main.yml
Description
===========
A simple, lightweight program provided for system monitoring in the *status*
line of **tmux**.
Two programs are provided for system monitoring in the *hardstatus* line of **GNU
Screen**: a CPU usage monitor and a memory usage monitor. These programs are
intended to use minimal system resources.
The memory monitor displays the used and available memory.
The CPU usage monitor outputs a percent CPU usage over all processors that is
updated every second. It also displays a textual bar graph of the current
percent usage where every '|' character represents 10% usage.
The CPU usage monitor outputs a percent CPU usage over all processors. It also
displays a textual bar graph of the current percent usage.
The memory monitor is updated every three seconds and displays the used and
available memory.
The system load average is also displayed.
Example::
Example output::
Mem:2885MB/7987MB Cpu:[||||| ] 51.2%
2885/7987MB [||||| ] 51.2% 2.11 2.35 2.44
^ ^ ^ ^ ^ ^ ^
| | | | | | |
1 2 3 4 5 6 7
1. Currently used memory.
2. Available memory.
3. CPU usage bar graph.
4. CPU usage percentage.
5. Load average for the past minute.
6. Load average for the past 5 minutes.
7. Load average for the past 15 minutes.
For `terminals with 256 color support`_, graded colors can be displayed by
passing the **--colors** flag.
Installation
============
Dependencies
------------
Currently, Linux, Mac OSX, FreeBSD, OpenBSD, and NetBSD are supported.
Building
~~~~~~~~
* >= cmake_ -2.6
* C++ compiler (e.g. gcc/g++)
* >= CMake_ -3.5
* C++ compiler with C++11 support (e.g. gcc/g++ >= 4.6)
Download
--------
There are links to the source code at the `project homepage`_.
Build
-----
@ -57,7 +72,6 @@ Build
cmake .
make
Install
-------
@ -67,37 +81,147 @@ Install
make install
logout
Build and Install Using tpm_
-----------------------------
Include the plugin in your ``.tmux.conf``, the same file you'll set the
configuration in, below.
Configuring GNU Screen_
=======================
::
set -g @plugin 'thewtex/tmux-mem-cpu-load'
The ``$HOME/.screenrc`` file must be edited to make use of the installed
programs, ``screen-cpu-usage`` and ``screen-mem-usage``.
Install with Package Managers
-----------------------------
An example configuration::
* Gentoo: ``emerge tmux-mem-cpu-load``
* Homebrew: ``brew install tmux-mem-cpu-load``
* FreeBSD: ``pkg install tmux-mem-cpu-load``
# backticks to display information in the statusbar
backtick 1 0 0 /usr/local/bin/screen-mem-usage
backtick 2 0 0 /usr/local/bin/screen-cpu-usage
Build and Install Using Antigen_
--------------------------------
hardstatus alwayslastline
hardstatus string '%{kg}Host:%{kG}%H%{kg} %=%{kb}Mem:%{kB}%1` %{ky}Cpu:%{kY}%2`%% %{kR}Load:%{kr}%l%=%{kc} %D %m/%d %{kC}%C%a%{w}'
Include the bundle in your ``.zshrc``
The example configuration will result in::
::
Host:flea Mem:2961MB/7987MB Cpu:[|| ] 25.6% Load:0.64 0.35 0.28 Fri 09/11 12:56am
antigen bundle thewtex/tmux-mem-cpu-load
Configuring tmux_
=================
Edit ``$HOME/.tmux.conf`` to display the program's output in *status-left* or
*status-right*. For example::
set -g status-interval 2
set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2)#[default]"
set -g status-left-length 60
Author
======
If you installed using tpm, you must specify the full path to the
``tmux-mem-cpu-load`` script, like below::
set -g status-right "#[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2)#[default]"
Note that the *interval* argument to `tmux-mem-cpu-load` should be the same number
of seconds that *status-interval* is set at.
Another optional argument is the number of bars in the bar graph, which
defaults to 10. This can, for instance, be set to the number of cores in a
multi-core system.
The *colors* option will add graded colors for each of the measures.
The full usage::
Usage: tmux-mem-cpu-load [OPTIONS]
Available options:
-h, --help
Prints this help message
-c, --colors
Use tmux colors in output
-p, --powerline-left
Use powerline left symbols throughout the output, enables --colors
-q, --powerline-right
Use powerline right symbols throughout the output, enables --colors
-v, --vertical-graph
Use vertical bar chart for CPU graph
-l <value>, --segments-left <value>
Enable blending bg/fg color (depending on -p or -q use) with segment to left
Provide color to be used depending on -p or -q option for seamless segment blending
Color is an integer value which uses the standard tmux color palette values
-r <value>, --segments-right <value>
Enable blending bg/fg color (depending on -p or -q use) with segment to right
Provide color to be used depending on -p or -q option for seamless segment blending
Color is an integer value which uses the standard tmux color palette values
-i <value>, --interval <value>
Set tmux status refresh interval in seconds. Default: 1 second
-g <value>, --graph-lines <value>
Set how many lines should be drawn in a graph. Default: 10
-m <value>, --mem-mode <value>
Set memory display mode. 0: Default, 1: Free memory, 2: Usage percent.
-t <value>, --cpu-mode <value>
Set cpu % display mode. 0: Default max 100%, 1: Max 100% * number of threads.
-a <value>, --averages-count <value>
Set how many load-averages should be drawn. Default: 3
Blending Dynamic Colors Tmux Powerline Segments
===============================================
The -l and -r options when used in conjunction with a recent version of Tmux Powerline
that has the ability to selectively disable spacing and separators between segments allow
for seamless blending of tmux-mem-cpu-load output with other adjacent segments. The end
result is dynamic changing of appropriate foreground and background colors as the start
and end of the tmux-mem-cpu-load output string that is aggregated with other Tmux
Powerline output to produce a more polished status line in Tmux.
Segment Adjaceny before this feature:
.. image:: seg-adj1.png
Segment Adjaceny after this feature:
.. image:: seg-adj2.png
Note that the values for the -l and -r options will be the standard Tmux integer color
values. They set the appropriate background and foreground colors used for the separator
character when used with the poweline-left or powerline-right options so it is easy to
match coloring to adjacent segments. An example from the segment script that calls
tmux-mem-cpu-load is as follows::
tmux-mem-cpu-load -q -v -l 52 -r 33
This combines with theme options available to tmux-powerline, such as the following::
"disk_usage_cust 52 123 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 52 123 right_disable" \
"tmux_mem_cpu_load_cust 52 234 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 52 234 both_disable separator_disable" \
"batt_cust 33 154 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 16 33 N separator_disable" \
Authors
=======
Matt McCormick (thewtex) <matt@mmmccormick.com>
Contributions from:
.. _screen: http://www.gnu.org/software/screen/
.. _cmake: http://www.cmake.org
.. _`project homepage`: http://github.com/thewtex/screen-cpu-mem
* cousine <iam@cousine.me>
* Jasper Lievisse Adriaanse <jasper@humppa.nl>
* Justin Crawford <justinc@pci-online.net>
* krieiter <krieiter@gmail.com>
* Mark Palmeri <mlp6@duke.edu>
* `Pawel 'l0ner' Soltys`_ <pwslts@gmail.com>
* Travil Heller <trav.heller@gmail.com>
* Tony Narlock <tony@git-pull.com>
* Compilenix <Compilenix@compilenix.org>
* jodavies <jodavies1010@gmail.com>
* `@nhdaly`_ (Nathan Daly) <nhdaly@gmail.com>
* bensuperpc <bensuperpc@gmail.com>
.. _tmux: http://tmux.sourceforge.net/
.. _CMake: http://www.cmake.org
.. _`project homepage`: http://github.com/thewtex/tmux-mem-cpu-load
.. _`tpm`: http://github.com/tmux-plugins/tpm
.. _`Antigen`: https://github.com/zsh-users/antigen
.. _`terminals with 256 color support`: http://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility
.. _`Pawel 'l0ner' Soltys` : http://l0ner.github.io/
.. _`@nhdaly` : http://github.com/nhdaly

6
builder/cmake.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail
source $(dirname "$0")/functions/cmake_fn.sh
cmake_build $@

11
builder/cmake_all.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile
make -f dockcross-Makefile display_images
source $(dirname "$0")/functions/cmake_fn.sh
for image in $(make -f dockcross-Makefile display_images); do
cmake_build $image $@
done

19
builder/functions/cmake_fn.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
cmake_build () {
local image=$1
local build_file=build-${image%:*}
shift 1
local cmake_arg=$@
echo "cmake arg: $cmake_arg"
echo "Pulling dockcross/$image"
docker pull dockcross/$image
echo "Make script dockcross-$image"
docker run --rm dockcross/$image > ./dockcross-$image
chmod +x ./dockcross-$image
echo "Build $build_file"
./dockcross-$image cmake -B$build_file -H. -GNinja $cmake_arg
./dockcross-$image ninja -C$build_file
}

View file

@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
makefile_build () {
local image=$1
shift 1
echo "Pulling dockcross/$image"
docker pull dockcross/$image
echo "Make script dockcross-$image"
docker run --rm dockcross/$image > ./dockcross-$image
chmod +x ./dockcross-$image
echo "Build..."
./dockcross-$image bash -c 'make CXX=$CXX CC=$CC AR=$AR AS=$AS CPP=$CPP FC=$FC'
}

6
builder/makefile.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -euo pipefail
source $(dirname "$0")/functions/makefile_fn.sh
makefile_build $@

11
builder/makefile_all.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile
make -f dockcross-Makefile display_images
source $(dirname "$0")/functions/makefile_fn.sh
for image in $(make -f dockcross-Makefile display_images); do
makefile_build $image $@
done

40
common/conversions.h Normal file
View file

@ -0,0 +1,40 @@
/* 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.
*/
#ifndef CONVERSIONS_H_
#define CONVERSIONS_H_
enum BYTE_UNITS
{
BYTES = 0,
KILOBYTES = 1,
MEGABYTES = 2,
GIGABYTES = 3
};
template <class T>
inline T convert_unit( T num, int to, int from = BYTES)
{
for( ; from < to; from++)
{
num /= 1024;
}
return num;
}
#endif

67
common/cpu.h Normal file
View file

@ -0,0 +1,67 @@
/* 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.
*/
#ifndef CPU_H_
#define CPU_H_
#include <cstdint>
#include <sys/types.h>
#if defined(__APPLE__) && defined(__MACH__)
#define CP_USER 0
#define CP_SYS 1
#define CP_IDLE 2
#define CP_NICE 3
#define CP_STATES 4
#elif defined(__OpenBSD__)
#include <sys/sched.h>
#define CP_STATES CPUSTATES
#else
#define CP_USER 0
#define CP_NICE 1
#define CP_SYS 2
#if defined(__FreeBSD__) || defined(__NetBSD__)
// *BSD or OSX
#define CP_INTR 3
#define CP_IDLE 4
#define CP_STATES 5
#else
//linux
#define CP_IDLE 3
#define CP_STATES 4
#endif
#endif
float cpu_percentage( unsigned );
uint32_t get_cpu_count();
/** CPU percentage output mode.
*
* Examples:
*
* CPU_MODE_DEFAULT: 100%
* CPU_MODE_THREADS: 800% (8 cores, fully loaded)
*/
enum CPU_MODE
{
CPU_MODE_DEFAULT,
CPU_MODE_THREADS
};
#endif

37
common/error.h Normal file
View file

@ -0,0 +1,37 @@
/* 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.
*/
#ifndef BSD_ERROR_H_
#define BSD_ERROR_H_
#include <iostream>
#include <sys/errno.h>
#include <cerrno>
#include <cstring> // strerror
#include <cstdlib> // exit()
inline void error( const char * error )
{
using std::cerr;
using std::endl;
cerr << error << ": " << strerror( errno ) << endl;
exit( EXIT_FAILURE );
}
#endif

43
common/generate-luts.py Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env python
"""Create the color code lookup table header."""
import matplotlib.cm
def write_table(fp, colormap_name, stat_name, first_half_foreground, second_half_foreground):
fp.write('static const char ')
fp.write(stat_name)
fp.write('_lut[][32] = {\n')
colormap = matplotlib.cm.get_cmap(colormap_name)
for ii in range(101):
fp.write('"#[fg=')
if ii < 50:
fp.write(first_half_foreground)
else:
fp.write(second_half_foreground)
fp.write(',bg=colour')
rgba = colormap(ii * 0.01)
red = int(round(rgba[0] * 5))
green = int(round(rgba[1] * 5))
blue = int(round(rgba[2] * 5))
color = 16 + 36*red + 6*green + blue;
fp.write(str(color))
fp.write(']"')
if ii != 100:
fp.write(',')
fp.write('\n')
fp.write('}; // end ')
fp.write(stat_name)
fp.write('_lut\n\n')
with open('luts.h', 'w') as fp:
fp.write('#ifndef _luts_h\n')
fp.write('#define _luts_h\n\n')
# hot colormap with white fg for the first half
# and black fg for the second half
write_table(fp, 'hot', 'cpu_percentage', 'brightwhite', 'black')
write_table(fp, 'gist_earth', 'mem', 'brightwhite', 'black')
write_table(fp, 'bone', 'load', 'brightwhite', 'black')
fp.write('#endif\n')

53
common/getsysctl.h Normal file
View file

@ -0,0 +1,53 @@
/*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#ifndef BSD_METER_COMMON_H_
#define BSD_METER_COMMON_H_
#include <iostream>
#include <cerrno>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <cstdlib> //exit()
#include <string.h> //strerror()
#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
static inline void getsysctl( const char *name, void *ptr, size_t len )
{
size_t nlen = len;
if( sysctlbyname( name, ptr, &nlen, NULL, 0 ) == -1 )
{
std::cerr << "sysctl(" << name << "...) failed: " << strerror( errno )
<< std::endl;
exit( EXIT_FAILURE );
}
if( nlen != len )
{
std::cerr << "sysctl(" << name << "...) expected "
<< static_cast<unsigned long>( len ) << " bytes, got "
<< static_cast<unsigned long>( nlen ) << " bytes\n";
//exit( 23 );
}
}
#endif

80
common/graph.cc Normal file
View file

@ -0,0 +1,80 @@
/* 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 <string>
#include <cstring>
#include <map>
#include "graph.h"
std::string get_graph_by_percentage( unsigned value, unsigned len )
{
unsigned step = 0;
std::string bars;
unsigned bar_count = ( static_cast<float>(value) / 99.9 * len );
for( ; step < bar_count; step++ )
{
bars.append( "|" );
}
for( ; step < len; step++ )
{
bars.append( " " );
}
return bars;
}
std::string get_graph_by_value( unsigned value, unsigned max, unsigned len )
{
unsigned step = 0;
std::string bars;
unsigned bar_count = ( static_cast<float>( value / ( max - 0.1 ) ) * len );
for( ; step < bar_count; step++ )
{
bars.append( "|" );
}
for( ; step < len; step++ )
{
bars.append( " " );
}
return bars;
}
std::string get_graph_vert( unsigned value )
{
static const std::map<unsigned, std::string> graph_chars = {
{ 0, " " }, { 10, "" }, { 20, "" }, { 30, "" }, { 40, "" },
{ 50, "" }, { 60, "" }, { 70, "" }, { 80, "" }, { 90, "" }
};
for( auto it = graph_chars.rbegin(); it != graph_chars.rend(); ++it )
{
if( value >= it->first )
{
return it->second;
}
}
return " "; // default return in case value doesn't match map options
}

28
common/graph.h Normal file
View file

@ -0,0 +1,28 @@
/* 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.
*/
#ifndef GRAPH_H_
#define GRAPH_H_
#include <string>
std::string get_graph_by_percentage( unsigned, unsigned len = 10 );
std::string get_graph_by_value( unsigned, unsigned, unsigned len = 10 );
std::string get_graph_vert( unsigned );
#endif

125
common/load.cc Normal file
View file

@ -0,0 +1,125 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* Copyright 2015 Pawel 'l0ner' Soltys
* Copyright 2016 Compilenix
*
* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#include <sstream>
#include <string>
#include <stdlib.h> // getloadavg()
#include <cmath> // floorf()
#include <sys/types.h>
#include <stdio.h>
#include "cpu.h"
#include "load.h"
#include "luts.h"
#include "powerline.h"
// Load Averages
std::string load_string( bool use_colors,
bool use_powerline_left, bool use_powerline_right, short num_averages,
bool segments_to_right, short right_color )
{
std::ostringstream ss;
ss.setf( std::ios::fixed, std::ios::floatfield );
ss.precision( 2 );
if( num_averages <= 0 || num_averages > 3)
{
ss << (char) 0;
return ss.str();
}
double averages[3];
// based on: opensource.apple.com/source/Libc/Libc-262/gen/getloadavg.c
if( getloadavg( averages, num_averages ) < 0 )
{
ss << " 0.00 0.00 0.00"; // couldn't get averages.
}
else
{
unsigned load_percent = static_cast<unsigned int>( averages[0] /
get_cpu_count() * 0.5f * 100.0f );
if( load_percent > 100 )
{
load_percent = 100;
}
if( use_colors )
{
if( use_powerline_right )
{
powerline( ss, load_lut[load_percent], POWERLINE_RIGHT );
}
else if( use_powerline_left )
{
powerline( ss, load_lut[load_percent], POWERLINE_LEFT );
}
else
{
powerline( ss, load_lut[load_percent], NONE );
}
}
ss << ' ';
for( int i = 0; i < num_averages; ++i )
{
// Round to nearest, make sure this is only a 0.00 value not a 0.0000
float avg = floorf( static_cast<float>( averages[i] ) * 100 + 0.5 ) / 100;
// Don't print trailing whitespace for last element
if ( i == num_averages-1 )
{
ss << avg;
}
else
{
ss << avg << " ";
}
}
if( use_colors )
{
if( use_powerline_left && segments_to_right )
{
powerline( ss, load_lut[load_percent], POWERLINE_LEFT, true );
powerline_char( ss, load_lut[load_percent], right_color, POWERLINE_LEFT, true );
}
else if( use_powerline_left && !segments_to_right )
{
powerline( ss, load_lut[load_percent], POWERLINE_LEFT, true );
powerline( ss, "#[fg=default,bg=default]", POWERLINE_LEFT );
}
else if( !use_powerline_right )
{
ss << "#[fg=default,bg=default]";
}
else if ( segments_to_right && use_powerline_right )
{
powerline_char( ss, load_lut[load_percent], right_color, POWERLINE_RIGHT, true );
}
}
}
return ss.str();
}

30
common/load.h Normal file
View file

@ -0,0 +1,30 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2015 Pawel 'l0ner' Soltys
* Copyright 2016 Compilenix
*
* 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.
*/
#ifndef LOAD_H_
#define LOAD_H_
#include <string>
std::string load_string( bool use_colors = false,
bool use_powerline_left = false, bool use_powerline_right = false,
short num_averages = 3, bool segments_to_right = false,
short right_color = 0 );
#endif

316
common/luts.h Normal file
View file

@ -0,0 +1,316 @@
#ifndef _luts_h
#define _luts_h
static const char cpu_percentage_lut[][32] = {
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour19]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour20]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour21]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour57]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour56]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour55]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour54]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour53]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour52]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour88]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour124]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour160]",
"#[fg=brightwhite,bg=colour196]",
"#[fg=brightwhite,bg=colour196]",
"#[fg=brightwhite,bg=colour196]",
"#[fg=brightwhite,bg=colour196]",
"#[fg=brightwhite,bg=colour196]",
"#[fg=brightwhite,bg=colour196]"
}; // end cpu_percentage_lut
static const char mem_lut[][32] = {
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour18]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour24]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour66]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour72]",
"#[fg=brightwhite,bg=colour71]",
"#[fg=brightwhite,bg=colour71]",
"#[fg=brightwhite,bg=colour71]",
"#[fg=brightwhite,bg=colour107]",
"#[fg=brightwhite,bg=colour107]",
"#[fg=black,bg=colour107]",
"#[fg=black,bg=colour107]",
"#[fg=black,bg=colour108]",
"#[fg=black,bg=colour108]",
"#[fg=black,bg=colour108]",
"#[fg=black,bg=colour108]",
"#[fg=black,bg=colour108]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour144]",
"#[fg=black,bg=colour150]",
"#[fg=black,bg=colour150]",
"#[fg=black,bg=colour186]",
"#[fg=black,bg=colour186]",
"#[fg=black,bg=colour186]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour180]",
"#[fg=black,bg=colour181]",
"#[fg=black,bg=colour181]",
"#[fg=black,bg=colour181]",
"#[fg=black,bg=colour181]",
"#[fg=black,bg=colour187]",
"#[fg=black,bg=colour187]",
"#[fg=black,bg=colour187]",
"#[fg=black,bg=colour187]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour224]",
"#[fg=black,bg=colour224]",
"#[fg=black,bg=colour224]",
"#[fg=black,bg=colour224]",
"#[fg=black,bg=colour224]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]"
}; // end mem_lut
static const char load_lut[][32] = {
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour16]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour17]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour59]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour60]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour102]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=brightwhite,bg=colour103]",
"#[fg=black,bg=colour103]",
"#[fg=black,bg=colour103]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour109]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour145]",
"#[fg=black,bg=colour146]",
"#[fg=black,bg=colour146]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour152]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour188]",
"#[fg=black,bg=colour195]",
"#[fg=black,bg=colour195]",
"#[fg=black,bg=colour195]",
"#[fg=black,bg=colour195]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]",
"#[fg=black,bg=colour231]"
}; // end load_lut
#endif

302
common/main.cc Normal file
View file

@ -0,0 +1,302 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
*
* 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 <cstring>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdlib> // EXIT_SUCCESS, atoi()
#include <getopt.h> // getopt_long
#include "version.h"
#include "graph.h"
// Tmux color lookup tables for the different metrics.
#include "luts.h"
#include "cpu.h"
#include "memory.h"
#include "load.h"
#include "powerline.h"
std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigned int graph_lines,
bool use_colors = false,
bool use_powerline_left = false, bool use_powerline_right = false, bool use_vert_graph = false)
{
float percentage;
float multiplier = 1.0f;
//output stuff
std::ostringstream oss;
oss.precision( 1 );
oss.setf( std::ios::fixed | std::ios::right );
// get %
percentage = cpu_percentage( cpu_usage_delay );
// set multiplier to number of threads ?
if ( cpu_mode == CPU_MODE_THREADS )
{
multiplier = get_cpu_count();
}
// if percentage*multiplier >= 100, remove decimal point to keep number short
if ( percentage*multiplier >= 100.0f )
{
oss.precision( 0 );
}
unsigned int percent = static_cast<unsigned int>( percentage );
if( use_colors )
{
if( use_powerline_right )
{
powerline( oss, cpu_percentage_lut[percent], POWERLINE_RIGHT );
}
else if( use_powerline_left )
{
powerline( oss, cpu_percentage_lut[percent], POWERLINE_LEFT );
}
else
{
powerline( oss, cpu_percentage_lut[percent], NONE );
}
}
if( use_vert_graph )
{
oss << "";
oss << get_graph_vert( unsigned( percentage ) );
oss << "";
}
else if( graph_lines > 0)
{
oss << " [";
oss << get_graph_by_percentage( unsigned( percentage ), graph_lines );
oss << "]";
}
oss.width( 6 );
oss.setf( std::ios::fixed, std::ios::floatfield );
oss.precision( 1 );
oss.fill( ' ' );
oss << std::right << percentage * multiplier;
oss << "%";
if( use_colors )
{
if( use_powerline_left )
{
powerline( oss, cpu_percentage_lut[percent], POWERLINE_LEFT, true );
}
else if( !use_powerline_right )
{
oss << "#[fg=default,bg=default]";
}
}
return oss.str();
}
void print_help()
{
using std::cout;
using std::endl;
cout << "tmux-mem-cpu-load v" << tmux_mem_cpu_load_VERSION << endl
<< "Usage: tmux-mem-cpu-load [OPTIONS]\n\n"
<< "Available options:\n"
<< "-h, --help\n"
<< "\t Prints this help message\n"
<< "-c, --colors\n"
<< "\tUse tmux colors in output\n"
<< "-p, --powerline-left\n"
<< "\tUse powerline left symbols throughout the output, enables --colors\n"
<< "-q, --powerline-right\n"
<< "\tUse powerline right symbols throughout the output, enables --colors\n"
<< "-v, --vertical-graph\n"
<< "\tUse vertical bar chart for CPU graph\n"
<< "-l <value>, --segments-left <value>\n"
<< "\tEnable blending bg/fg color (depending on -p or -q use) with segment to left\n"
<< "\tProvide color to be used depending on -p or -q option for seamless segment blending\n"
<< "\tColor is an integer value which uses the standard tmux color palette values\n"
<< "-r <value>, --segments-right <value>\n"
<< "\tEnable blending bg/fg color (depending on -p or -q use) with segment to right\n"
<< "\tProvide color to be used depending on -p or -q option for seamless segment blending\n"
<< "\tColor is an integer value which uses the standard tmux color palette values\n"
<< "-i <value>, --interval <value>\n"
<< "\tSet tmux status refresh interval in seconds. Default: 1 second\n"
<< "-g <value>, --graph-lines <value>\n"
<< "\tSet how many lines should be drawn in a graph. Default: 10\n"
<< "-m <value>, --mem-mode <value>\n"
<< "\tSet memory display mode. 0: Default, 1: Free memory, 2: Usage percent.\n"
<< "-t <value>, --cpu-mode <value>\n"
<< "\tSet cpu % display mode. 0: Default max 100%, 1: Max 100% * number of threads. \n"
<< "-a <value>, --averages-count <value>\n"
<< "\tSet how many load-averages should be drawn. Default: 3\n"
<< endl;
}
int main( int argc, char** argv )
{
unsigned cpu_usage_delay = 990000;
short averages_count = 3;
short graph_lines = 10; // max 32767 should be enough
short left_color = 0;
short right_color = 0;
bool use_colors = false;
bool use_powerline_left = false;
bool use_powerline_right = false;
bool use_vert_graph = false;
bool segments_to_left = false;
bool segments_to_right= false;
MEMORY_MODE mem_mode = MEMORY_MODE_DEFAULT;
CPU_MODE cpu_mode = CPU_MODE_DEFAULT;
static struct option long_options[] =
{
// Struct is a s follows:
// const char * name, int has_arg, int *flag, int val
// if *flag is null, val is option identifier to use in switch()
// otherwise it's a value to set the variable *flag points to
{ "help", no_argument, NULL, 'h' },
{ "colors", no_argument, NULL, 'c' },
{ "powerline-left", no_argument, NULL, 'p' },
{ "powerline-right", no_argument, NULL, 'q' },
{ "vertical-graph", no_argument, NULL, 'v' },
{ "interval", required_argument, NULL, 'i' },
{ "graph-lines", required_argument, NULL, 'g' },
{ "mem-mode", required_argument, NULL, 'm' },
{ "cpu-mode", required_argument, NULL, 't' },
{ "averages-count", required_argument, NULL, 'a' },
{ "segments-left", required_argument, NULL, 'l' },
{ "segments-right", required_argument, NULL, 'r' },
{ 0, 0, 0, 0 } // used to handle unknown long options
};
int c;
// while c != -1
while( (c = getopt_long( argc, argv, "hi:cpqvl:r:g:m:a:t:", long_options, NULL) ) != -1 )
{
switch( c )
{
case 'h': // --help, -h
print_help();
return EXIT_FAILURE;
break;
case 'c': // --colors
use_colors = true;
break;
case 'p': // --powerline-left
use_colors = true;
use_powerline_left = true;
break;
case 'q': // --powerline-right
use_colors = true;
use_powerline_right = true;
break;
case 'v': // --vertical-graph
use_vert_graph = true;
break;
case 'l': // --segments-left
segments_to_left = true;
if( atoi( optarg ) < 0 || atoi( optarg ) > 255 )
{
std::cerr << "Valid color vaues are from 0 to 255.\n";
return EXIT_FAILURE;
}
left_color = atoi( optarg ) ;
break;
case 'r': // --segments-right
segments_to_right= true;
if( atoi( optarg ) < 0 || atoi( optarg ) > 255 )
{
std::cerr << "Valid color vaues are from 0 to 255.\n";
return EXIT_FAILURE;
}
right_color = atoi( optarg ) ;
break;
case 'i': // --interval, -i
if( atoi( optarg ) < 1 )
{
std::cerr << "Status interval argument must be one or greater.\n";
return EXIT_FAILURE;
}
cpu_usage_delay = atoi( optarg ) * 1000000 - 10000;
break;
case 'g': // --graph-lines, -g
if( atoi( optarg ) < 0 )
{
std::cerr << "Graph lines argument must be zero or greater.\n";
return EXIT_FAILURE;
}
graph_lines = atoi( optarg );
break;
case 'm': // --mem-mode, -m
if( atoi( optarg ) < 0 )
{
std::cerr << "Memory mode argument must be zero or greater.\n";
return EXIT_FAILURE;
}
mem_mode = static_cast< MEMORY_MODE >( atoi( optarg ) );
break;
case 't': // --cpu-mode, -t
if( atoi( optarg ) < 0 )
{
std::cerr << "CPU mode argument must be zero or greater.\n";
return EXIT_FAILURE;
}
cpu_mode = static_cast< CPU_MODE >( atoi( optarg ) );
break;
case 'a': // --averages-count, -a
if( atoi( optarg ) < 0 || atoi( optarg ) > 3 )
{
std::cerr << "Valid averages-count arguments are: 0, 1, 2, 3\n";
return EXIT_FAILURE;
}
averages_count = atoi( optarg );
break;
case '?':
// getopt_long prints error message automatically
return EXIT_FAILURE;
break;
default:
std::cerr << "?? getopt returned character code 0 " << c << std::endl;
return EXIT_FAILURE;
}
}
// Detect old option specification and return and error message.
if( argc > optind )
{
std::cout <<
"The interval and graph lines options are now specified with flags.\n\n";
print_help();
return EXIT_FAILURE;
}
MemoryStatus memory_status;
mem_status( memory_status );
std::cout << mem_string( memory_status, mem_mode, use_colors, use_powerline_left, use_powerline_right, segments_to_left, left_color )
<< cpu_string( cpu_mode, cpu_usage_delay, graph_lines, use_colors, use_powerline_left, use_powerline_right, use_vert_graph )
<< load_string( use_colors, use_powerline_left, use_powerline_right, averages_count, segments_to_right, right_color );
std::cout << std::endl;
return EXIT_SUCCESS;
}

122
common/memory.cc Normal file
View file

@ -0,0 +1,122 @@
/* 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 <sstream>
#include <string>
#include "memory.h"
#include "luts.h"
#include "conversions.h"
#include "powerline.h"
std::string mem_string( const MemoryStatus & mem_status,
MEMORY_MODE mode,
bool use_colors,
bool use_powerline_left,
bool use_powerline_right,
bool segments_to_left,
short left_color )
{
std::ostringstream oss;
// Change the percision for floats, for a pretty output
oss.precision( 2 );
oss.setf( std::ios::fixed | std::ios::right );
unsigned int color = static_cast< unsigned int >((100 * mem_status.used_mem) / mem_status.total_mem);
if( use_colors )
{
if( use_powerline_right && segments_to_left )
{
powerline_char( oss, mem_lut[color], left_color, POWERLINE_RIGHT, false);
oss << ' ';
}
else if( use_powerline_right && !segments_to_left )
{
oss << "#[bg=default]";
powerline( oss, mem_lut[color], POWERLINE_RIGHT );
oss << ' ';
}
else if( use_powerline_left && segments_to_left )
{
powerline_char( oss, mem_lut[color], left_color, POWERLINE_LEFT, false);
oss << ' ';
}
else if( use_powerline_left )
{
//powerline( oss, mem_lut[color], POWERLINE_LEFT );
// We do not know how to invert the default background color
powerline( oss, mem_lut[color], NONE );
oss << ' ';
}
else
{
powerline( oss, mem_lut[color], NONE );
}
}
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<float>( mem_status.total_mem ) * 100.0;
oss << percentage_mem << '%';
break;
}
default: // Default mode, just show the used/total memory in MB
if(mem_status.used_mem>10000 && mem_status.total_mem>10000)
oss<<static_cast<unsigned int>(mem_status.used_mem/1024)<<"/"<<static_cast<unsigned int>(mem_status.total_mem/1024)<<"GB";
else if(mem_status.used_mem<10000 && mem_status.total_mem>10000)
oss<<static_cast<unsigned int>(mem_status.used_mem)<<"MB/"<<static_cast<unsigned int>(mem_status.total_mem/1024)<<"GB";
else
oss<<static_cast<unsigned int>(mem_status.used_mem)<<"/"<<static_cast<unsigned int>(mem_status.total_mem)<<"MB";
}
if( use_colors )
{
if( use_powerline_left )
{
powerline( oss, mem_lut[color], POWERLINE_LEFT, true );
}
else if( !use_powerline_right )
{
oss << "#[fg=default,bg=default]";
}
}
return oss.str();
}

58
common/memory.h Normal file
View file

@ -0,0 +1,58 @@
/* 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.
*/
#ifndef MEMORY_H_
#define MEMORY_H_
#include <string>
/** 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,
MEMORY_MODE_FREE_MEMORY,
MEMORY_MODE_USAGE_PERCENTAGE
};
std::string mem_string( const MemoryStatus & mem_status,
MEMORY_MODE mode = MEMORY_MODE_DEFAULT,
bool use_colors = false,
bool use_powerline_left = false,
bool use_powerline_right = false,
bool segments_to_left = false,
short left_color = 0 );
#endif

102
common/powerline.cc Normal file
View file

@ -0,0 +1,102 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2016 Michał Goliński
*
* 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 "powerline.h"
#include <string>
#include <cstring>
#include <sstream>
#define PWL_LEFT_FILLED ""
#define PWL_RIGHT_FILLED ""
const char * bg2fg( const char s[] )
{
static char buf[40] = {0};
const char *substr = strchr(s, ',');
buf[0] = '#';
buf[1] = '[';
buf[2] = 'f';
strcpy(buf+3, substr+2);
return buf;
}
void powerline( std::ostringstream & oss, const char color[],
POWERLINE_DIRECTION direction, bool background_only )
{
switch( direction )
{
case NONE:
oss << color;
break;
case POWERLINE_LEFT:
if( background_only )
{
oss << ' ' << bg2fg( color );
}
else
{
std::string colorstr( color );
oss << "#[" << colorstr.substr( colorstr.find( "," ) + 1 )
<< PWL_LEFT_FILLED
<< color;
}
break;
case POWERLINE_RIGHT:
oss << ' '
<< bg2fg( color )
<< PWL_RIGHT_FILLED
<< color;
break;
};
}
void powerline_char( std::ostringstream & oss, const char dynamic_color[],
short static_color, POWERLINE_DIRECTION direction, bool eol )
{
char write_color[7];
sprintf(write_color, "%d", static_color);
switch( direction )
{
case NONE:
break;
case POWERLINE_LEFT:
if ( eol )
{
oss << bg2fg( dynamic_color ) << "#[bg=colour" << write_color << "]";
}
else
{
oss << dynamic_color << "#[fg=colour" << write_color << "]";
}
oss << PWL_LEFT_FILLED << dynamic_color;
break;
case POWERLINE_RIGHT:
if ( eol )
{
oss << dynamic_color << "#[fg=colour" << write_color << "] ";
}
else
{
oss << bg2fg(dynamic_color) << " #[bg=colour" << write_color << "]";
}
oss << PWL_RIGHT_FILLED << dynamic_color;
break;
}
}

40
common/powerline.h Normal file
View file

@ -0,0 +1,40 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2016 Michał Goliński
*
* 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.
*/
#ifndef POWERLINE_H
#define POWERLINE_H
#include <sstream>
enum POWERLINE_DIRECTION
{
NONE,
POWERLINE_LEFT,
POWERLINE_RIGHT
};
/** Print out a powerline left character inverted version of the given
* color. In the case of of using powerline left, the background color needs
* to be inverted to the foreground before the powerline character is printed
* in the next entr. */
void powerline( std::ostringstream & oss, const char color[],
POWERLINE_DIRECTION direction, bool background_only = false );
void powerline_char( std::ostringstream & oss, const char dynamic_color[],
short static_color, POWERLINE_DIRECTION direction, bool eol = false );
#endif // POWERLINE_H

24
common/version.h.in Normal file
View file

@ -0,0 +1,24 @@
/* 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.
*/
// the configured options and settings for sysstat
#define tmux_mem_cpu_load_VERSION_MAJOR @tmux-mem-cpu-load_VERSION_MAJOR@
#define tmux_mem_cpu_load_VERSION_MINOR @tmux-mem-cpu-load_VERSION_MINOR@
#define tmux_mem_cpu_load_VERSION_PATCH @tmux-mem-cpu-load_VERSION_PATCH@
#define tmux_mem_cpu_load_VERSION "@tmux-mem-cpu-load_VERSION@"

65
freebsd/cpu.cc Normal file
View file

@ -0,0 +1,65 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#include <sys/types.h>
#include <unistd.h> // usleep
#include "getsysctl.h"
#include "cpu.h"
uint32_t get_cpu_count()
{
int32_t cpu_count = 0;
GETSYSCTL( "hw.ncpu", cpu_count );
return static_cast<uint32_t>( cpu_count );
}
float cpu_percentage( unsigned int cpu_usage_delay )
{
u_long load1[CP_STATES];
u_long load2[CP_STATES];
GETSYSCTL( "kern.cp_time", load1 );
usleep( cpu_usage_delay );
GETSYSCTL( "kern.cp_time", load2 );
// Current load times
unsigned long long current_user = load1[CP_USER];
unsigned long long current_system = load1[CP_SYS];
unsigned long long current_nice = load1[CP_NICE];
unsigned long long current_idle = load1[CP_IDLE];
// Next load times
unsigned long long next_user = load2[CP_USER];
unsigned long long next_system = load2[CP_SYS];
unsigned long long next_nice = load2[CP_NICE];
unsigned long long next_idle = load2[CP_IDLE];
// Difference between the two
unsigned long long diff_user = next_user - current_user;
unsigned long long diff_system = next_system - current_system;
unsigned long long diff_nice = next_nice - current_nice;
unsigned long long diff_idle = next_idle - current_idle;
return static_cast<float>( diff_user + diff_system + diff_nice ) /
static_cast<float>( diff_user + diff_system + diff_nice + diff_idle ) *
100.0;
}

70
freebsd/memory.cc Normal file
View file

@ -0,0 +1,70 @@
/* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#include <sstream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include "getsysctl.h"
#include "memory.h"
#include "conversions.h"
void mem_status( MemoryStatus & status )
{
// These values are in bytes
//u_int total;
//u_int free;
//u_int inactive;
//u_int cache;
u_int wired;
u_int active;
u_int page_size;
u_int page_count;
// Get total physical memory, page size, and some other needed info
// instead of using realmem which reports quantity of ram installed on
// platform, use physmem which reports ram available to system.
//GETSYSCTL( "hw.physmem", total );
page_size = getpagesize();
// page count reflects actual size of memory we have available for
// applications. it will be less than realmem or physmem, since it doesn't
// include what's been allocated for kernel, but it will be equal to
// free + inactive + cache + wired + active, and thus will reflect better
// what's actually available.
GETSYSCTL( "vm.stats.vm.v_page_count", page_count );
//GETSYSCTL( "vm.stats.vm.v_free_count", free );
//GETSYSCTL( "vm.stats.vm.v_inactive_count", inactive );
//GETSYSCTL( "vm.stats.vm.v_cache_count", cache );
GETSYSCTL( "vm.stats.vm.v_wire_count", wired ); // Buffers
GETSYSCTL( "vm.stats.vm.v_active_count", active );
// Get all memory which can be allocated, which on FreeBSD is:
// cached + inactive + free
//u_int unused = ( cache + inactive + free ) * page_size;
// Used memory on FreeBSD is active + wired.
u_int used = ( active + wired );
status.used_mem = convert_unit( static_cast< float >( used * (page_size >> 10) ), MEGABYTES, KILOBYTES );
status.total_mem = convert_unit( static_cast< float >( page_count * (page_size >> 10) ), MEGABYTES, KILOBYTES);
}

78
linux/cpu.cc Normal file
View file

@ -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 <string>
#include <fstream>
#include <unistd.h> // usleep
#include "cpu.h"
#include "luts.h"
uint32_t get_cpu_count()
{
return sysconf( _SC_NPROCESSORS_ONLN );
}
float cpu_percentage( unsigned cpu_usage_delay )
{
std::string line;
size_t substr_start = 0;
size_t substr_len;
// cpu stats
// user, nice, system, idle
// in that order
unsigned long long stats[CP_STATES];
std::ifstream stat_file( "/proc/stat" );
getline( stat_file, line );
stat_file.close();
// skip "cpu"
substr_len = line.find_first_of( " ", 3 );
// parse cpu line
for( unsigned i=0; i < 4; i++ )
{
substr_start = line.find_first_not_of( " ", substr_len );
substr_len = line.find_first_of( " ", substr_start );
stats[i] = std::stoll( line.substr( substr_start, substr_len ) );
}
usleep( cpu_usage_delay );
stat_file.open( "/proc/stat" );
getline( stat_file, line );
stat_file.close();
// skip "cpu"
substr_len = line.find_first_of( " ", 3 );
// parse cpu line
for( unsigned i=0; i < 4; i++ )
{
substr_start = line.find_first_not_of( " ", substr_len );
substr_len = line.find_first_of ( " ", substr_start );
stats[i] = std::stoll( line.substr( substr_start, substr_len ) ) - stats[i];
}
return static_cast<float>(
stats[CP_USER] + stats[CP_NICE] + stats[CP_SYS]
) / static_cast<float>(
stats[CP_USER] + stats[CP_NICE] + stats[CP_SYS] + stats[CP_IDLE]
) * 100.0;
}

93
linux/memory.cc Normal file
View file

@ -0,0 +1,93 @@
/* 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 <sstream>
#include <fstream>
#include <sys/sysinfo.h>
#include "memory.h"
#include "conversions.h"
void mem_status( MemoryStatus & status )
{
std::string line;
std::string substr;
size_t substr_start;
size_t substr_len;
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
* 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
* following formula:
* total_ram + shmem - free_ram - buffered_ram - cached_ram - srclaimable
*
* example data, junk removed, with comments added:
*
* MemTotal: 61768 kB old
* MemFree: 1436 kB old
* MemAvailable ????? kB ??
* MemShared: 0 kB old (now always zero; not calculated)
* Buffers: 1312 kB old
* Cached: 20932 kB old
* SwapTotal: 122580 kB old
* SwapFree: 60352 kB old
*/
std::ifstream memory_info("/proc/meminfo");
while( std::getline( memory_info, line ) )
{
substr_start = 0;
substr_len = line.find_first_of( ':' );
substr = line.substr( substr_start, substr_len );
substr_start = line.find_first_not_of( " ", substr_len + 1 );
substr_len = line.find_first_of( 'k' ) - substr_start;
if( substr.compare( "MemTotal" ) == 0 )
{
// get total memory
total_mem = stol( line.substr( substr_start, substr_len ) );
}
else if( substr.compare( "MemFree" ) == 0 )
{
used_mem = total_mem - stol( line.substr( substr_start, substr_len ) );
}
else if( substr.compare( "Shmem" ) == 0 )
{
used_mem += stol( line.substr( substr_start, substr_len ) );
}
else if( substr.compare( "Buffers" ) == 0 ||
substr.compare( "Cached" ) == 0 ||
substr.compare( "SReclaimable" ) == 0 )
{
used_mem -= stol( line.substr( substr_start, substr_len ) );
}
}
// 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
status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES, KILOBYTES);
status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES, KILOBYTES);
}

65
netbsd/cpu.cc Normal file
View file

@ -0,0 +1,65 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#include <sys/types.h>
#include <unistd.h> // usleep
#include "getsysctl.h"
#include "cpu.h"
uint32_t get_cpu_count()
{
int cpu_count = 0;
GETSYSCTL( "hw.ncpu", cpu_count );
return static_cast<uint32_t>( cpu_count );
}
float cpu_percentage( unsigned int cpu_usage_delay )
{
u_int64_t load1[CP_STATES];
u_int64_t load2[CP_STATES];
GETSYSCTL( "kern.cp_time", load1 );
usleep( cpu_usage_delay );
GETSYSCTL( "kern.cp_time", load2 );
// Current load times
unsigned long long current_user = load1[CP_USER];
unsigned long long current_system = load1[CP_SYS];
unsigned long long current_nice = load1[CP_NICE];
unsigned long long current_idle = load1[CP_IDLE];
// Next load times
unsigned long long next_user = load2[CP_USER];
unsigned long long next_system = load2[CP_SYS];
unsigned long long next_nice = load2[CP_NICE];
unsigned long long next_idle = load2[CP_IDLE];
// Difference between the two
unsigned long long diff_user = next_user - current_user;
unsigned long long diff_system = next_system - current_system;
unsigned long long diff_nice = next_nice - current_nice;
unsigned long long diff_idle = next_idle - current_idle;
return static_cast<float>( diff_user + diff_system + diff_nice ) /
static_cast<float>( diff_user + diff_system + diff_nice + diff_idle ) *
100.0;
}

48
netbsd/memory.cc Normal file
View file

@ -0,0 +1,48 @@
/* 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 <sstream>
#include <string>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <uvm/uvm_extern.h> // uvmexp struct
#include "error.h"
#include "conversions.h"
#include "memory.h"
void mem_status( MemoryStatus & status )
{
// get vm memory stats
static int vm_totalmem[] = { CTL_VM, VM_UVMEXP2 };
struct uvmexp_sysctl mem;
size_t size = sizeof( mem );
if( sysctl( vm_totalmem, 2, &mem, &size, NULL, 0 ) < 0 )
{
error( "memory: error getting vm memory stats" );
}
int64_t total_mem = ( mem.npages << mem.pageshift );
int64_t used_mem =
( mem.active + mem.wired - mem.filepages ) << mem.pageshift;
// add 1 to used which gets lost somewhere along conversions
status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES );
status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES );
}

85
openbsd/cpu.cc Normal file
View file

@ -0,0 +1,85 @@
/* 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 <unistd.h> // usleep
#include <sys/sysctl.h>
#include <sys/types.h>
#include "error.h"
#include "cpu.h"
uint32_t get_cpu_count()
{
int cpu_count = 1; // default to 1
int mib[2] = { CTL_HW, HW_NCPUONLINE };
size_t len = sizeof( cpu_count );
if( sysctl( mib, 2, &cpu_count, &len, NULL, 0 ) < 0 )
{
error( "sysctl: error getting cpu count" );
}
return static_cast<uint32_t>( cpu_count );
}
float cpu_percentage( unsigned int cpu_usage_delay )
{
int cpu_ctl[] = { CTL_KERN, KERN_CPTIME };
u_long load1[CP_STATES];
u_long load2[CP_STATES];
size_t size = sizeof( load1 );
// get cpu times
if( sysctl( cpu_ctl, 2, &load1, &size, NULL, 0 ) < 0 )
{
error( "sysctl: error getting initial cpu stats" );
}
usleep( cpu_usage_delay );
size = sizeof( load2 );
// update cpu times
if( sysctl( cpu_ctl, 2, &load2, &size, NULL, 0 ) < 0 )
{
error( "sysctl: error getting updated cpu stats" );
}
// Current load times
unsigned long long current_user = load1[CP_USER];
unsigned long long current_system = load1[CP_SYS];
unsigned long long current_nice = load1[CP_NICE];
unsigned long long current_idle = load1[CP_IDLE];
// Next load times
unsigned long long next_user = load2[CP_USER];
unsigned long long next_system = load2[CP_SYS];
unsigned long long next_nice = load2[CP_NICE];
unsigned long long next_idle = load2[CP_IDLE];
// Difference between the two
unsigned long long diff_user = next_user - current_user;
unsigned long long diff_system = next_system - current_system;
unsigned long long diff_nice = next_nice - current_nice;
unsigned long long diff_idle = next_idle - current_idle;
return static_cast<float>( diff_user + diff_system + diff_nice ) /
static_cast<float>( diff_user + diff_system + diff_nice + diff_idle ) *
100.0;
}

90
openbsd/memory.cc Normal file
View file

@ -0,0 +1,90 @@
/* 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 <sstream>
#include <string>
// Ugly fix to compilation on OpenBSD 5.6
// these need to be before include sys/mount.h
// and be in this exact order. Otherwise compiling on
// OpenBSD 5.6 will fail with missing NGROUPS define
// or missing gid_t typedefs
#ifdef OPENBSD_WORKAROUND
#include <sys/types.h> // typedefs
#include <sys/param.h> // missing NGROUPS
#include <sys/ucred.h>
#else
#include <sys/types.h>
#endif
#include <sys/mount.h> // VFS_* which we use to get cache
#include <sys/sysctl.h>
#include "error.h"
#include "memory.h"
#include "conversions.h"
void mem_status( MemoryStatus & status )
{
// These values are in bytes
int64_t total_mem = 0;
int64_t used_mem = 0;
int32_t free_mem = 0;
size_t size;
// get page size
static int hw_pagesize[] = { CTL_HW, HW_PAGESIZE };
int page_size = 0;
size = sizeof( page_size );
if( sysctl( hw_pagesize, 2, &page_size, &size, NULL, 0 ) < 0 )
{
error( "memory: error getting page size" );
}
// get vm memory stats
static int uvmexp_mib[] = { CTL_VM, VM_UVMEXP };
struct uvmexp uvmexp;
size = sizeof( uvmexp );
if( sysctl( uvmexp_mib, 2, &uvmexp, &size, NULL, 0 ) < 0 )
{
error( "memory: error getting vm memory stats" );
}
// In case we need it, this gets the cached memory (bcstats.numbufpages)
static int vm_bcstats[] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT };
struct bcachestats bcstats;
size = sizeof( bcstats );
if( sysctl( vm_bcstats, 3, &bcstats, &size, NULL, 0 ) < 0 )
{
error( "memory: error getting cached memory size" );
}
// calculations based on libgtop
used_mem = ( (uint64_t) uvmexp.npages - uvmexp.free ) << uvmexp.pageshift;
free_mem = ( (uint64_t) uvmexp.free ) << uvmexp.pageshift;
// from nagios-memory plugin
used_mem -= ( (uint64_t) bcstats.numbufpages ) << uvmexp.pageshift;
free_mem += ( (uint64_t) bcstats.numbufpages ) << uvmexp.pageshift;
// calculate total memory
total_mem = ( (uint64_t) uvmexp.npages ) << uvmexp.pageshift;
status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES );
status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES );
}

80
osx/cpu.cc Normal file
View file

@ -0,0 +1,80 @@
/*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* 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 <mach/mach.h>
#include <unistd.h> // usleep()
#include "cpu.h"
uint32_t get_cpu_count()
{
return sysconf( _SC_NPROCESSORS_ONLN );
}
// OSX or BSD based system, use BSD APIs instead
// See: http://www.opensource.apple.com/source/xnu/xnu-201/osfmk/mach/host_info.h
// and: http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/
host_cpu_load_info_data_t _get_cpu_percentage()
{
kern_return_t error;
mach_msg_type_number_t count;
host_cpu_load_info_data_t r_load;
mach_port_t mach_port;
count = HOST_CPU_LOAD_INFO_COUNT;
mach_port = mach_host_self();
error = host_statistics(mach_port, HOST_CPU_LOAD_INFO,
( host_info_t )&r_load, &count );
if ( error != KERN_SUCCESS )
{
return host_cpu_load_info_data_t();
}
return r_load;
}
float cpu_percentage( unsigned int cpu_usage_delay )
{
// Get the load times from the XNU kernel
host_cpu_load_info_data_t load1 = _get_cpu_percentage();
usleep( cpu_usage_delay );
host_cpu_load_info_data_t load2 = _get_cpu_percentage();
// Current load times
unsigned long long current_user = load1.cpu_ticks[CP_USER];
unsigned long long current_system = load1.cpu_ticks[CP_SYS];
unsigned long long current_nice = load1.cpu_ticks[CP_NICE];
unsigned long long current_idle = load1.cpu_ticks[CP_IDLE];
// Next load times
unsigned long long next_user = load2.cpu_ticks[CP_USER];
unsigned long long next_system = load2.cpu_ticks[CP_SYS];
unsigned long long next_nice = load2.cpu_ticks[CP_NICE];
unsigned long long next_idle = load2.cpu_ticks[CP_IDLE];
// Difference between the two
unsigned long long diff_user = next_user - current_user;
unsigned long long diff_system = next_system - current_system;
unsigned long long diff_nice = next_nice - current_nice;
unsigned long long diff_idle = next_idle - current_idle;
return static_cast<float>( diff_user + diff_system + diff_nice ) /
static_cast<float>( diff_user + diff_system + diff_nice + diff_idle ) *
100.0;
}

65
osx/memory.cc Normal file
View file

@ -0,0 +1,65 @@
/*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* 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 <string>
#include <sstream>
#include <mach/mach.h>
#include <sys/sysctl.h> // for sysctl
#include "memory.h"
#include "conversions.h"
void mem_status( MemoryStatus & status )
{
// These values are in bytes
u_int64_t total_mem;
// float app_mem = 0.0f;
// float cached_file_mem = 0.0f;
float available_mem = 0.0f;
float percentage_mem;
float free_mem;
float free_mem_in_gigabytes; // used to check if free mem < 1 GB
//u_int64_t unused_mem;
vm_size_t page_size;
vm_statistics64_data_t vm_stats; // Use 64-bit VM statistics
// Get total physical memory
int mib[] = { CTL_HW, HW_MEMSIZE };
size_t length = sizeof( total_mem );
sysctl( mib, 2, &total_mem, &length, NULL, 0 );
mach_port_t mach_port = mach_host_self();
// Use HOST_VM_INFO64_COUNT as the count for vm_statistics64_data_t
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
if( KERN_SUCCESS == host_page_size( mach_port, &page_size ) &&
KERN_SUCCESS == host_statistics64( mach_port, HOST_VM_INFO64,
( host_info_t )&vm_stats, &count )
)
{
//unused_mem = static_cast<u_int64_t>( vm_stats.free_count * page_size );
// app_mem = static_cast<float>(( vm_stats.internal_page_count - vm_stats.purgeable_count ) * page_size );
// cached_file_mem = static_cast<float>(( vm_stats.purgeable_count + vm_stats.external_page_count ) * page_size );
available_mem = static_cast<float>(( vm_stats.free_count + vm_stats.external_page_count - vm_stats.speculative_count ) * page_size );
}
status.used_mem = convert_unit(static_cast< float >(total_mem - available_mem ), MEGABYTES );
status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES );
}

View file

@ -1,144 +0,0 @@
/**
* @file cpuusage.cpp
* @brief print out the percent cpu usage at a given interval
* @author Matthew McCormick (thewtex)
* @version
* @date 2009-08-12
*/
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
#include <unistd.h> // sleep
// in seconds
const static unsigned int INTERVAL=1;
class CPUPercentage
{
public:
CPUPercentage();
~CPUPercentage();
const float& get_percentage();
private:
ifstream m_stat_file;
unsigned long long m_current_user;
unsigned long long m_current_system;
unsigned long long m_current_nice;
unsigned long long m_current_idle;
unsigned long long m_next_user;
unsigned long long m_next_system;
unsigned long long m_next_nice;
unsigned long long m_next_idle;
unsigned long long m_diff_user;
unsigned long long m_diff_system;
unsigned long long m_diff_nice;
unsigned long long m_diff_idle;
string m_stat_line;
size_t m_line_start_pos;
size_t m_line_end_pos;
istringstream m_iss;
float m_percentage;
};
CPUPercentage::CPUPercentage():
m_current_user(0),
m_current_system(0),
m_current_nice(0),
m_current_idle(0),
m_next_user(0),
m_next_system(0),
m_next_nice(0),
m_next_idle(0),
m_diff_user(0),
m_diff_system(0),
m_diff_nice(0),
m_diff_idle(0)
{
m_stat_file.exceptions(ifstream::eofbit|ifstream::failbit|ifstream::badbit);
}
CPUPercentage::~CPUPercentage()
{
if(m_stat_file.is_open())
m_stat_file.close();
}
const float& CPUPercentage::get_percentage()
{
m_stat_file.open("/proc/stat");
getline(m_stat_file, m_stat_line);
m_stat_file.close();
// skip "cpu"
m_line_start_pos = m_stat_line.find_first_not_of(" ", 3);
m_line_end_pos = m_stat_line.find_first_of(' ', m_line_start_pos);
m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
m_line_end_pos = m_stat_line.find_first_of(' ', m_line_end_pos + 1);
m_iss.str(m_stat_line.substr(m_line_start_pos, m_line_end_pos - m_line_start_pos));
m_iss >> m_next_user >> m_next_nice >> m_next_system >> m_next_idle;
m_iss.clear();
m_diff_user = m_next_user - m_current_user;
m_diff_system = m_next_system - m_current_system;
m_diff_nice = m_next_nice - m_current_nice;
m_diff_idle = m_next_idle - m_current_idle;
m_percentage = static_cast<float>(m_diff_user + m_diff_system + m_diff_nice)/static_cast<float>(m_diff_user + m_diff_system + m_diff_nice + m_diff_idle)*100.0;
m_current_user = m_next_user;
m_current_system = m_next_system;
m_current_nice = m_next_nice;
m_current_idle = m_next_idle;
return m_percentage;
}
int main(int argc, char** argv)
{
string meter = "[ ]";
int meter_count = 0;
float percentage = 0.0;
CPUPercentage cpu_per;
cout.precision(1);
cout.setf(ios::fixed | ios::right);
cout.width(5);
try
{
while(true)
{
percentage = cpu_per.get_percentage();
meter_count = 1;
while(meter_count*9.99 < percentage)
{
meter[meter_count] = '|';
meter_count++;
}
while(meter_count <= 10)
{
meter[meter_count] = ' ';
meter_count++;
}
cout << meter << ' ';
cout.width(5);
cout << percentage << endl;
sleep(1);
}
}
catch(const exception &e)
{
cerr << "Error: " << e.what() << endl;
return 1;
}
return 0;
}

View file

@ -1,9 +0,0 @@
#!/bin/sh
total_mem=$(/usr/bin/free -m | /usr/bin/awk '$1 == "Mem:" { print $2 }')
while(true); do
current_mem=$(/usr/bin/free -m | /usr/bin/awk '$1 == "-/+" { print $3 }')
echo "${current_mem}MB/${total_mem}MB"
sleep 3
done

BIN
seg-adj1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
seg-adj2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

49
tmux-mem-cpu-load.plugin.tmux Executable file
View file

@ -0,0 +1,49 @@
# 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.
# The directory where this plugin is located.
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -f $CURRENT_DIR/tmux-mem-cpu-load ] && ! $(builtin type -P "tmux-mem-cpu-load" &> /dev/null) ; then
tmux run-shell "echo \"tmux-mem-cpu-load not found. Attempting to build.
\""
pushd $CURRENT_DIR #Pushd to the directory where this plugin is located.
# Attempt to rebuild the plugin and log any errors in the tmux display window.
if output=$(cmake . 2>&1); then
tmux run-shell "echo \"'cmake $CURRENT_DIR' completed successfully.
\""
else
tmux run-shell "echo \"'cmake $CURRENT_DIR' failed. Error logged below.
$output
\""
exit 1
fi
if output=$(cmake --build . 2>&1); then
tmux run-shell "echo \"tmux-mem-cpu-load built successfully.
\""
else
tmux run-shell "echo \"tmux-mem-cpu-load failed to build. Error logged below.
$output
\""
exit 1
fi
popd
fi

View file

@ -0,0 +1,25 @@
# 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.
if [ ! -s /usr/local/bin/tmux-mem-cpu-load ];
then
pushd ${0:a:h} #Pushd to the directory where this plugin is located.
cmake .
make
sudo make install
popd
fi

53
windows/cpu.cc Normal file
View file

@ -0,0 +1,53 @@
/* 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 <string>
#include <fstream>
#include <unistd.h> // usleep
#include <thread>
#include "TCHAR.h"
#include "pdh.h"
static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal;
#include "cpu.h"
#include "luts.h"
uint32_t get_cpu_count()
{
return static_cast< uint32_t >( std::thread::hardware_concurrency() );
}
float cpu_percentage( unsigned cpu_usage_delay )
{
PdhOpenQuery(NULL, 0, &cpuQuery);
PdhAddCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", 0, &cpuTotal);
PdhCollectQueryData(cpuQuery);
usleep( cpu_usage_delay );
PDH_FMT_COUNTERVALUE counterVal;
PdhCollectQueryData(cpuQuery);
PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal);
return static_cast< float >( counterVal.doubleValue );
}

44
windows/load.cc Normal file
View file

@ -0,0 +1,44 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2013 Justin Crawford <Justasic@gmail.com>
* Copyright 2015 Pawel 'l0ner' Soltys
* Copyright 2016 Compilenix
*
* 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.
*/
// Based on: github.com/freebsd/freebsd/blob/master/usr.bin/top/machine.c
// Based on: Apple.cpp for load_string/mem_string and apple's documentation
#include <sstream>
#include <string>
#include <cmath> // floorf()
#include <sys/types.h>
#include "cpu.h"
#include "load.h"
#include "luts.h"
#include "powerline.h"
// Load Averages
std::string load_string( bool use_colors,
bool use_powerline_left, bool use_powerline_right,
short num_averages )
{
// Not implemented
std::ostringstream ss;
ss << (char) 0;
return ss.str();
}

40
windows/memory.cc Normal file
View file

@ -0,0 +1,40 @@
/* 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 <sstream>
#include <fstream>
#include "windows.h"
#include "memory.h"
#include "conversions.h"
void mem_status( MemoryStatus & status )
{
MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(memory_status);
GlobalMemoryStatusEx(&memory_status);
// 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
status.used_mem = convert_unit(static_cast< float >( memory_status.ullAvailPhys ), MEGABYTES, BYTES);
status.total_mem = convert_unit(static_cast< float >( memory_status.ullTotalPhys ), MEGABYTES, BYTES);
}