Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
dbb24763
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 搜索 >>
提交
dbb24763
编写于
5月 10, 2014
作者:
N
Nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SNMP client: compute ifNumber if it is not available
上级
88a48444
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
8 deletion
+14
-8
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+14
-8
未找到文件。
glances/plugins/glances_network.py
浏览文件 @
dbb24763
...
...
@@ -29,10 +29,11 @@ from glances.plugins.glances_plugin import GlancesPlugin
# SNMP OID
# http://www.net-snmp.org/docs/mibs/interfaces.html
snmp_oid
=
{
'ifNumber'
:
'1.3.6.1.2.1.2.1.0'
}
netif_oid
=
{
'interface_name'
:
'1.3.6.1.2.1.2.2.1.2'
,
'cumulative_rx'
:
'1.3.6.1.2.1.2.2.1.10'
,
'cumulative_tx'
:
'1.3.6.1.2.1.2.2.1.16'
}
ifNumber_oid
=
{
'ifNumber'
:
'1.3.6.1.2.1.2.1.0'
}
ifIndex_oid
=
{
'ifIndex'
:
'1.3.6.1.2.1.2.2.1.1.'
}
snmp_oid
=
{
'interface_name'
:
'1.3.6.1.2.1.2.2.1.2.'
,
'cumulative_rx'
:
'1.3.6.1.2.1.2.2.1.10.'
,
'cumulative_tx'
:
'1.3.6.1.2.1.2.2.1.16.'
}
class
Plugin
(
GlancesPlugin
):
...
...
@@ -123,14 +124,20 @@ class Plugin(GlancesPlugin):
elif
input
==
'snmp'
:
# Update stats using SNMP
# !!! High CPU consumption on the client side
# !!! To be optimized with getbulk
time_since_update
=
getTimeSinceLastUpdate
(
'net'
)
# Get number of network interfaces
try
:
ifNumber
=
int
(
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)[
'ifNumber'
])
+
1
# IfNumber is available directly
ifNumber
=
int
(
self
.
set_stats_snmp
(
snmp_oid
=
ifNumber_oid
)[
'ifNumber'
])
+
1
except
:
return
self
.
stats
# Or not...
# Walk through ifIndex
ifNumber
=
1
while
self
.
set_stats_snmp
(
snmp_oid
=
{
'ifIndex'
:
ifIndex_oid
[
'ifIndex'
]
+
str
(
ifNumber
)})[
'ifIndex'
]
!=
''
:
ifNumber
+=
1
# Loop over network interfaces
network_new
=
{}
...
...
@@ -138,7 +145,7 @@ class Plugin(GlancesPlugin):
ifCpt
=
1
while
(
ifCpt
<
ifNumber
)
and
(
ifIndex
<
1024
):
# Add interface index to netif OID
net_oid
=
dict
((
k
,
v
+
'.'
+
str
(
ifIndex
))
for
(
k
,
v
)
in
netif
_oid
.
items
())
net_oid
=
dict
((
k
,
v
+
str
(
ifIndex
))
for
(
k
,
v
)
in
snmp
_oid
.
items
())
net_stat
=
self
.
set_stats_snmp
(
snmp_oid
=
net_oid
)
if
str
(
net_stat
[
'interface_name'
])
==
''
:
ifIndex
+=
1
...
...
@@ -169,7 +176,6 @@ class Plugin(GlancesPlugin):
"""
#!!! TODO: Add alert on network interface bitrate
#!!! TODO: Manage the hide tag to hide a list of net interface
# Init the return message
ret
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录