Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
a183f681
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a183f681
编写于
10月 21, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add thresholds and update docs (issue #937)
上级
deb42a07
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
58 addition
and
22 deletion
+58
-22
conf/glances.conf
conf/glances.conf
+5
-0
docs/_static/wifi.png
docs/_static/wifi.png
+0
-0
docs/aoa/wifi.rst
docs/aoa/wifi.rst
+14
-3
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+8
-8
glances/plugins/glances_wifi.py
glances/plugins/glances_wifi.py
+31
-11
未找到文件。
conf/glances.conf
浏览文件 @
a183f681
...
...
@@ -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)
...
...
docs/_static/wifi.png
查看替换文件 @
deb42a07
浏览文件 @
a183f681
9.2 KB
|
W:
|
H:
8.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
docs/aoa/wifi.rst
浏览文件 @
a183f681
...
...
@@ -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 hotspot
s' 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 interface
s
:
.. 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.
glances/plugins/glances_plugin.py
浏览文件 @
a183f681
...
...
@@ -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
...
...
glances/plugins/glances_wifi.py
浏览文件 @
a183f681
...
...
@@ -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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录