mirror of
https://github.com/thewtex/tmux-mem-cpu-load.git
synced 2026-09-14 17:26:17 -04:00
Compare commits
No commits in common. "master" and "v3.8.0" have entirely different histories.
2
.github/workflows/expired.yml
vendored
2
.github/workflows/expired.yml
vendored
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v11
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
exempt-issue-milestones: 'future,alpha,beta,release'
|
||||
|
|
|
|||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
build_type: [Release, Debug]
|
||||
steps:
|
||||
- name: "📥 Checkout Code"
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
|
|
|
|||
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
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
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
|
|
@ -29,26 +29,25 @@ jobs:
|
|||
- 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
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bin-artifact-${{ matrix.arch_name }}
|
||||
name: bin-artifact
|
||||
path: tmux-mem-cpu-load-${{ matrix.arch_name }}.tar.xz
|
||||
retention-days: 1
|
||||
retention-days: 1
|
||||
release:
|
||||
name: release
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: "📥 Checkout Code"
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
- name: get artifact
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: bin-artifact-*
|
||||
merge-multiple: true
|
||||
name: bin-artifact
|
||||
path: .
|
||||
- name: "✅ checksum"
|
||||
run: find . -maxdepth 1 -name "*.tar.xz" | xargs sha256sum > checksum_all.sha256
|
||||
|
|
@ -60,4 +59,4 @@ jobs:
|
|||
files: |
|
||||
LICENSE
|
||||
*.tar.xz
|
||||
*.sha256
|
||||
*.sha256
|
||||
|
|
@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.5)
|
|||
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)
|
||||
set(tmux-mem-cpu-load_VERSION_PATCH 0)
|
||||
#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})
|
||||
|
|
@ -121,7 +121,7 @@ if(BUILD_TESTING)
|
|||
)
|
||||
|
||||
add_test(NAME invalid_graph_lines
|
||||
COMMAND tmux-mem-cpu-load --graph-lines -2
|
||||
COMMAND tmux-mem-cpu-load --graph_lines -2
|
||||
)
|
||||
|
||||
add_test(NAME old_option_specification
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
CPU, RAM, and load monitor for use with tmux_
|
||||
---------------------------------------------
|
||||
|
||||
.. image:: https://travis-ci.org/thewtex/tmux-mem-cpu-load.svg
|
||||
:target: https://travis-ci.org/thewtex/tmux-mem-cpu-load
|
||||
|
||||
.. image:: https://circleci.com/gh/thewtex/tmux-mem-cpu-load.svg?style=svg
|
||||
:target: https://circleci.com/gh/thewtex/tmux-mem-cpu-load
|
||||
|
||||
|
|
@ -96,7 +99,6 @@ Install with Package Managers
|
|||
|
||||
* Gentoo: ``emerge tmux-mem-cpu-load``
|
||||
* Homebrew: ``brew install tmux-mem-cpu-load``
|
||||
* FreeBSD: ``pkg install tmux-mem-cpu-load``
|
||||
|
||||
Build and Install Using Antigen_
|
||||
--------------------------------
|
||||
|
|
@ -120,7 +122,7 @@ Edit ``$HOME/.tmux.conf`` to display the program's output in *status-left* or
|
|||
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]"
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -28,15 +28,12 @@
|
|||
#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__)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
// *BSD or OSX
|
||||
#define CP_INTR 3
|
||||
#define CP_IDLE 4
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ std::string load_string( bool use_colors,
|
|||
std::ostringstream ss;
|
||||
ss.setf( std::ios::fixed, std::ios::floatfield );
|
||||
ss.precision( 2 );
|
||||
double averages[num_averages];
|
||||
// based on: opensource.apple.com/source/Libc/Libc-262/gen/getloadavg.c
|
||||
|
||||
if( num_averages <= 0 || num_averages > 3)
|
||||
{
|
||||
|
|
@ -49,9 +51,6 @@ std::string load_string( bool use_colors,
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -74,8 +74,6 @@ void powerline_char( std::ostringstream & oss, const char dynamic_color[],
|
|||
sprintf(write_color, "%d", static_color);
|
||||
switch( direction )
|
||||
{
|
||||
case NONE:
|
||||
break;
|
||||
case POWERLINE_LEFT:
|
||||
if ( eol )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,21 +66,21 @@ void mem_status( MemoryStatus & status )
|
|||
if( substr.compare( "MemTotal" ) == 0 )
|
||||
{
|
||||
// get total memory
|
||||
total_mem = stol( line.substr( substr_start, substr_len ) );
|
||||
total_mem = stoi( line.substr( substr_start, substr_len ) );
|
||||
}
|
||||
else if( substr.compare( "MemFree" ) == 0 )
|
||||
{
|
||||
used_mem = total_mem - stol( line.substr( substr_start, substr_len ) );
|
||||
used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) );
|
||||
}
|
||||
else if( substr.compare( "Shmem" ) == 0 )
|
||||
{
|
||||
used_mem += stol( line.substr( substr_start, substr_len ) );
|
||||
used_mem += stoi( 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 ) );
|
||||
used_mem -= stoi( line.substr( substr_start, substr_len ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "error.h"
|
||||
#include "cpu.h"
|
||||
|
||||
uint32_t get_cpu_count()
|
||||
uint8_t get_cpu_count()
|
||||
{
|
||||
int cpu_count = 1; // default to 1
|
||||
int mib[2] = { CTL_HW, HW_NCPUONLINE };
|
||||
|
|
@ -35,7 +35,7 @@ uint32_t get_cpu_count()
|
|||
error( "sysctl: error getting cpu count" );
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>( cpu_count );
|
||||
return cpu_count;
|
||||
}
|
||||
|
||||
float cpu_percentage( unsigned int cpu_usage_delay )
|
||||
|
|
@ -55,8 +55,6 @@ float cpu_percentage( unsigned int cpu_usage_delay )
|
|||
|
||||
usleep( cpu_usage_delay );
|
||||
|
||||
size = sizeof( load2 );
|
||||
|
||||
// update cpu times
|
||||
if( sysctl( cpu_ctl, 2, &load2, &size, NULL, 0 ) < 0 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,16 +28,14 @@ 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 used_mem;
|
||||
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
|
||||
vm_statistics_data_t vm_stats;
|
||||
|
||||
// Get total physical memory
|
||||
int mib[] = { CTL_HW, HW_MEMSIZE };
|
||||
|
|
@ -45,21 +43,18 @@ void mem_status( MemoryStatus & status )
|
|||
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;
|
||||
|
||||
mach_msg_type_number_t count = sizeof( vm_stats ) / sizeof( natural_t );
|
||||
if( KERN_SUCCESS == host_page_size( mach_port, &page_size ) &&
|
||||
KERN_SUCCESS == host_statistics64( mach_port, HOST_VM_INFO64,
|
||||
KERN_SUCCESS == host_statistics( mach_port, HOST_VM_INFO,
|
||||
( 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 );
|
||||
|
||||
used_mem = static_cast<float>(
|
||||
( vm_stats.active_count + vm_stats.wire_count ) * page_size);
|
||||
}
|
||||
|
||||
status.used_mem = convert_unit(static_cast< float >(total_mem - available_mem ), MEGABYTES );
|
||||
status.used_mem = convert_unit(static_cast< float >( used_mem ), MEGABYTES );
|
||||
status.total_mem = convert_unit(static_cast< float >( total_mem ), MEGABYTES );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if [ ! -f $CURRENT_DIR/tmux-mem-cpu-load ] && ! $(builtin type -P "tmux-mem-cpu-
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if output=$(cmake --build . 2>&1); then
|
||||
if output=$(make 2>&1); then
|
||||
tmux run-shell "echo \"tmux-mem-cpu-load built successfully.
|
||||
\""
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue