Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
f5ea9e8f
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,体验更适合开发者的 AI 搜索 >>
提交
f5ea9e8f
编写于
10月 07, 2019
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add color to nf_conn-track'
上级
7c87d343
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
26 deletion
+27
-26
conf/glances.conf
conf/glances.conf
+5
-1
docs/aoa/connections.rst
docs/aoa/connections.rst
+6
-2
glances/plugins/glances_connections.py
glances/plugins/glances_connections.py
+13
-23
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+3
-0
未找到文件。
conf/glances.conf
浏览文件 @
f5ea9e8f
...
...
@@ -26,7 +26,7 @@ max_processes_display=30
[
quicklook
]
# Set to true to disable a plugin
# Note: you can also disable it from the command line (see --disable-plugin)
disable
=
f
alse
disable
=
F
alse
# Graphical percentage char used in the terminal user interface (default is |)
percentage_char
=|
# Define CPU, MEM and SWAP thresholds in %
...
...
@@ -143,6 +143,10 @@ tx_critical=90
# Display additional information about TCP connections
# This plugin will be disable by default
disable
=
True
# nf_conntrack thresholds in %
nf_conntrack_percent_careful
=
70
nf_conntrack_percent_warning
=
80
nf_conntrack_percent_critical
=
90
[
wifi
]
# Define the list of hidden wireless network interfaces (comma-separated regexp)
...
...
docs/aoa/connections.rst
浏览文件 @
f5ea9e8f
...
...
@@ -7,19 +7,23 @@ Connections
This plugin display extended information about network connections.
The states are the following:
- Listen: all ports created by server and waiting for a client to connect
- Initialized: All states when a connection is initialized (sum of SYN_SENT and SYN_RECEIVED)
- Established: All established connections between a client and a server
- Terminated: All states when a connection is terminated (FIN_WAIT1, CLOSE_WAIT, LAST_ACK, FIN_WAIT2, TIME_WAIT and CLOSE)
- Tracked: Current number and maximum Netfilter tracker connection (nf_conntrack_count/nf_conntrack_max)
The configuration should be done in the ``[connections]`` section of the
Glances configuration file.
By default the plugin is
disabled.
By default the plugin is
**disabled**. Please change your configuration file as following to enable it
.. code-block:: ini
[connections]
disable=False
# nf_conntrack thresholds in %
nf_conntrack_percent_careful=70
nf_conntrack_percent_warning=80
nf_conntrack_percent_critical=90
glances/plugins/glances_connections.py
浏览文件 @
f5ea9e8f
...
...
@@ -20,6 +20,7 @@
"""Connections plugin."""
from
__future__
import
unicode_literals
from
glances.logger
import
logger
from
glances.timer
import
getTimeSinceLastUpdate
from
glances.plugins.glances_plugin
import
GlancesPlugin
from
glances.compat
import
n
,
u
,
b
,
nativestr
...
...
@@ -103,6 +104,7 @@ class Plugin(GlancesPlugin):
for
i
in
self
.
conntrack
:
with
open
(
self
.
conntrack
[
i
],
'r'
)
as
f
:
stats
[
i
]
=
float
(
f
.
readline
().
rstrip
(
"
\n
"
))
stats
[
'nf_conntrack_percent'
]
=
stats
[
'nf_conntrack_count'
]
*
100
/
stats
[
'nf_conntrack_max'
]
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
...
...
@@ -119,34 +121,20 @@ class Plugin(GlancesPlugin):
super
(
Plugin
,
self
).
update_views
()
# Add specifics informations
# Alert
# for i in self.stats:
# ifrealname = i['interface_name'].split(':')[0]
# # Convert rate in bps ( to be able to compare to interface speed)
# bps_rx = int(i['rx'] // i['time_since_update'] * 8)
# bps_tx = int(i['tx'] // i['time_since_update'] * 8)
# # Decorate the bitrate with the configuration file thresolds
# alert_rx = self.get_alert(bps_rx, header=ifrealname + '_rx')
# alert_tx = self.get_alert(bps_tx, header=ifrealname + '_tx')
# # If nothing is define in the configuration file...
# # ... then use the interface speed (not available on all systems)
# if alert_rx == 'DEFAULT' and 'speed' in i and i['speed'] != 0:
# alert_rx = self.get_alert(current=bps_rx,
# maximum=i['speed'],
# header='rx')
# if alert_tx == 'DEFAULT' and 'speed' in i and i['speed'] != 0:
# alert_tx = self.get_alert(current=bps_tx,
# maximum=i['speed'],
# header='tx')
# # then decorates
# self.views[i[self.get_key()]]['rx']['decoration'] = alert_rx
# self.views[i[self.get_key()]]['tx']['decoration'] = alert_tx
try
:
# Alert and log
self
.
views
[
'nf_conntrack_percent'
][
'decoration'
]
=
self
.
get_alert
(
header
=
'nf_conntrack_percent'
)
except
KeyError
:
# try/except mandatory for Windows compatibility (no conntrack stats)
pass
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return the dict to display in the curse interface."""
# Init the return message
ret
=
[]
logger
.
info
(
self
.
is_disable
())
# Only process if stats exist and display plugin enable...
if
not
self
.
stats
or
self
.
is_disable
():
return
ret
...
...
@@ -169,6 +157,8 @@ class Plugin(GlancesPlugin):
msg
=
'{:>{width}}'
.
format
(
'{:0.0f}/{:0.0f}'
.
format
(
self
.
stats
[
'nf_conntrack_count'
],
self
.
stats
[
'nf_conntrack_max'
]),
width
=
max_width
-
len
(
s
)
+
2
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'nf_conntrack_percent'
,
option
=
'decoration'
)))
return
ret
glances/plugins/glances_plugin.py
浏览文件 @
f5ea9e8f
...
...
@@ -90,6 +90,9 @@ class GlancesPlugin(object):
if
not
self
.
load_limits
(
config
=
config
):
logger
.
debug
(
'Can not load section {} in {}'
.
format
(
self
.
plugin_name
,
config
))
else
:
logger
.
debug
(
'Load section {} in {}'
.
format
(
self
.
plugin_name
,
config
))
# Init the actions
self
.
actions
=
GlancesActions
(
args
=
args
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录