mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-26 02:31:36 +03:00
Manage disks and network interfaces hidden lists (issue #304)
This commit is contained in:
parent
09079f5b12
commit
4dd4461989
2
NEWS
2
NEWS
@ -1,6 +1,8 @@
|
|||||||
Version 1.7.4
|
Version 1.7.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
* You can hide disk from the IOdisk view using the conf file
|
||||||
|
* You can hide network interface from the Network view using the conf file
|
||||||
* ...
|
* ...
|
||||||
|
|
||||||
Version 1.7.3
|
Version 1.7.3
|
||||||
|
@ -75,6 +75,14 @@ mem_careful=50
|
|||||||
mem_warning=70
|
mem_warning=70
|
||||||
mem_critical=90
|
mem_critical=90
|
||||||
|
|
||||||
|
[iodisk]
|
||||||
|
# Define the list of hidden disks (comma separed)
|
||||||
|
#hide=sda2,sda5
|
||||||
|
|
||||||
|
[network]
|
||||||
|
# Define the list of hidden network interfaces (comma separed)
|
||||||
|
#hide=lo
|
||||||
|
|
||||||
[monitor]
|
[monitor]
|
||||||
# Define the list of processes to monitor
|
# Define the list of processes to monitor
|
||||||
# *** This section is optionnal ***
|
# *** This section is optionnal ***
|
||||||
|
@ -75,6 +75,14 @@ mem_careful=50
|
|||||||
mem_warning=70
|
mem_warning=70
|
||||||
mem_critical=90
|
mem_critical=90
|
||||||
|
|
||||||
|
[iodisk]
|
||||||
|
# Define the list of hidden disks (comma separed)
|
||||||
|
#hide=sda2,sda5
|
||||||
|
|
||||||
|
[network]
|
||||||
|
# Define the list of hidden network interfaces (comma separed)
|
||||||
|
#hide=lo
|
||||||
|
|
||||||
[monitor]
|
[monitor]
|
||||||
# Define the list of processes to monitor
|
# Define the list of processes to monitor
|
||||||
# *** This section is optionnal ***
|
# *** This section is optionnal ***
|
||||||
|
@ -154,7 +154,7 @@ Configuration
|
|||||||
|
|
||||||
No configuration file is mandatory to use Glances.
|
No configuration file is mandatory to use Glances.
|
||||||
|
|
||||||
Furthermore a configuration file is needed for setup limits and/or monitored processes list.
|
Furthermore a configuration file is needed for setup limits, disks or network interfaces to hide and/or monitored processes list.
|
||||||
|
|
||||||
By default, the configuration file is under:
|
By default, the configuration file is under:
|
||||||
|
|
||||||
@ -292,6 +292,8 @@ if the bit rate is higher than 70 Mbps.
|
|||||||
| If bit rate is ``>70%``, then status is set to ``"WARNING"``
|
| If bit rate is ``>70%``, then status is set to ``"WARNING"``
|
||||||
| If bit rate is ``>90%``, then status is set to ``"CRITICAL"``
|
| If bit rate is ``>90%``, then status is set to ``"CRITICAL"``
|
||||||
|
|
||||||
|
*Note*: In the configuration file, you can define a list of network interfaces to hide.
|
||||||
|
|
||||||
Sensors
|
Sensors
|
||||||
-------
|
-------
|
||||||
|
|
||||||
@ -331,6 +333,8 @@ Glances displays the disk I/O throughput. The unit is adapted dynamically.
|
|||||||
|
|
||||||
*Note*: There is no alert on this information.
|
*Note*: There is no alert on this information.
|
||||||
|
|
||||||
|
*Note*: In the configuration file, you can define a list of disk to hide.
|
||||||
|
|
||||||
File system
|
File system
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -592,7 +592,9 @@ class monitorList:
|
|||||||
|
|
||||||
class glancesLimits:
|
class glancesLimits:
|
||||||
"""
|
"""
|
||||||
Manage the limit OK, CAREFUL, WARNING, CRITICAL for each stats
|
Manage limits for each stats. A limit can be:
|
||||||
|
* a set of careful, warning and critical values
|
||||||
|
* a filter (for example: hide some network interfaces)
|
||||||
|
|
||||||
The limit list is stored in an hash table:
|
The limit list is stored in an hash table:
|
||||||
__limits_list[STAT] = [CAREFUL, WARNING, CRITICAL]
|
__limits_list[STAT] = [CAREFUL, WARNING, CRITICAL]
|
||||||
@ -602,6 +604,9 @@ class glancesLimits:
|
|||||||
LOAD is for LOAD limits (5 min/15 min)
|
LOAD is for LOAD limits (5 min/15 min)
|
||||||
TEMP is for sensors limits (temperature in °C)
|
TEMP is for sensors limits (temperature in °C)
|
||||||
HDDTEMP is for hddtemp limits (temperature in °C)
|
HDDTEMP is for hddtemp limits (temperature in °C)
|
||||||
|
FS is for partitions space limits
|
||||||
|
IODISK_HIDE is a list of disk (name) to hide
|
||||||
|
NETWORK_HIDE is a list of network interface (name) to hide
|
||||||
"""
|
"""
|
||||||
__limits_list = {'STD': [50, 70, 90],
|
__limits_list = {'STD': [50, 70, 90],
|
||||||
'CPU_USER': [50, 70, 90],
|
'CPU_USER': [50, 70, 90],
|
||||||
@ -614,7 +619,9 @@ class glancesLimits:
|
|||||||
'HDDTEMP': [45, 52, 60],
|
'HDDTEMP': [45, 52, 60],
|
||||||
'FS': [50, 70, 90],
|
'FS': [50, 70, 90],
|
||||||
'PROCESS_CPU': [50, 70, 90],
|
'PROCESS_CPU': [50, 70, 90],
|
||||||
'PROCESS_MEM': [50, 70, 90]}
|
'PROCESS_MEM': [50, 70, 90],
|
||||||
|
'IODISK_HIDE': [],
|
||||||
|
'NETWORK_HIDE': []}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Test if the configuration file has a limits section
|
# Test if the configuration file has a limits section
|
||||||
@ -672,6 +679,24 @@ class glancesLimits:
|
|||||||
self.__setLimits('PROCESS_MEM', 'process', 'mem_careful')
|
self.__setLimits('PROCESS_MEM', 'process', 'mem_careful')
|
||||||
self.__setLimits('PROCESS_MEM', 'process', 'mem_warning')
|
self.__setLimits('PROCESS_MEM', 'process', 'mem_warning')
|
||||||
self.__setLimits('PROCESS_MEM', 'process', 'mem_critical')
|
self.__setLimits('PROCESS_MEM', 'process', 'mem_critical')
|
||||||
|
if config.has_section('iodisk'):
|
||||||
|
# Hidden disks' list
|
||||||
|
self.__setHidden('IODISK_HIDE', 'iodisk', 'hide')
|
||||||
|
if config.has_section('network'):
|
||||||
|
# Network interfaces' list
|
||||||
|
self.__setHidden('NETWORK_HIDE', 'network', 'hide')
|
||||||
|
|
||||||
|
def __setHidden(self, stat, section, alert='hide'):
|
||||||
|
"""
|
||||||
|
stat: 'IODISK', 'NETWORK'
|
||||||
|
section: 'iodisk', 'network'
|
||||||
|
alert: 'hide'
|
||||||
|
"""
|
||||||
|
value = config.get_raw_option(section, alert)
|
||||||
|
|
||||||
|
# print("%s / %s = %s -> %s" % (section, alert, value, stat))
|
||||||
|
if (value is not None):
|
||||||
|
self.__limits_list[stat] = value.split(",")
|
||||||
|
|
||||||
def __setLimits(self, stat, section, alert):
|
def __setLimits(self, stat, section, alert):
|
||||||
"""
|
"""
|
||||||
@ -681,7 +706,7 @@ class glancesLimits:
|
|||||||
"""
|
"""
|
||||||
value = config.get_option(section, alert)
|
value = config.get_option(section, alert)
|
||||||
|
|
||||||
#~ print("%s / %s = %s -> %s" % (section, alert, value, stat))
|
# print("%s / %s = %s -> %s" % (section, alert, value, stat))
|
||||||
if alert.endswith('careful'):
|
if alert.endswith('careful'):
|
||||||
self.__limits_list[stat][0] = value
|
self.__limits_list[stat][0] = value
|
||||||
elif alert.endswith('warning'):
|
elif alert.endswith('warning'):
|
||||||
@ -696,6 +721,9 @@ class glancesLimits:
|
|||||||
def getAll(self):
|
def getAll(self):
|
||||||
return self.__limits_list
|
return self.__limits_list
|
||||||
|
|
||||||
|
def getHide(self, stat):
|
||||||
|
return self.__limits_list[stat]
|
||||||
|
|
||||||
def getCareful(self, stat):
|
def getCareful(self, stat):
|
||||||
return self.__limits_list[stat][0]
|
return self.__limits_list[stat][0]
|
||||||
|
|
||||||
@ -2913,70 +2941,73 @@ class glancesScreen:
|
|||||||
return 3
|
return 3
|
||||||
|
|
||||||
# Adapt the maximum interface to the screen
|
# Adapt the maximum interface to the screen
|
||||||
ret = 2
|
net_max = min(screen_y - self.network_y - 3, len(network))
|
||||||
net_num = min(screen_y - self.network_y - 3, len(network))
|
net_count = 0
|
||||||
for i in range(0, net_num):
|
for i in range(0, net_max):
|
||||||
elapsed_time = max(1, self.__refresh_time)
|
elapsed_time = max(1, self.__refresh_time)
|
||||||
|
|
||||||
# network interface name
|
# network interface name
|
||||||
#~ ifname = network[i]['interface_name'].encode('ascii', 'ignore').split(':')[0]
|
#~ ifname = network[i]['interface_name'].encode('ascii', 'ignore').split(':')[0]
|
||||||
ifname = network[i]['interface_name'].split(':')[0]
|
ifname = network[i]['interface_name'].split(':')[0]
|
||||||
if len(ifname) > 8:
|
|
||||||
ifname = '_' + ifname[-8:]
|
|
||||||
self.term_window.addnstr(self.network_y + 1 + i,
|
|
||||||
self.network_x, ifname, 8)
|
|
||||||
|
|
||||||
# Byte/s or bit/s
|
if (ifname not in limits.getHide('NETWORK_HIDE')):
|
||||||
if self.net_byteps_tag:
|
net_count += 1
|
||||||
rx_per_sec = self.__autoUnit(network[i]['rx'] // elapsed_time)
|
|
||||||
tx_per_sec = self.__autoUnit(network[i]['tx'] // elapsed_time)
|
|
||||||
# Combined, or total network traffic
|
|
||||||
# cx is combined rx + tx
|
|
||||||
cx_per_sec = self.__autoUnit(network[i]['cx'] // elapsed_time)
|
|
||||||
cumulative_rx = self.__autoUnit(network[i]['cumulative_rx'])
|
|
||||||
cumulative_tx = self.__autoUnit(network[i]['cumulative_tx'])
|
|
||||||
cumulative_cx = self.__autoUnit(network[i]['cumulative_cx'])
|
|
||||||
|
|
||||||
else:
|
if len(ifname) > 8:
|
||||||
rx_per_sec = self.__autoUnit(
|
ifname = '_' + ifname[-8:]
|
||||||
network[i]['rx'] // elapsed_time * 8) + "b"
|
self.term_window.addnstr(self.network_y + net_count,
|
||||||
tx_per_sec = self.__autoUnit(
|
self.network_x, ifname, 8)
|
||||||
network[i]['tx'] // elapsed_time * 8) + "b"
|
|
||||||
# cx is combined rx + tx
|
|
||||||
cx_per_sec = self.__autoUnit(
|
|
||||||
network[i]['cx'] // elapsed_time * 8) + "b"
|
|
||||||
cumulative_rx = self.__autoUnit(
|
|
||||||
network[i]['cumulative_rx'] * 8) + "b"
|
|
||||||
cumulative_tx = self.__autoUnit(
|
|
||||||
network[i]['cumulative_tx'] * 8) + "b"
|
|
||||||
cumulative_cx = self.__autoUnit(
|
|
||||||
network[i]['cumulative_cx'] * 8) + "b"
|
|
||||||
|
|
||||||
if self.network_stats_cumulative:
|
# Byte/s or bit/s
|
||||||
rx = cumulative_rx
|
if self.net_byteps_tag:
|
||||||
tx = cumulative_tx
|
rx_per_sec = self.__autoUnit(network[i]['rx'] // elapsed_time)
|
||||||
cx = cumulative_cx
|
tx_per_sec = self.__autoUnit(network[i]['tx'] // elapsed_time)
|
||||||
else:
|
# Combined, or total network traffic
|
||||||
rx = rx_per_sec
|
# cx is combined rx + tx
|
||||||
tx = tx_per_sec
|
cx_per_sec = self.__autoUnit(network[i]['cx'] // elapsed_time)
|
||||||
cx = cx_per_sec
|
cumulative_rx = self.__autoUnit(network[i]['cumulative_rx'])
|
||||||
|
cumulative_tx = self.__autoUnit(network[i]['cumulative_tx'])
|
||||||
|
cumulative_cx = self.__autoUnit(network[i]['cumulative_cx'])
|
||||||
|
|
||||||
if not self.network_stats_combined:
|
else:
|
||||||
# rx/s
|
rx_per_sec = self.__autoUnit(
|
||||||
self.term_window.addnstr(self.network_y + 1 + i,
|
network[i]['rx'] // elapsed_time * 8) + "b"
|
||||||
self.network_x + 8,
|
tx_per_sec = self.__autoUnit(
|
||||||
format(rx, '>7'), 7)
|
network[i]['tx'] // elapsed_time * 8) + "b"
|
||||||
# tx/s
|
# cx is combined rx + tx
|
||||||
self.term_window.addnstr(self.network_y + 1 + i,
|
cx_per_sec = self.__autoUnit(
|
||||||
self.network_x + 16,
|
network[i]['cx'] // elapsed_time * 8) + "b"
|
||||||
format(tx, '>7'), 7)
|
cumulative_rx = self.__autoUnit(
|
||||||
else:
|
network[i]['cumulative_rx'] * 8) + "b"
|
||||||
# cx/s (Combined, or total)
|
cumulative_tx = self.__autoUnit(
|
||||||
self.term_window.addnstr(self.network_y + 1 + i,
|
network[i]['cumulative_tx'] * 8) + "b"
|
||||||
self.network_x + 16,
|
cumulative_cx = self.__autoUnit(
|
||||||
format(cx, '>7'), 7)
|
network[i]['cumulative_cx'] * 8) + "b"
|
||||||
ret = ret + 1
|
|
||||||
return ret
|
if self.network_stats_cumulative:
|
||||||
|
rx = cumulative_rx
|
||||||
|
tx = cumulative_tx
|
||||||
|
cx = cumulative_cx
|
||||||
|
else:
|
||||||
|
rx = rx_per_sec
|
||||||
|
tx = tx_per_sec
|
||||||
|
cx = cx_per_sec
|
||||||
|
|
||||||
|
if not self.network_stats_combined:
|
||||||
|
# rx/s
|
||||||
|
self.term_window.addnstr(self.network_y + net_count,
|
||||||
|
self.network_x + 8,
|
||||||
|
format(rx, '>7'), 7)
|
||||||
|
# tx/s
|
||||||
|
self.term_window.addnstr(self.network_y + net_count,
|
||||||
|
self.network_x + 16,
|
||||||
|
format(tx, '>7'), 7)
|
||||||
|
else:
|
||||||
|
# cx/s (Combined, or total)
|
||||||
|
self.term_window.addnstr(self.network_y + net_count,
|
||||||
|
self.network_x + 16,
|
||||||
|
format(cx, '>7'), 7)
|
||||||
|
return net_count +2
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def displaySensors(self, sensors, offset_y=0):
|
def displaySensors(self, sensors, offset_y=0):
|
||||||
@ -3074,28 +3105,28 @@ class glancesScreen:
|
|||||||
return 3
|
return 3
|
||||||
|
|
||||||
# Adapt the maximum disk to the screen
|
# Adapt the maximum disk to the screen
|
||||||
disk = 0
|
disk_cpt = 0
|
||||||
disk_num = min(screen_y - self.diskio_y - 3, len(diskio))
|
disk_max = min(screen_y - self.diskio_y - 3, len(diskio))
|
||||||
for disk in range(0, disk_num):
|
for disk in range(0, disk_max):
|
||||||
elapsed_time = max(1, self.__refresh_time)
|
elapsed_time = max(1, self.__refresh_time)
|
||||||
|
|
||||||
# partition name
|
if (diskio[disk]['disk_name'] not in limits.getHide('IODISK_HIDE')):
|
||||||
self.term_window.addnstr(
|
disk_cpt += 1
|
||||||
self.diskio_y + 1 + disk, self.diskio_x,
|
# partition name
|
||||||
diskio[disk]['disk_name'], 8)
|
self.term_window.addnstr(
|
||||||
|
self.diskio_y + disk_cpt, self.diskio_x,
|
||||||
# in/s
|
diskio[disk]['disk_name'], 8)
|
||||||
ins = diskio[disk]['write_bytes'] // elapsed_time
|
# in/s
|
||||||
self.term_window.addnstr(
|
ins = diskio[disk]['write_bytes'] // elapsed_time
|
||||||
self.diskio_y + 1 + disk, self.diskio_x + 10,
|
self.term_window.addnstr(
|
||||||
format(self.__autoUnit(ins), '>5'), 5)
|
self.diskio_y + disk_cpt, self.diskio_x + 10,
|
||||||
|
format(self.__autoUnit(ins), '>5'), 5)
|
||||||
# out/s
|
# out/s
|
||||||
outs = diskio[disk]['read_bytes'] // elapsed_time
|
outs = diskio[disk]['read_bytes'] // elapsed_time
|
||||||
self.term_window.addnstr(
|
self.term_window.addnstr(
|
||||||
self.diskio_y + 1 + disk, self.diskio_x + 18,
|
self.diskio_y + disk_cpt, self.diskio_x + 18,
|
||||||
format(self.__autoUnit(outs), '>5'), 5)
|
format(self.__autoUnit(outs), '>5'), 5)
|
||||||
return disk + 3
|
return disk_cpt + 2
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def displayFs(self, fs, offset_y=0):
|
def displayFs(self, fs, offset_y=0):
|
||||||
|
Loading…
Reference in New Issue
Block a user