Skip to content

Commit

Permalink
Merge branch 'issue1524' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Nov 11, 2024
2 parents e1cd3de + 172dda9 commit 1054358
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 140 deletions.
4 changes: 4 additions & 0 deletions conf/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ disable=False
# Should be one of the following:
# cpu_percent, memory_percent, io_counters, name, cpu_times, username
#sort_key=memory_percent
# List of stats to disable (not grabed and not display)
# Stats that can be disabled: cpu_percent,memory_info,memory_percent,username,cpu_times,num_threads,nice,status,io_counters,cmdline
# Stats that can not be disable: pid,name
#disable_stats=cpu_percent,memory_info,memory_percent,username,cpu_times,num_threads,nice,status,io_counters,cmdline
# Define CPU/MEM (per process) thresholds in %
# Default values if not defined: 50/70/90
cpu_careful=50
Expand Down
23 changes: 19 additions & 4 deletions docker-compose/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ hide_no_up=True
hide_no_ip=True
# Set hide_zero to True to automatically hide interface with no traffic
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide interface with traffic less than this value
hide_threshold_bytes=0
# Set hide_threshold_bytes to an integer value to automatically hide
# interface with traffic less or equal than this value
#hide_threshold_bytes=0
# It is possible to overwrite the bitrate thresholds per interface
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
#wlan0_rx_careful=4000000
Expand Down Expand Up @@ -286,12 +287,22 @@ disable=False
hide=loop.*,/dev/loop.*
# Set hide_zero to True to automatically hide disk with no read/write
hide_zero=False
# Set hide_threshold_bytes to an integer value to automatically hide disk with read/write less than this value
hide_threshold_bytes=0
# Set hide_threshold_bytes to an integer value to automatically hide
# interface with traffic less or equal than this value
#hide_threshold_bytes=0
# Define the list of disks to be show (comma-separated)
#show=sda.*
# Alias for sda1 and sdb1
#alias=sda1:SystemDisk,sdb1:DataDisk
# Set thresholds (in bytes per second) for a given disk name (rx = read / tx = write)
#dm-0_rx_careful=4000000000
#dm-0_rx_warning=5000000000
#dm-0_rx_critical=6000000000
#dm-0_rx_log=True
#dm-0_tx_careful=700000000
#dm-0_tx_warning=900000000
#dm-0_tx_critical=1000000000
#dm-0_tx_log=True

[fs]
disable=False
Expand Down Expand Up @@ -399,6 +410,10 @@ disable=False
# Should be one of the following:
# cpu_percent, memory_percent, io_counters, name, cpu_times, username
#sort_key=memory_percent
# List of stats to disable (not grabed and not display)
# Stats that can be disabled: cpu_percent,memory_info,memory_percent,username,cpu_times,num_threads,nice,status,io_counters,cmdline
# Stats that can not be disable: pid,name
#disable_stats=cpu_percent,memory_info,memory_percent,username,cpu_times,num_threads,nice,status,io_counters,cmdline
# Define CPU/MEM (per process) thresholds in %
# Default values if not defined: 50/70/90
cpu_careful=50
Expand Down
6 changes: 3 additions & 3 deletions glances/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from glances.config import Config
from glances.globals import WINDOWS, disable, enable
from glances.logger import LOG_FILENAME, logger
from glances.processes import sort_processes_key_list
from glances.processes import sort_processes_stats_list


class GlancesMain:
Expand Down Expand Up @@ -269,8 +269,8 @@ def init_args(self):
parser.add_argument(
'--sort-processes',
dest='sort_processes_key',
choices=sort_processes_key_list,
help='Sort processes by: {}'.format(', '.join(sort_processes_key_list)),
choices=sort_processes_stats_list,
help='Sort processes by: {}'.format(', '.join(sort_processes_stats_list)),
)
# Display processes list by program name and not by thread
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions glances/outputs/glances_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from glances.logger import logger
from glances.outputs.glances_colors import GlancesColors
from glances.outputs.glances_unicode import unicode_message
from glances.processes import glances_processes, sort_processes_key_list
from glances.processes import glances_processes, sort_processes_stats_list
from glances.timer import Timer

# Import curses library for "normal" operating system
Expand Down Expand Up @@ -97,7 +97,7 @@ class _GlancesCurses:
# 'DOWN' > Down in the server list
}

_sort_loop = sort_processes_key_list
_sort_loop = sort_processes_stats_list

# Define top menu
_top = ['quicklook', 'cpu', 'percpu', 'gpu', 'mem', 'memswap', 'load']
Expand Down
98 changes: 55 additions & 43 deletions glances/outputs/static/js/components/plugin-processlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,108 +3,117 @@
<table class="table table-sm table-borderless table-striped table-hover">
<thead>
<tr>
<td scope="col"
:class="['sortable', sorter.column === 'cpu_percent' && 'sort']"
@click="$emit('update:sorter', 'cpu_percent')">
<td scope="col" :class="['sortable', sorter.column === 'cpu_percent' && 'sort']"
@click="$emit('update:sorter', 'cpu_percent')"
v-show="!getDisableStats().includes('cpu_percent')">
CPU%
</td>
<td scope="col"
:class="['sortable', sorter.column === 'memory_percent' && 'sort']"
@click="$emit('update:sorter', 'memory_percent')">
<td scope="col" :class="['sortable', sorter.column === 'memory_percent' && 'sort']"
@click="$emit('update:sorter', 'memory_percent')"
v-show="!getDisableStats().includes('memory_percent')">
MEM%
</td>
<td scope="col" class="hidden-xs hidden-sm">
<td scope="col" class="hidden-xs hidden-sm" v-show="!getDisableStats().includes('memory_info')">
VIRT
</td>
<td scope="col" class="hidden-xs hidden-sm">
<td scope="col" class="hidden-xs hidden-sm" v-show="!getDisableStats().includes('memory_info')">
RES
</td>
<td scope="col">
<td scope="col" v-show="!getDisableStats().includes('pid')">
PID
</td>
<td scope="row" :class="['sortable', sorter.column === 'username' && 'sort']"
@click="$emit('update:sorter', 'username')">
@click="$emit('update:sorter', 'username')" v-show="!getDisableStats().includes('username')">
USER
</td>
<td scope="row" class="hidden-xs hidden-sm"
:class="['sortable', sorter.column === 'timemillis' && 'sort']"
@click="$emit('update:sorter', 'timemillis')">
@click="$emit('update:sorter', 'timemillis')" v-show="!getDisableStats().includes('cpu_times')">
TIME+
</td>
<td scope="row" class="hidden-xs hidden-sm"
:class="['sortable', sorter.column === 'num_threads' && 'sort']"
@click="$emit('update:sorter', 'num_threads')">
@click="$emit('update:sorter', 'num_threads')"
v-show="!getDisableStats().includes('num_threads')">
THR
</td>
<td scope="row">NI</td>
<td scope="row" class="table-cell widtd-60">S</td>
<td scope="row"
v-show="ioReadWritePresent"
class="hidden-xs hidden-sm"
:class="['sortable', sorter.column === 'io_counters' && 'sort']"
<td scope="row" v-show="!getDisableStats().includes('nice')">NI</td>
<td scope="row" class="table-cell widtd-60" v-show="!getDisableStats().includes('status')">S
</td>
<td scope="row" v-show="ioReadWritePresent && !getDisableStats().includes('io_counters')"
class="hidden-xs hidden-sm" :class="['sortable', sorter.column === 'io_counters' && 'sort']"
@click="$emit('update:sorter', 'io_counters')">
IOR/s
</td>
<td scope="row"
v-show="ioReadWritePresent" class="text-start hidden-xs hidden-sm"
<td scope="row" v-show="ioReadWritePresent && !getDisableStats().includes('io_counters')"
class="text-start hidden-xs hidden-sm"
:class="['sortable', sorter.column === 'io_counters' && 'sort']"
@click="$emit('update:sorter', 'io_counters')">
IOW/s
</td>
<td scope="row"
:class="['sortable', sorter.column === 'name' && 'sort']"
@click="$emit('update:sorter', 'name')">
<td scope="row" :class="['sortable', sorter.column === 'name' && 'sort']"
@click="$emit('update:sorter', 'name')" v-show="!getDisableStats().includes('cmdline')">
Command
</td>
</tr>
</thead>
<tbody>
<tr v-for="(process, processId) in processes" :key="processId">
<td scope="row" :class="getCpuPercentAlert(process)">
<td scope="row" :class="getCpuPercentAlert(process)"
v-show="!getDisableStats().includes('cpu_percent')">
{{ process.cpu_percent == -1 ? '?' : $filters.number(process.cpu_percent, 1) }}
</td>
<td scope="row" :class="getMemoryPercentAlert(process)">
<td scope="row" :class="getMemoryPercentAlert(process)"
v-show="!getDisableStats().includes('memory_percent')">
{{ process.memory_percent == -1 ? '?' : $filters.number(process.memory_percent, 1) }}
</td>
<td scope="row">
<td scope="row" v-show="!getDisableStats().includes('memory_info')">
{{ $filters.bytes(process.memvirt) }}
</td>
<td scope="row">
<td scope="row" v-show="!getDisableStats().includes('memory_info')">
{{ $filters.bytes(process.memres) }}
</td>
<td scope="row">
<td scope="row" v-show="!getDisableStats().includes('pid')">
{{ process.pid }}
</td>
<td scope="row">
<td scope="row" v-show="!getDisableStats().includes('username')">
{{ process.username }}
</td>
<td scope="row" class="hidden-xs hidden-sm" v-if="process.timeplus != '?'">
<td scope="row" class="hidden-xs hidden-sm" v-if="process.timeplus != '?'"
v-show="!getDisableStats().includes('cpu_times')">
<span v-show="process.timeplus.hours > 0" class="highlight">{{ process.timeplus.hours }}h</span>
{{ $filters.leftPad(process.timeplus.minutes, 2, '0') }}:{{ $filters.leftPad(process.timeplus.seconds,
2, '0') }}
<span v-show="process.timeplus.hours <= 0">.{{ $filters.leftPad(process.timeplus.milliseconds, 2, '0')
}}</span>
</td>
<td scope="row" class="hidden-xs hidden-sm" v-if="process.timeplus == '?'">?</td>
<td scope="row" class="hidden-xs hidden-sm">
{{ $filters.leftPad(process.timeplus.minutes, 2, '0') }}:{{
$filters.leftPad(process.timeplus.seconds,
2, '0') }}
<span v-show="process.timeplus.hours <= 0">.{{ $filters.leftPad(process.timeplus.milliseconds,
2, '0')
}}</span>
</td>
<td scope="row" class="hidden-xs hidden-sm" v-if="process.timeplus == '?'"
v-show="!getDisableStats().includes('cpu_times')">?</td>
<td scope="row" class="hidden-xs hidden-sm" v-show="!getDisableStats().includes('num_threads')">
{{ process.num_threads == -1 ? '?' : process.num_threads }}
</td>
<td scope="row" :class="{ nice: process.isNice }">
<td scope="row" :class="{ nice: process.isNice }" v-show="!getDisableStats().includes('nice')">
{{ $filters.exclamation(process.nice) }}
</td>
<td scope="row" :class="{ status: process.status == 'R' }">
<td scope="row" :class="{ status: process.status == 'R' }"
v-show="!getDisableStats().includes('status')">
{{ process.status }}
</td>
<td scope="row" class="hidden-xs hidden-sm" v-show="ioReadWritePresent">
<td scope="row" class="hidden-xs hidden-sm"
v-show="ioReadWritePresent && !getDisableStats().includes('io_counters')">
{{ $filters.bytes(process.io_read) }}
</td>
<td scope="row" class="hidden-xs hidden-sm" v-show="ioReadWritePresent">
<td scope="row" class="hidden-xs hidden-sm"
v-show="ioReadWritePresent && !getDisableStats().includes('io_counters')">
{{ $filters.bytes(process.io_write) }}
</td>
<td scope="row" class="text-truncate" v-show="args.process_short_name">
<td scope="row" class="text-truncate"
v-show="args.process_short_name && !getDisableStats().includes('cmdline')">
{{ process.name }}
</td>
<td scope="row" v-show="!args.process_short_name">
<td scope="row" v-show="!args.process_short_name && !getDisableStats().includes('cmdline')">
{{ process.cmdline }}
</td>
</tr>
Expand Down Expand Up @@ -230,6 +239,9 @@ export default {
},
getMemoryPercentAlert(process) {
return GlancesHelper.getAlert('processlist', 'processlist_mem_', process.cpu_percent);
},
getDisableStats() {
return GlancesHelper.getLimit('processlist', 'processlist_disable_stats') || [];
}
}
};
Expand Down
9 changes: 9 additions & 0 deletions glances/outputs/static/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class GlancesHelperService {
this.limits = limits;
}

getLimit(pluginName, limitName) {
if (this.limits[pluginName] != undefined) {
if (this.limits[pluginName][limitName] != undefined) {
return this.limits[pluginName][limitName]
}
}
return null
}

getAlert(pluginName, limitNamePrefix, current, maximum, log) {
current = current || 0;
maximum = maximum || 100;
Expand Down
Loading

0 comments on commit 1054358

Please sign in to comment.