mirror of https://github.com/nicolargo/glances.git
Add thresholds and update docs (issue #937)
This commit is contained in:
parent
deb42a075f
commit
a183f68101
|
|
@ -114,6 +114,11 @@ critical=90
|
|||
[wifi]
|
||||
# Define the list of hidden wireless network interfaces (comma-separated regexp)
|
||||
hide=lo,docker.*
|
||||
# Define SIGNAL thresholds in db (lower is better...)
|
||||
# Based on: http://serverfault.com/questions/501025/industry-standard-for-minimum-wifi-signal-strength
|
||||
careful=-65
|
||||
warning=-75
|
||||
critical=-85
|
||||
|
||||
#[diskio]
|
||||
# Define the list of hidden disks (comma-separated regexp)
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.5 KiB |
|
|
@ -5,14 +5,25 @@ Wifi
|
|||
|
||||
.. image:: ../_static/wifi.png
|
||||
|
||||
Glances displays the Wifi hotspot name and quality where the host is connected.
|
||||
Glances displays the Wifi hotspots' name and signal quality.
|
||||
If Glances is ran as root, then all the available hotspots are displayed.
|
||||
|
||||
In the configuration file, you can define signal quality thresholds.
|
||||
"Poor" quality is between -100 and -85dBm, "Good" quality between -85
|
||||
and -60dBm, and "Excellent" between -60 and -40dBm.
|
||||
|
||||
It's also possible to disable the scan on a specific interface from the
|
||||
configuration file (``[network]`` section). For example, if you want to
|
||||
hide the loopback interface (lo) and all the virtual docker interface:
|
||||
configuration file (``[wifi]`` section). For example, if you want to
|
||||
hide the loopback interface (lo) and all the virtual docker interfaces:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[wifi]
|
||||
hide=lo,docker.*
|
||||
# Define SIGNAL thresholds in dBm (lower is better...)
|
||||
careful=-65
|
||||
warning=-75
|
||||
critical=-85
|
||||
|
||||
You can disable this plugin using the --disable-wifi option or by heating
|
||||
the 'W' from the user interface.
|
||||
|
|
|
|||
|
|
@ -503,11 +503,11 @@ class GlancesPlugin(object):
|
|||
# If is_max is set then display the value in MAX
|
||||
ret = 'MAX' if is_max else 'OK'
|
||||
try:
|
||||
if value > self.__get_limit('critical', stat_name=stat_name):
|
||||
if value >= self.get_limit('critical', stat_name=stat_name):
|
||||
ret = 'CRITICAL'
|
||||
elif value > self.__get_limit('warning', stat_name=stat_name):
|
||||
elif value >= self.get_limit('warning', stat_name=stat_name):
|
||||
ret = 'WARNING'
|
||||
elif value > self.__get_limit('careful', stat_name=stat_name):
|
||||
elif value >= self.get_limit('careful', stat_name=stat_name):
|
||||
ret = 'CAREFUL'
|
||||
elif current < minimum:
|
||||
ret = 'CAREFUL'
|
||||
|
|
@ -516,7 +516,7 @@ class GlancesPlugin(object):
|
|||
|
||||
# Manage log
|
||||
log_str = ""
|
||||
if self.__get_limit_log(stat_name=stat_name, default_action=log):
|
||||
if self.get_limit_log(stat_name=stat_name, default_action=log):
|
||||
# Add _LOG to the return string
|
||||
# So stats will be highlited with a specific color
|
||||
log_str = "_LOG"
|
||||
|
|
@ -537,7 +537,7 @@ class GlancesPlugin(object):
|
|||
"""Manage the action for the current stat"""
|
||||
# Here is a command line for the current trigger ?
|
||||
try:
|
||||
command = self.__get_limit_action(trigger, stat_name=stat_name)
|
||||
command = self.get_limit_action(trigger, stat_name=stat_name)
|
||||
except KeyError:
|
||||
# Reset the trigger
|
||||
self.actions.set(stat_name, trigger)
|
||||
|
|
@ -578,7 +578,7 @@ class GlancesPlugin(object):
|
|||
action_key=action_key,
|
||||
log=True)
|
||||
|
||||
def __get_limit(self, criticity, stat_name=""):
|
||||
def get_limit(self, criticity, stat_name=""):
|
||||
"""Return the limit value for the alert."""
|
||||
# Get the limit for stat + header
|
||||
# Exemple: network_wlan0_rx_careful
|
||||
|
|
@ -594,7 +594,7 @@ class GlancesPlugin(object):
|
|||
# Return the limit
|
||||
return limit
|
||||
|
||||
def __get_limit_action(self, criticity, stat_name=""):
|
||||
def get_limit_action(self, criticity, stat_name=""):
|
||||
"""Return the action for the alert."""
|
||||
# Get the action for stat + header
|
||||
# Exemple: network_wlan0_rx_careful_action
|
||||
|
|
@ -608,7 +608,7 @@ class GlancesPlugin(object):
|
|||
# Return the action list
|
||||
return ret
|
||||
|
||||
def __get_limit_log(self, stat_name, default_action=False):
|
||||
def get_limit_log(self, stat_name, default_action=False):
|
||||
"""Return the log tag for the alert."""
|
||||
# Get the log tag for stat + header
|
||||
# Exemple: network_wlan0_rx_log
|
||||
|
|
|
|||
|
|
@ -129,19 +129,36 @@ class Plugin(GlancesPlugin):
|
|||
|
||||
return self.stats
|
||||
|
||||
def get_alert(self, value):
|
||||
"""Overwrite the default get_alert method.
|
||||
Alert is on signal quality where lower is better...
|
||||
|
||||
:returns: string -- Signal alert
|
||||
"""
|
||||
|
||||
ret = 'OK'
|
||||
try:
|
||||
if value <= self.get_limit('critical', stat_name=self.plugin_name):
|
||||
ret = 'CRITICAL'
|
||||
elif value <= self.get_limit('warning', stat_name=self.plugin_name):
|
||||
ret = 'WARNING'
|
||||
elif value <= self.get_limit('careful', stat_name=self.plugin_name):
|
||||
ret = 'CAREFUL'
|
||||
except KeyError:
|
||||
ret = 'DEFAULT'
|
||||
|
||||
return ret
|
||||
|
||||
def update_views(self):
|
||||
"""Update stats views."""
|
||||
# Call the father's method
|
||||
super(Plugin, self).update_views()
|
||||
|
||||
# Add specifics informations
|
||||
# Alert
|
||||
# for i in self.stats:
|
||||
# ifrealname = i['interface_name'].split(':')[0]
|
||||
# self.views[i[self.get_key()]]['rx']['decoration'] = self.get_alert(int(i['rx'] // i['time_since_update'] * 8),
|
||||
# header=ifrealname + '_rx')
|
||||
# self.views[i[self.get_key()]]['tx']['decoration'] = self.get_alert(int(i['tx'] // i['time_since_update'] * 8),
|
||||
# header=ifrealname + '_tx')
|
||||
# Alert on signal thresholds
|
||||
for i in self.stats:
|
||||
self.views[i[self.get_key()]]['signal']['decoration'] = self.get_alert(i['signal'])
|
||||
self.views[i[self.get_key()]]['quality']['decoration'] = self.views[i[self.get_key()]]['signal']['decoration']
|
||||
|
||||
def msg_curse(self, args=None, max_width=None):
|
||||
"""Return the dict to display in the curse interface."""
|
||||
|
|
@ -163,15 +180,15 @@ class Plugin(GlancesPlugin):
|
|||
# Header
|
||||
msg = '{:{width}}'.format('WIFI', width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
msg = '{:>6}'.format('Quality')
|
||||
msg = '{:>7}'.format('dBm')
|
||||
ret.append(self.curse_add_line(msg))
|
||||
|
||||
# Hotspot list (sorted by name)
|
||||
for i in sorted(self.stats, key=operator.itemgetter(self.get_key())):
|
||||
ret.append(self.curse_new_line())
|
||||
# Do not display hotspot with no name (/ssid)
|
||||
if i['ssid'] == '':
|
||||
continue
|
||||
ret.append(self.curse_new_line())
|
||||
# New hotspot
|
||||
hotspotname = i['ssid']
|
||||
# Add the encryption type (if it is available)
|
||||
|
|
@ -183,7 +200,10 @@ class Plugin(GlancesPlugin):
|
|||
# Add the new hotspot to the message
|
||||
msg = '{:{width}}'.format(hotspotname, width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>7}'.format(i['quality'], width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>7}'.format(i['signal'], width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg,
|
||||
self.get_views(item=i[self.get_key()],
|
||||
key='signal',
|
||||
option='decoration')))
|
||||
|
||||
return ret
|
||||
|
|
|
|||
Loading…
Reference in New Issue