Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
0a0be7bb
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 搜索 >>
提交
0a0be7bb
编写于
5月 12, 2014
作者:
N
Nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SNMP client: replace input args by set and get method
上级
28c7f7f3
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
76 addition
and
72 deletion
+76
-72
glances/core/glances_stats.py
glances/core/glances_stats.py
+3
-1
glances/plugins/glances_alert.py
glances/plugins/glances_alert.py
+1
-1
glances/plugins/glances_batpercent.py
glances/plugins/glances_batpercent.py
+3
-4
glances/plugins/glances_core.py
glances/plugins/glances_core.py
+3
-4
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+3
-4
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+3
-4
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+3
-4
glances/plugins/glances_hddtemp.py
glances/plugins/glances_hddtemp.py
+3
-4
glances/plugins/glances_help.py
glances/plugins/glances_help.py
+1
-1
glances/plugins/glances_load.py
glances/plugins/glances_load.py
+3
-4
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+3
-4
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+3
-4
glances/plugins/glances_monitor.py
glances/plugins/glances_monitor.py
+2
-2
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+3
-4
glances/plugins/glances_now.py
glances/plugins/glances_now.py
+1
-1
glances/plugins/glances_percpu.py
glances/plugins/glances_percpu.py
+3
-4
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+18
-0
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+3
-4
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+3
-4
glances/plugins/glances_psutilversion.py
glances/plugins/glances_psutilversion.py
+2
-2
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+3
-4
glances/plugins/glances_system.py
glances/plugins/glances_system.py
+3
-4
glances/plugins/glances_uptime.py
glances/plugins/glances_uptime.py
+3
-4
未找到文件。
glances/core/glances_stats.py
浏览文件 @
0a0be7bb
...
...
@@ -259,9 +259,11 @@ class GlancesStatsClientSNMP(GlancesStats):
# For each plugins, call the update method
for
p
in
self
.
_plugins
:
# Set the input method to SNMP
self
.
_plugins
[
p
].
set_input
(
'snmp'
)
# print "DEBUG: Update %s stats using SNMP request" % p
try
:
self
.
_plugins
[
p
].
update
(
input
=
'snmp'
)
self
.
_plugins
[
p
].
update
()
except
Exception
as
e
:
print
"ERROR: Update %s failed (%s)"
%
(
p
,
e
)
# pass
...
...
glances/plugins/glances_alert.py
浏览文件 @
0a0be7bb
...
...
@@ -53,7 +53,7 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Nothing to do here
Just return the global glances_log
...
...
glances/plugins/glances_batpercent.py
浏览文件 @
0a0be7bb
...
...
@@ -54,22 +54,21 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update batterie capacity stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
self
.
stats
=
self
.
glancesgrabbat
.
getcapacitypercent
()
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# Not avalaible
pass
...
...
glances/plugins/glances_core.py
浏览文件 @
0a0be7bb
...
...
@@ -46,17 +46,16 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update core stats
Input method could be: local (mandatory) or snmp (optionnal)
Stats is a dict (with both physical and log cpu number) instead of a integer
"""
# Reset the stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# The PSUtil 2.0 include psutil.cpu_count() and psutil.cpu_count(logical=False)
...
...
@@ -70,7 +69,7 @@ class Plugin(GlancesPlugin):
except
NameError
:
self
.
reset
()
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# http://stackoverflow.com/questions/5662467/how-to-find-out-the-number-of-cpus-using-snmp
pass
...
...
glances/plugins/glances_cpu.py
浏览文件 @
0a0be7bb
...
...
@@ -61,16 +61,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update CPU stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab CPU using the PSUtil cpu_times_percent method
...
...
@@ -93,7 +92,7 @@ class Plugin(GlancesPlugin):
'guest'
,
'guest_nice'
]:
if
hasattr
(
cputimespercent
,
cpu
):
self
.
stats
[
cpu
]
=
getattr
(
cputimespercent
,
cpu
)
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_diskio.py
浏览文件 @
0a0be7bb
...
...
@@ -55,16 +55,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update disk IO stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab the stat using the PsUtil disk_io_counters method
# read_count: number of reads
...
...
@@ -111,7 +110,7 @@ class Plugin(GlancesPlugin):
# Save stats to compute next bitrate
self
.
diskio_old
=
diskio_new
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# !!! TODO: no standard way for the moment
pass
...
...
glances/plugins/glances_fs.py
浏览文件 @
0a0be7bb
...
...
@@ -70,16 +70,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update the FS stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset the list
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab the stats using the PsUtil disk_partitions
...
...
@@ -109,7 +108,7 @@ class Plugin(GlancesPlugin):
fs_current
[
'percent'
]
=
fs_usage
.
percent
self
.
stats
.
append
(
fs_current
)
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# SNMP bulk command to get all file system in one shot
...
...
glances/plugins/glances_hddtemp.py
浏览文件 @
0a0be7bb
...
...
@@ -50,20 +50,19 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update HDD stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
self
.
stats
=
self
.
glancesgrabhddtemp
.
get
()
el
if
input
==
'snmp'
:
el
se
:
# Update stats using SNMP
# Not available for the moment
pass
...
...
glances/plugins/glances_help.py
浏览文件 @
0a0be7bb
...
...
@@ -47,7 +47,7 @@ class Plugin(GlancesPlugin):
# Enter -1 to diplay bottom
self
.
line_curse
=
0
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
No stats, it is just a plugin to display the help...
"""
...
...
glances/plugins/glances_load.py
浏览文件 @
0a0be7bb
...
...
@@ -64,10 +64,9 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update load stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
...
...
@@ -79,7 +78,7 @@ class Plugin(GlancesPlugin):
except
:
nb_log_core
=
0
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Get the load using the os standard lib
...
...
@@ -95,7 +94,7 @@ class Plugin(GlancesPlugin):
'min5'
:
load
[
1
],
'min15'
:
load
[
2
],
'cpucore'
:
nb_log_core
}
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_mem.py
浏览文件 @
0a0be7bb
...
...
@@ -67,16 +67,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update MEM (RAM) stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab MEM using the PSUtil virtual_memory method
vm_stats
=
psutil
.
virtual_memory
()
...
...
@@ -110,7 +109,7 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'free'
]
+=
self
.
stats
[
'cached'
]
# used=total-free
self
.
stats
[
'used'
]
=
self
.
stats
[
'total'
]
-
self
.
stats
[
'free'
]
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_memswap.py
浏览文件 @
0a0be7bb
...
...
@@ -59,16 +59,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update MEM (SWAP) stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab SWAP using the PSUtil swap_memory method
sm_stats
=
psutil
.
swap_memory
()
...
...
@@ -84,7 +83,7 @@ class Plugin(GlancesPlugin):
'sin'
,
'sout'
]:
if
hasattr
(
sm_stats
,
swap
):
self
.
stats
[
swap
]
=
getattr
(
sm_stats
,
swap
)
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_monitor.py
浏览文件 @
0a0be7bb
...
...
@@ -50,12 +50,12 @@ class Plugin(GlancesPlugin):
# print "DEBUG: Monitor plugin load config file %s" % config
self
.
glances_monitors
=
glancesMonitorList
(
config
)
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update the monitored list
"""
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Monitor list only available in a full Glances environment
# Check if the glances_monitor instance is init
if
self
.
glances_monitors
is
None
:
...
...
glances/plugins/glances_network.py
浏览文件 @
0a0be7bb
...
...
@@ -63,17 +63,16 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update network stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
Stats is a list of dict (one dict per interface)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab network interface stat using the PsUtil net_io_counter method
...
...
@@ -120,7 +119,7 @@ class Plugin(GlancesPlugin):
# Save stats to compute next bitrate
self
.
network_old
=
network_new
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
...
...
glances/plugins/glances_now.py
浏览文件 @
0a0be7bb
...
...
@@ -44,7 +44,7 @@ class Plugin(GlancesPlugin):
# Enter -1 to diplay bottom
self
.
line_curse
=
-
1
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update current date/time
"""
...
...
glances/plugins/glances_percpu.py
浏览文件 @
0a0be7bb
...
...
@@ -57,16 +57,15 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update Per CPU stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Grab CPU using the PSUtil cpu_times method
...
...
@@ -132,7 +131,7 @@ class Plugin(GlancesPlugin):
except
Exception
:
self
.
reset
()
el
if
input
==
'snmp'
:
el
se
:
# Update stats using SNMP
pass
...
...
glances/plugins/glances_plugin.py
浏览文件 @
0a0be7bb
...
...
@@ -40,6 +40,9 @@ class GlancesPlugin(object):
# Init the args
self
.
args
=
args
# Init the input method
self
.
input
=
'local'
# Init the stats list
self
.
stats
=
None
...
...
@@ -54,6 +57,21 @@ class GlancesPlugin(object):
# Return the human-readable stats
return
str
(
self
.
stats
)
def
set_input
(
self
,
input
):
"""
Set the input method:
* local: system local grab (PSUtil or direct access)
* snmp: Client server mode via SNMP
* glances: Client server mode via Glances API
"""
self
.
input
=
input
def
get_input
(
self
):
"""
Get the input method
"""
return
self
.
input
def
set_stats
(
self
,
input_stats
):
# Set the stats to input_stats
self
.
stats
=
input_stats
...
...
glances/plugins/glances_processcount.py
浏览文件 @
0a0be7bb
...
...
@@ -49,23 +49,22 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update processes stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Here, update is call for processcount AND processlist
glances_processes
.
update
()
# Return the processes count
self
.
stats
=
glances_processes
.
getcount
()
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# !!! TODO
pass
...
...
glances/plugins/glances_processlist.py
浏览文件 @
0a0be7bb
...
...
@@ -52,21 +52,20 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update processes stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
# Note: Update is done in the processcount plugin
# Just return the processes list
self
.
stats
=
glances_processes
.
getlist
()
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# !!! TODO
pass
...
...
glances/plugins/glances_psutilversion.py
浏览文件 @
0a0be7bb
...
...
@@ -40,7 +40,7 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
None
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update core stats
"""
...
...
@@ -49,7 +49,7 @@ class Plugin(GlancesPlugin):
self
.
reset
()
# Return PsUtil version as a tuple
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# PsUtil version only available in local
try
:
self
.
stats
=
tuple
([
int
(
num
)
for
num
in
__psutil_version__
.
split
(
'.'
)])
...
...
glances/plugins/glances_sensors.py
浏览文件 @
0a0be7bb
...
...
@@ -66,21 +66,20 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
[]
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update sensors stats using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset the stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
self
.
hddtemp_plugin
.
update
()
self
.
stats
=
self
.
glancesgrabsensors
.
get
()
self
.
stats
.
extend
(
self
.
hddtemp_plugin
.
stats
)
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# No standard: http://www.net-snmp.org/wiki/index.php/Net-SNMP_and_lm-sensors_on_Ubuntu_10.04
pass
...
...
glances/plugins/glances_system.py
浏览文件 @
0a0be7bb
...
...
@@ -59,17 +59,16 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update the host/system info using the input method
Input method could be: local (mandatory) or snmp (optionnal)
Return the stats (dict)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
self
.
stats
[
'os_name'
]
=
platform
.
system
()
self
.
stats
[
'hostname'
]
=
platform
.
node
()
...
...
@@ -91,7 +90,7 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'os_version'
]
=
' '
.
join
(
os_version
[::
2
])
else
:
self
.
stats
[
'os_version'
]
=
""
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_uptime.py
浏览文件 @
0a0be7bb
...
...
@@ -57,22 +57,21 @@ class Plugin(GlancesPlugin):
"""
self
.
stats
=
{}
def
update
(
self
,
input
=
'local'
):
def
update
(
self
):
"""
Update uptime stat using the input method
Input method could be: local (mandatory) or snmp (optionnal)
"""
# Reset stats
self
.
reset
()
if
input
==
'local'
:
if
self
.
get_input
()
==
'local'
:
# Update stats using the standard system lib
uptime
=
datetime
.
now
()
-
datetime
.
fromtimestamp
(
psutil
.
boot_time
())
# Convert uptime to string (because datetime is not JSONifi)
self
.
stats
=
str
(
uptime
).
split
(
'.'
)[
0
]
elif
input
==
'snmp'
:
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
uptime
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)[
'_uptime'
]
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录