Skip to content

Commit

Permalink
hide_zero=True option not working in the WebUI #2987
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Oct 26, 2024
1 parent 5b091f4 commit ffba4ca
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 19 deletions.
9 changes: 9 additions & 0 deletions conf/glances.conf
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ hide_zero=False
#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
38 changes: 26 additions & 12 deletions glances/outputs/static/js/components/plugin-diskio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
<td scope="row">
{{ $filters.minSize(disk.alias ? disk.alias : disk.name, 32) }}
</td>
<td class="text-end w-25" v-show="!args.diskio_iops">
<td class="text-end w-25" :class="getDecoration(disk.name, 'write_bytes_rate_per_sec')"
v-show="!args.diskio_iops">
{{ disk.bitrate.txps }}
</td>
<td class="text-end w-25" v-show="!args.diskio_iops">
<td class="text-end w-25" :class="getDecoration(disk.name, 'read_bytes_rate_per_sec')"
v-show="!args.diskio_iops">
{{ disk.bitrate.rxps }}
</td>
<td class="text-end w-25" v-show="args.diskio_iops">
<td class="text-end w-25" :class="getDecoration(disk.name, 'write_bytes_rate_per_sec')"
v-show="args.diskio_iops">
{{ disk.count.txps }}
</td>
<td class="text-end w-25" v-show="args.diskio_iops">
<td class="text-end w-25" :class="getDecoration(disk.name, 'read_bytes_rate_per_sec')"
v-show="args.diskio_iops">
{{ disk.count.rxps }}
</td>
</tr>
Expand Down Expand Up @@ -56,27 +60,37 @@ export default {
stats() {
return this.data.stats['diskio'];
},
view() {
return this.data.views['diskio'];
},
disks() {
const disks = this.stats.map((diskioData) => {
const timeSinceUpdate = diskioData['time_since_update'];
return {
name: diskioData['disk_name'],
alias: diskioData['alias'] !== undefined ? diskioData['alias'] : null,
bitrate: {
txps: bytes(diskioData['read_bytes'] / timeSinceUpdate),
rxps: bytes(diskioData['write_bytes'] / timeSinceUpdate)
txps: bytes(diskioData['read_bytes_rate_per_sec']),
rxps: bytes(diskioData['write_bytes_rate_per_sec'])
},
count: {
txps: bytes(diskioData['read_count'] / timeSinceUpdate),
rxps: bytes(diskioData['write_count'] / timeSinceUpdate)
},
alias: diskioData['alias'] !== undefined ? diskioData['alias'] : null
txps: bytes(diskioData['read_count_rate_per_sec']),
rxps: bytes(diskioData['write_count_rate_per_sec'])
}
};
});
}).filter(disk => (this.view[disk.name]['read_bytes_rate_per_sec'].hidden === false) && (this.view[disk.name]['write_bytes_rate_per_sec'].hidden === false));
return orderBy(disks, ['name']);
},
hasDisks() {
return this.disks.length > 0;
}
},
methods: {
getDecoration(diskName, field) {
if (this.view[diskName][field] == undefined) {
return;
}
return this.view[diskName][field].decoration.toLowerCase();
}
}
};
</script>
28 changes: 22 additions & 6 deletions glances/outputs/static/js/components/plugin-network.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
<td scope="row" class="visible-lg-inline">
{{ network.ifname }}
</td>
<td class="text-end w-25" v-show="!args.network_cumul && !args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_recv_rate_per_sec) : $filters.bits(network.bytes_recv_rate_per_sec) }}
<td class="text-end w-25" :class="getDecoration(network.interfaceName, 'bytes_recv_rate_per_sec')"
v-show="!args.network_cumul && !args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_recv_rate_per_sec) :
$filters.bits(network.bytes_recv_rate_per_sec) }}
</td>
<td class="text-end w-25" v-show="!args.network_cumul && !args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_sent_rate_per_sec) : $filters.bits(network.bytes_sent_rate_per_sec) }}
<td class="text-end w-25" :class="getDecoration(network.interfaceName, 'bytes_sent_rate_per_sec')"
v-show="!args.network_cumul && !args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_sent_rate_per_sec) :
$filters.bits(network.bytes_sent_rate_per_sec) }}
</td>
<td class="text-end w-25" v-show="!args.network_cumul && args.network_sum"></td>
<td class="text-end w-25" v-show="!args.network_cumul && args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_all_rate_per_sec) : $filters.bits(network.bytes_all_rate_per_sec) }}
{{ args.byte ? $filters.bytes(network.bytes_all_rate_per_sec) :
$filters.bits(network.bytes_all_rate_per_sec) }}
</td>
<td class="text-end w-25" v-show="args.network_cumul && !args.network_sum">
{{ args.byte ? $filters.bytes(network.bytes_recv) : $filters.bits(network.bytes_recv) }}
Expand Down Expand Up @@ -67,6 +72,9 @@ export default {
stats() {
return this.data.stats['network'];
},
view() {
return this.data.views['network'];
},
networks() {
const networks = this.stats.map((networkData) => {
const alias = networkData['alias'] !== undefined ? networkData['alias'] : null;
Expand All @@ -83,12 +91,20 @@ export default {
};
return network;
});
}).filter(network => (this.view[network.interfaceName]['bytes_recv_rate_per_sec'].hidden === false) && (this.view[network.interfaceName]['bytes_sent_rate_per_sec'].hidden === false));
return orderBy(networks, ['interfaceName']);
},
hasNetworks() {
return this.networks.length > 0;
}
},
methods: {
getDecoration(interfaceName, field) {
if (this.view[interfaceName][field] == undefined) {
return;
}
return this.view[interfaceName][field].decoration.toLowerCase();
}
}
};
</script>
2 changes: 1 addition & 1 deletion glances/outputs/static/public/glances.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions glances/plugins/diskio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def update_views(self):
# Add specifics information
# Alert
for i in self.get_raw():
# Skip alert if no timespan to measure
if 'read_bytes_rate_per_sec' not in i or 'write_bytes_rate_per_sec' not in i:
continue

disk_real_name = i['disk_name']
self.views[i[self.get_key()]]['read_bytes']['decoration'] = self.get_alert(
i['read_bytes'], header=disk_real_name + '_rx'
Expand Down
2 changes: 2 additions & 0 deletions glances/plugins/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ def update_views(self):

# then decorates
self.views[i[self.get_key()]]['bytes_recv']['decoration'] = alert_rx
self.views[i[self.get_key()]]['bytes_recv_rate_per_sec']['decoration'] = alert_rx
self.views[i[self.get_key()]]['bytes_sent']['decoration'] = alert_tx
self.views[i[self.get_key()]]['bytes_sent_rate_per_sec']['decoration'] = alert_rx

def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
Expand Down

0 comments on commit ffba4ca

Please sign in to comment.