diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..271c8d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + + +all: + $(CXX) scripts/sysstat.cpp -o scripts/tmux_sysstat + + +clean: + rm -rf tmux_sysstat diff --git a/screenshots/cpu_thresholds.png b/preview/cpu_thresholds.png similarity index 100% rename from screenshots/cpu_thresholds.png rename to preview/cpu_thresholds.png diff --git a/screenshots/intro.png b/preview/intro.png similarity index 100% rename from screenshots/intro.png rename to preview/intro.png diff --git a/scripts/cpu.sh b/scripts/cpu.sh deleted file mode 100755 index adc2223..0000000 --- a/scripts/cpu.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -set -u -set -e - -LC_NUMERIC=C - -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$CURRENT_DIR/helpers.sh" - -cpu_tmp_dir=$(tmux show-option -gqv "@sysstat_cpu_tmp_dir") - -cpu_view_tmpl=$(get_tmux_option "@sysstat_cpu_view_tmpl" 'CPU:#[fg=#{cpu.color}]#{cpu.pused}#[default]') - -cpu_medium_threshold=$(get_tmux_option "@sysstat_cpu_medium_threshold" "30") -cpu_stress_threshold=$(get_tmux_option "@sysstat_cpu_stress_threshold" "80") - -cpu_color_low=$(get_tmux_option "@sysstat_cpu_color_low" "green") -cpu_color_medium=$(get_tmux_option "@sysstat_cpu_color_medium" "yellow") -cpu_color_stress=$(get_tmux_option "@sysstat_cpu_color_stress" "red") - -get_cpu_color(){ - local cpu_used=$1 - - if fcomp "$cpu_stress_threshold" "$cpu_used"; then - echo "$cpu_color_stress"; - elif fcomp "$cpu_medium_threshold" "$cpu_used"; then - echo "$cpu_color_medium"; - else - echo "$cpu_color_low"; - fi -} - -print_cpu_usage() { - local cpu_pused=$(get_cpu_usage_or_collect) - local cpu_color=$(get_cpu_color "$cpu_pused") - - local cpu_view="$cpu_view_tmpl" - cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%.1f%%" "$cpu_pused")}" - cpu_view="${cpu_view//'#{cpu.color}'/$(echo "$cpu_color" | awk '{ print $1 }')}" - cpu_view="${cpu_view//'#{cpu.color2}'/$(echo "$cpu_color" | awk '{ print $2 }')}" - cpu_view="${cpu_view//'#{cpu.color3}'/$(echo "$cpu_color" | awk '{ print $3 }')}" - - echo "$cpu_view" -} - -get_cpu_usage_or_collect() { - local collect_cpu_metric="$cpu_tmp_dir/cpu_collect.metric" - - # read cpu metric from file, otherwise 0 as a temporary null value, until first cpu metric is collected - [ -f "$collect_cpu_metric" ] && cat "$collect_cpu_metric" || echo "0.0" - - start_cpu_collect_if_required >/dev/null 2>&1 -} - -start_cpu_collect_if_required() { - local collect_cpu_pidfile="$cpu_tmp_dir/cpu_collect.pid" - - # check if cpu collect process is running, otherwise start it in background - if [ -f "$collect_cpu_pidfile" ] && ps -p "$(cat "$collect_cpu_pidfile")" > /dev/null 2>&1; then - return; - fi - - jobs >/dev/null 2>&1 - "$CURRENT_DIR/cpu_collect.sh" &>/dev/null & - if [ -n "$(jobs -n)" ]; then - echo "$!" > "${collect_cpu_pidfile}" - else - echo "Failed to start CPU collect job" >&2 - exit 1 - fi -} - -main(){ - print_cpu_usage -} - -main diff --git a/scripts/cpu_collect.sh b/scripts/cpu_collect.sh deleted file mode 100755 index 768caba..0000000 --- a/scripts/cpu_collect.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -LC_NUMERIC=C - -set -u -set -e - -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$CURRENT_DIR/helpers.sh" - -refresh_interval=$(get_tmux_option "status-interval" "5") -samples_count="60" -cpu_metric_file="$(get_tmux_option "@sysstat_cpu_tmp_dir" "/dev/null")/cpu_collect.metric" - -get_cpu_usage() { - if is_osx; then - if command_exists "iostat"; then - iostat -w "$refresh_interval" -c "$samples_count" \ - | stdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }' - else - top -l "$samples_count" -s "$refresh_interval" -n 0 \ - | sed -u -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' \ - | stdbuf -o0 awk '{ print 100-$0 }' - fi - elif ! command_exists "vmstat"; then - if is_freebsd; then - vmstat -n "$refresh_interval" -c "$samples_count" \ - | stdbuf -o0 awk 'NR>2 {print 100-$(NF-0)}' - else - vmstat -n "$refresh_interval" "$samples_count" \ - | stdbuf -o0 awk 'NR>2 {print 100-$(NF-2)}' - fi - else - if is_freebsd; then - top -d"$samples_count" \ - | sed -u -nr '/CPU:/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*id.*/\1/p' \ - | stdbuf -o0 awk '{ print 100-$0 }' - else - top -b -n "$samples_count" -d "$refresh_interval" \ - | sed -u -nr '/%Cpu/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)[[:space:]]*id.*/\1/p' \ - | stdbuf -o0 awk '{ print 100-$0 }' - fi - fi -} - -main() { - get_cpu_usage | while read -r value; do - echo "$value" | tee "$cpu_metric_file" - done -} - -main - diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 92793b3..fd8568c 100755 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -1,12 +1,26 @@ +sysstat_color_map=( + 5fff00 + 87ff00 + afff00 + d7ff00 + ffff00 + ffd700 + ffaf00 + ff8700 + ff5f00 + d70000 + ff0000 +) + get_tmux_option() { local option="$1" local default_value="$2" local option_value="$(tmux show-option -gqv "$option")" if [ -z "$option_value" ]; then - echo "$default_value" + echo "$default_value" else - echo "$option_value" + echo "$option_value" fi } @@ -16,6 +30,28 @@ set_tmux_option() { tmux set-option -gq "$option" "$value" } +get_tmux_option_ex() { + local option=$1 + local default_value=$2 + local force_icon=$3 + if [[ $force_icon == "force" ]]; then + local option_value=$(tmux show-option -gqv "$option") + if [[ $option_value != $default_value ]]; then + set_tmux_option "$option" "$default_value" + fi + fi + local option_value=$(tmux show-option -gqv "$option") + if [[ $force_icon == "custom" ]]; then + echo "$default_value" + elif [[ $force_icon == "force" ]]; then + echo "$option_value" + elif [[ $option_value != "" ]]; then + echo "$option_value" + else + echo "$default_value" + # echo "$option_value" + fi +} is_osx() { [ $(uname) == "Darwin" ] } @@ -52,7 +88,7 @@ fcomp() { # 1048576 - scale to GiB function get_size_scale_factor(){ local size_unit="$1" - case "$size_unit" in + case "$size_unit" in G) echo 1048576;; M) echo 1024;; K) echo 1;; @@ -62,15 +98,15 @@ function get_size_scale_factor(){ # Depending on scale factor, change precision # 12612325K - no digits after floating point # 1261M - no digits after floating point -# 1.1G - 1 digit after floating point +# 1.1G - 1 digit after floating point function get_size_format(){ local size_unit="$1" - case "$size_unit" in + case "$size_unit" in G) echo '%.1f%s';; M) echo '%.0f%s';; K) echo '%.0f%s';; esac } - - + + diff --git a/scripts/loadavg.sh b/scripts/loadavg.sh deleted file mode 100755 index 7152314..0000000 --- a/scripts/loadavg.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -u -set -e - -LC_NUMERIC=C - -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source "$CURRENT_DIR/helpers.sh" - -loadavg_per_cpu_core=$(get_tmux_option "@sysstat_loadavg_per_cpu_core" "true") - -get_num_of_cores(){ - is_osx && sysctl -n hw.ncpu || nproc -} - -main(){ - local num_cores=$([ "$loadavg_per_cpu_core" == "true" ] && get_num_of_cores || echo 1) - - uptime | awk -v num_cores="$num_cores" '{ - sub(/,$/, "", $(NF-2)); - sub(/,$/, "", $(NF-1)); - sub(/,$/, "", $NF); - printf "%.2f %.2f %.2f", $(NF-2)/num_cores, $(NF-1)/num_cores, $NF/num_cores - }' -} - -main diff --git a/scripts/old.scripts/cpu.sh b/scripts/old.scripts/cpu.sh new file mode 100755 index 0000000..ba056d7 --- /dev/null +++ b/scripts/old.scripts/cpu.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash + +set -u +set -e + +LC_NUMERIC=C + +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "$CURRENT_DIR/helpers.sh" + +cpu_tmp_dir=$(tmux show-option -gqv "@sysstat_cpu_tmp_dir") + +cpu_view_tmpl=$(get_tmux_option "@sysstat_cpu_view_tmpl" '#[bg=#3e4452]U:#[fg=#{cpu.color},bg=#3e4452]#{cpu.pused}#[fg=#aab2bf,bg=#3e4452] #[default]') + +cpu_medium_threshold=$(get_tmux_option "@sysstat_cpu_medium_threshold" "30") +cpu_stress_threshold=$(get_tmux_option "@sysstat_cpu_stress_threshold" "80") + +cpu_color_low=$(get_tmux_option "@sysstat_cpu_color_low" "green") +cpu_color_medium=$(get_tmux_option "@sysstat_cpu_color_medium" "yellow") +cpu_color_stress=$(get_tmux_option "@sysstat_cpu_color_stress" "red") + +refresh_interval=$(get_tmux_option_ex "status-interval" "3" "force") +samples_count="1" +cpu_usage_val=0 +cpu_idle_val=0 + +get_cpu_color_old(){ + local cpu_used=$1 + + if fcomp "$cpu_stress_threshold" "$cpu_used"; then + echo "$cpu_color_stress"; + elif fcomp "$cpu_medium_threshold" "$cpu_used"; then + echo "$cpu_color_medium"; + else + echo "$cpu_color_low"; + fi +} + +get_cpu_color(){ + local cpu_used=$1 + + cpu_used=${cpu_used%.*} + cpu_used_num=$((cpu_used / 10)) + if [[ $cpu_used_num -ge 10 ]]; then + cpu_used_num=10 + fi + echo "#${sysstat_color_map[$cpu_used_num]}" +} + + +get_cpu_usage() { + if is_osx; then + echo "======$LINENO" + if command_exists "iostat"; then + cpu_usage_val=$(iostat -w "$refresh_interval" -c "$samples_count" \ + | stdbuf -o0 awk 'NR > 2 { print 100-$(NF-3); }') + else + cpu_usage_val=$(top -l "$samples_count" -s "$refresh_interval" -n 0 \ + | sed -u -nr '/CPU usage/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*idle.*/\1/p' \ + | stdbuf -o0 awk '{ print 100-$0 }') + fi + elif is_linux ; then + if [ ! `command_exists "iostat"` ]; then + sar_output_val=$(env LANG=en_US iostat -c 1 2|grep idle -A 1|tail -n 2) + for item in $sar_output_val; + do + cpu_idle_val=$item + done + cpu_usage_val=$(echo ${cpu_idle_val}|awk '{print 100-$NF}') + elif [ ! `command_exists "sar"` ]; then + sar_output_val=$(env LANG=en_US sar -u 1 1|grep idle -A 1) + for item in $sar_output_val; + do + cpu_idle_val=$item + done + cpu_usage_val=$(echo ${cpu_idle_val}|awk '{print 100-$NF}') + elif [ ! `command_exists "vmstat"` ]; then + if is_freebsd; then + cpu_usage_val=$(vmstat -n "$refresh_interval" -c "$samples_count" \ + | stdbuf -o0 awk 'NR>2 {print 100-$(NF-0)}') + else + cpu_usage_val=$(vmstat -n "$refresh_interval" "$samples_count" \ + | stdbuf -o0 awk 'NR>2 {print 100-$(NF-2)}') + fi + fi + else + if is_freebsd; then + cpu_usage_val=$(top -d"$samples_count" \ + | sed -u -nr '/CPU:/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)%[[:space:]]*id.*/\1/p' \ + | stdbuf -o0 awk '{ print 100-$0 }') + else + cpu_usage_val=$(top -b -n "$samples_count" -d "$refresh_interval" \ + | sed -u -nr '/%Cpu/s/.*,[[:space:]]*([0-9]+[.,][0-9]*)[[:space:]]*id.*/\1/p' \ + | stdbuf -o0 awk '{ print 100-$0 }') + fi + fi +} + +print_cpu_usage() { + local cpu_pused=$cpu_usage_val + local cpu_color=$(get_cpu_color "$cpu_pused") + + local cpu_view="$cpu_view_tmpl" + + get_cpu_usage + cpu_pused=$cpu_usage_val + cpu_color=$(get_cpu_color "$cpu_pused") + + cpu_view="${cpu_view//'#{cpu.pused}'/$(printf "%.1f%%" "$cpu_pused")}" + cpu_view="${cpu_view//'#{cpu.color}'/$(echo "$cpu_color" | awk '{ print $1 }')}" + cpu_view="${cpu_view//'#{cpu.color2}'/$(echo "$cpu_color" | awk '{ print $2 }')}" + cpu_view="${cpu_view//'#{cpu.color3}'/$(echo "$cpu_color" | awk '{ print $3 }')}" + + echo "$cpu_view" +} + +get_cpu_usage_or_collect() { + local collect_cpu_metric="$cpu_tmp_dir/cpu_collect.metric" + + # read cpu metric from file, otherwise 0 as a temporary null value, until first cpu metric is collected + [ -f "$collect_cpu_metric" ] && cat "$collect_cpu_metric" || echo "0.0" + + start_cpu_collect_if_required >/dev/null 2>&1 +} + +start_cpu_collect_if_required() { + local collect_cpu_pidfile="$cpu_tmp_dir/cpu_collect.pid" + + # check if cpu collect process is running, otherwise start it in background + if [ -f "$collect_cpu_pidfile" ] && ps -p "$(cat "$collect_cpu_pidfile")" > /dev/null 2>&1; then + return; + fi + + jobs >/dev/null 2>&1 + "$CURRENT_DIR/cpu_collect.sh" &>/dev/null & + if [ -n "$(jobs -n)" ]; then + echo "$!" > "${collect_cpu_pidfile}" + else + echo "Failed to start CPU collect job" >&2 + exit 1 + fi +} + +main(){ + print_cpu_usage + # get_cpu_color 120.44 +} + +main diff --git a/scripts/old.scripts/helpers.sh b/scripts/old.scripts/helpers.sh new file mode 100755 index 0000000..fd8568c --- /dev/null +++ b/scripts/old.scripts/helpers.sh @@ -0,0 +1,112 @@ + +sysstat_color_map=( + 5fff00 + 87ff00 + afff00 + d7ff00 + ffff00 + ffd700 + ffaf00 + ff8700 + ff5f00 + d70000 + ff0000 +) + +get_tmux_option() { + local option="$1" + local default_value="$2" + local option_value="$(tmux show-option -gqv "$option")" + if [ -z "$option_value" ]; then + echo "$default_value" + else + echo "$option_value" + fi +} + +set_tmux_option() { + local option="$1" + local value="$2" + tmux set-option -gq "$option" "$value" +} + +get_tmux_option_ex() { + local option=$1 + local default_value=$2 + local force_icon=$3 + if [[ $force_icon == "force" ]]; then + local option_value=$(tmux show-option -gqv "$option") + if [[ $option_value != $default_value ]]; then + set_tmux_option "$option" "$default_value" + fi + fi + local option_value=$(tmux show-option -gqv "$option") + if [[ $force_icon == "custom" ]]; then + echo "$default_value" + elif [[ $force_icon == "force" ]]; then + echo "$option_value" + elif [[ $option_value != "" ]]; then + echo "$option_value" + else + echo "$default_value" + # echo "$option_value" + fi +} +is_osx() { + [ $(uname) == "Darwin" ] +} + +is_linux(){ + [ $(uname -s) == "Linux" ] +} + +is_freebsd() { + [ $(uname) == FreeBSD ] +} + +command_exists() { + local command="$1" + type "$command" >/dev/null 2>&1 +} + +# because bash does not support floating-point math +# but awk does +calc() { + local stdin; + read -d '' -u 0 stdin; + awk "BEGIN { print $stdin }"; +} + +# "<" math operator which works with floats, once again based on awk +fcomp() { + awk -v n1="$1" -v n2="$2" 'BEGIN {if (n1 +#include +#include +#include + +enum DispColorSt { + DISP_COLOR_LIGHT_GREEN = 0x5fff00, + DISP_COLOR_GREEN = 0x98c379, + DISP_COLOR_YELLOW = 0xe5c07b, + DISP_COLOR_RED = 0xe06c75, +}; + +// 用来存储内存信息的结构体 +typedef struct { + long long totalMem; + long long freeMem; +} MemoryInfo; + +// 从 /proc/meminfo 文件中读取内存信息 +MemoryInfo getMemoryInfo() { + FILE *fp = fopen("/proc/meminfo", "r"); + if (fp == NULL) { + perror("Failed to open /proc/meminfo"); + exit(EXIT_FAILURE); + } + + MemoryInfo memInfo = {0, 0}; + char line[256]; + + while (fgets(line, sizeof(line), fp)) { + long long value; + if (sscanf(line, "MemTotal: %lld kB", &value) == 1) { + memInfo.totalMem = value; + } + if (sscanf(line, "MemAvailable: %lld kB", &value) == 1) { + memInfo.freeMem = value; + } + // 如果还需要其他内存信息,可以在这里继续添加解析代码 + } + + fclose(fp); + return memInfo; +} + +#include +#include +#include +#include + +// 用来存储CPU时间片的结构体 +typedef struct { + long long user; + long long nice; + long long system; + long long idle; + long long iowait; + long long irq; + long long softirq; + long long steal; + long long guest; + long long guest_nice; +} CpuTime; + +// 从 /proc/stat 文件中读取CPU时间片 +int readCpuTime(CpuTime *result) { + FILE *fp; + char buffer[1024]; + char cpu[5]; + fp = fopen("/proc/stat", "r"); + if (fp == NULL) { + perror("Failed to open /proc/stat"); + return -1; + } + if (fgets(buffer, sizeof(buffer), fp) == NULL) { + perror("Failed to read /proc/stat"); + fclose(fp); + return -1; + } + fclose(fp); + sscanf(buffer, "%s %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld", + cpu, + &result->user, + &result->nice, + &result->system, + &result->idle, + &result->iowait, + &result->irq, + &result->softirq, + &result->steal, + &result->guest, + &result->guest_nice); + return 0; +} + +double calculateCpuUsage(const CpuTime *start, const CpuTime *end) { + long long idle_diff = end->idle - start->idle; + long long total_diff = (end->user + end->nice + end->system + end->idle + end->iowait + end->irq + end->softirq + end->steal) + - (start->user + start->nice + start->system + start->idle + start->iowait + start->irq + start->softirq + start->steal); + if (total_diff == 0) return 0.0; + return (1.0 - ((double)idle_diff / total_diff)) * 100.0; +} + +int cpuUsed() { + double usePercent; + uint32_t disColor; + + CpuTime start, end; + + // 读取第一次CPU时间 + if (readCpuTime(&start) != 0) { + return EXIT_FAILURE; + } + + // 等待一秒 + sleep(1); + + // 读取第二次CPU时间 + if (readCpuTime(&end) != 0) { + return EXIT_FAILURE; + } + + usePercent = calculateCpuUsage(&start, &end); + if (usePercent < 75) { + disColor = DISP_COLOR_GREEN; + } else if (usePercent < 90) { + disColor = DISP_COLOR_YELLOW; + } else { + disColor = DISP_COLOR_RED; + } + // 计算并打印CPU使用率 + // printf("CPU Usage: %.2f%%", calculateCpuUsage(&start, &end)); + printf("#[bg=#3e4452]U:#[fg=#%x,bg=#3e4452]%.2f\%#[fg=#aab2bf,bg=#3e4452]", + disColor,usePercent); + + return EXIT_SUCCESS; +} + +int memUsed() { + int usePercent; + float memDisp; + uint32_t disColor; + + MemoryInfo memInfo = getMemoryInfo(); + + // printf("Total Memory: %lld kB\n", memInfo.totalMem); + // printf("Free Memory: %lld kB\n", memInfo.freeMem); + // // 计算已使用的内存大小 + // printf("Used Memory: %lld kB\n", memInfo.totalMem - memInfo.freeMem); + disColor = 0x98c379; + usePercent = 10000 - 10000*memInfo.freeMem/memInfo.totalMem; + if (usePercent < 7500) { + disColor = DISP_COLOR_GREEN; + } else if (usePercent < 9000) { + disColor = DISP_COLOR_YELLOW; + } else { + disColor = DISP_COLOR_RED; + } + + memDisp = 12.3; + memDisp = usePercent/100.0; + printf(" #[bg=#3e4452]M:#[fg=#%x,bg=#3e4452]%.2f\%#[fg=#aab2bf,bg=#3e4452]  #[default]", + disColor,memDisp); + return 0; +} + +int loadavgStat() +{ + double loadavg[3]; + uint32_t disColor[3]; + int itemCnt; + + long nprocs = -1; + // long nprocs_max = -1; + + nprocs = sysconf(_SC_NPROCESSORS_ONLN); + // nprocs_max = sysconf(_SC_NPROCESSORS_CONF); + + if (nprocs < 1) { + fprintf(stderr, "Could not determine number of CPUs online:\n"); + // return 1; + // } else if (nprocs_max < 1) { + // fprintf(stderr, "Could not determine number of CPUs configured:\n"); + // // return 1; + } + + // printf("Number of CPUs online: %ld\n", nprocs); + // printf("Number of CPUs configured: %ld\n", nprocs_max); + + // 读取负载均衡值 + if (getloadavg(loadavg, 3) == -1) { + perror("loadavgNG"); + return 1; + } + + itemCnt = 0; + while (itemCnt < sizeof(loadavg)/sizeof(loadavg[0])) { + loadavg[itemCnt] = loadavg[itemCnt]/nprocs; + if (loadavg[itemCnt] < 0.75) { + disColor[itemCnt] = DISP_COLOR_GREEN; + } else if (loadavg[itemCnt] < 0.9) { + disColor[itemCnt] = DISP_COLOR_YELLOW; + } else { + disColor[itemCnt] = DISP_COLOR_RED; + } + itemCnt++; + } + // 打印1分钟、5分钟和15分钟的负载均衡值 + // printf("1 minute load average: %.2f\n", loadavg[0]); + // printf("5 minute load average: %.2f\n", loadavg[1]); + // printf("15 minute load average: %.2f\n", loadavg[2]); + printf("#[fg=#%x,bg=#3e4452]%.2f \ +#[default]#[fg=#%x,bg=#3e4452]%.2f \ +#[default]#[fg=#%x,bg=#3e4452]%.2f \ +#[default]#[bg=#3e4452]", + disColor[0],loadavg[0], + disColor[1],loadavg[1], + disColor[2],loadavg[2]); + return 0; +} + +int main(int argc, char *argv[]) +{ + cpuUsed(); + memUsed(); + loadavgStat(); + return 0; +} + + + + diff --git a/sysstat.tmux b/sysstat.tmux index d44efdb..0e86025 100755 --- a/sysstat.tmux +++ b/sysstat.tmux @@ -5,16 +5,10 @@ source "$CURRENT_DIR/scripts/helpers.sh" placeholders=( "\#{sysstat_cpu}" - "\#{sysstat_mem}" - "\#{sysstat_swap}" - "\#{sysstat_loadavg}" ) commands=( - "#($CURRENT_DIR/scripts/cpu.sh)" - "#($CURRENT_DIR/scripts/mem.sh)" - "#($CURRENT_DIR/scripts/swap.sh)" - "#($CURRENT_DIR/scripts/loadavg.sh)" + "#($CURRENT_DIR/scripts/tmux_sysstat)" ) do_interpolation() { @@ -33,11 +27,12 @@ update_tmux_option() { } main() { - cpu_tmp_dir=$(mktemp -d) - tmux set-option -gq "@sysstat_cpu_tmp_dir" "$cpu_tmp_dir" + # cpu_tmp_dir=$(mktemp -d) + # tmux set-option -gq "@sysstat_cpu_tmp_dir" "$cpu_tmp_dir" update_tmux_option "status-right" update_tmux_option "status-left" } -main \ No newline at end of file +main +