Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
abec1a72
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,发现更多精彩内容 >>
提交
abec1a72
编写于
3月 05, 2015
作者:
A
Alessio Sergi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace getters/setters with properties - Round 4
上级
56c69617
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
115 addition
and
107 deletion
+115
-107
glances/core/glances_stats.py
glances/core/glances_stats.py
+4
-3
glances/outputs/glances_bottle.py
glances/outputs/glances_bottle.py
+1
-1
glances/plugins/glances_alert.py
glances/plugins/glances_alert.py
+1
-1
glances/plugins/glances_batpercent.py
glances/plugins/glances_batpercent.py
+2
-2
glances/plugins/glances_core.py
glances/plugins/glances_core.py
+2
-2
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+5
-5
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+2
-2
glances/plugins/glances_docker.py
glances/plugins/glances_docker.py
+2
-2
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+4
-4
glances/plugins/glances_hddtemp.py
glances/plugins/glances_hddtemp.py
+1
-1
glances/plugins/glances_ip.py
glances/plugins/glances_ip.py
+2
-2
glances/plugins/glances_load.py
glances/plugins/glances_load.py
+2
-2
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+4
-4
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+4
-4
glances/plugins/glances_monitor.py
glances/plugins/glances_monitor.py
+1
-1
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+4
-4
glances/plugins/glances_now.py
glances/plugins/glances_now.py
+1
-1
glances/plugins/glances_percpu.py
glances/plugins/glances_percpu.py
+1
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+54
-47
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+2
-2
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+2
-2
glances/plugins/glances_psutilversion.py
glances/plugins/glances_psutilversion.py
+1
-1
glances/plugins/glances_quicklook.py
glances/plugins/glances_quicklook.py
+2
-2
glances/plugins/glances_raid.py
glances/plugins/glances_raid.py
+2
-2
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+2
-2
glances/plugins/glances_system.py
glances/plugins/glances_system.py
+4
-4
glances/plugins/glances_uptime.py
glances/plugins/glances_uptime.py
+3
-3
未找到文件。
glances/core/glances_stats.py
浏览文件 @
abec1a72
...
...
@@ -183,13 +183,13 @@ class GlancesStats(object):
def
getAllLimits
(
self
):
"""Return the plugins limits list."""
return
[
self
.
_plugins
[
p
].
get_limits
()
for
p
in
self
.
_plugins
]
return
[
self
.
_plugins
[
p
].
limits
for
p
in
self
.
_plugins
]
def
getAllLimitsAsDict
(
self
):
"""Return all the stats limits (dict)"""
ret
=
{}
for
p
in
self
.
_plugins
:
ret
[
p
]
=
self
.
_plugins
[
p
].
get_limits
()
ret
[
p
]
=
self
.
_plugins
[
p
].
limits
return
ret
def
getAllViews
(
self
):
...
...
@@ -387,7 +387,8 @@ 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'
,
self
.
system_name
)
self
.
_plugins
[
p
].
input_method
=
'snmp'
self
.
_plugins
[
p
].
short_system_name
=
self
.
system_name
try
:
self
.
_plugins
[
p
].
update
()
except
Exception
as
e
:
...
...
glances/outputs/glances_bottle.py
浏览文件 @
abec1a72
...
...
@@ -234,7 +234,7 @@ class GlancesBottle(object):
try
:
# Get the JSON value of the stat limits
ret
=
self
.
stats
.
get_plugin
(
plugin
).
get_limits
()
ret
=
self
.
stats
.
get_plugin
(
plugin
).
limits
except
Exception
as
e
:
abort
(
404
,
"Cannot get limits for plugin %s (%s)"
%
(
plugin
,
str
(
e
)))
return
ret
...
...
glances/plugins/glances_alert.py
浏览文件 @
abec1a72
...
...
@@ -42,7 +42,7 @@ class Plugin(GlancesPlugin):
self
.
display_curse
=
True
# Set the message position
self
.
set_align
(
'bottom'
)
self
.
align
=
'bottom'
# Init the stats
self
.
reset
()
...
...
glances/plugins/glances_batpercent.py
浏览文件 @
abec1a72
...
...
@@ -61,12 +61,12 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats
self
.
glancesgrabbat
.
update
()
self
.
stats
=
self
.
glancesgrabbat
.
get
()
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# Not avalaible
pass
...
...
glances/plugins/glances_core.py
浏览文件 @
abec1a72
...
...
@@ -56,7 +56,7 @@ class Plugin(GlancesPlugin):
# Reset the stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# The PSUtil 2.0 include psutil.cpu_count() and psutil.cpu_count(logical=False)
...
...
@@ -70,7 +70,7 @@ class Plugin(GlancesPlugin):
except
NameError
:
self
.
reset
()
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'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
浏览文件 @
abec1a72
...
...
@@ -78,7 +78,7 @@ class Plugin(GlancesPlugin):
# Grab CPU stats using psutil's cpu_percent and cpu_times_percent
# methods
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Get all possible values for CPU stats: user, system, idle,
# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)
# The following stats are returned by the API but not displayed in the UI:
...
...
@@ -89,14 +89,14 @@ class Plugin(GlancesPlugin):
'irq'
,
'softirq'
,
'steal'
,
'guest'
,
'guest_nice'
]:
if
hasattr
(
cpu_times_percent
,
stat
):
self
.
stats
[
stat
]
=
getattr
(
cpu_times_percent
,
stat
)
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
if
self
.
get_short_system_name
()
in
(
'windows'
,
'esxi'
):
if
self
.
short_system_name
in
(
'windows'
,
'esxi'
):
# Windows or VMWare ESXi
# You can find the CPU utilization of windows system by querying the oid
# Give also the number of core (number of element in the table)
try
:
cpu_stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
],
cpu_stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
short_system_name
],
bulk
=
True
)
except
KeyError
:
self
.
reset
()
...
...
@@ -118,7 +118,7 @@ class Plugin(GlancesPlugin):
# Default behavor
try
:
self
.
stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
])
snmp_oid
=
snmp_oid
[
self
.
short_system_name
])
except
KeyError
:
self
.
stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
'default'
])
...
...
glances/plugins/glances_diskio.py
浏览文件 @
abec1a72
...
...
@@ -66,7 +66,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Grab the stat using the PsUtil disk_io_counters method
# read_count: number of reads
...
...
@@ -114,7 +114,7 @@ class Plugin(GlancesPlugin):
# Save stats to compute next bitrate
self
.
diskio_old
=
diskio_new
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# No standard way for the moment...
pass
...
...
glances/plugins/glances_docker.py
浏览文件 @
abec1a72
...
...
@@ -131,7 +131,7 @@ class Plugin(GlancesPlugin):
if
not
docker_tag
or
(
self
.
args
is
not
None
and
self
.
args
.
disable_docker
):
return
self
.
stats
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats
# Exemple: {
# "KernelVersion": "3.16.4-tinycore64",
...
...
@@ -159,7 +159,7 @@ class Plugin(GlancesPlugin):
# !!! Refresh problem
# c['network'] = self.get_docker_network(c['Id'])
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# Not available
pass
...
...
glances/plugins/glances_fs.py
浏览文件 @
abec1a72
...
...
@@ -93,7 +93,7 @@ class Plugin(GlancesPlugin):
# Reset the list
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Grab the stats using the PsUtil disk_partitions
...
...
@@ -133,19 +133,19 @@ class Plugin(GlancesPlugin):
fs_current
[
'key'
]
=
self
.
get_key
()
self
.
stats
.
append
(
fs_current
)
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# SNMP bulk command to get all file system in one shot
try
:
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
],
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
short_system_name
],
bulk
=
True
)
except
KeyError
:
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
'default'
],
bulk
=
True
)
# Loop over fs
if
self
.
get_short_system_name
()
in
(
'windows'
,
'esxi'
):
if
self
.
short_system_name
in
(
'windows'
,
'esxi'
):
# Windows or ESXi tips
for
fs
in
fs_stat
:
# Memory stats are grabed in the same OID table (ignore it)
...
...
glances/plugins/glances_hddtemp.py
浏览文件 @
abec1a72
...
...
@@ -58,7 +58,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
self
.
stats
=
self
.
glancesgrabhddtemp
.
get
()
...
...
glances/plugins/glances_ip.py
浏览文件 @
abec1a72
...
...
@@ -61,7 +61,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
and
netifaces_tag
:
if
self
.
input_method
==
'local'
and
netifaces_tag
:
# Update stats using the netifaces lib
try
:
default_gw
=
netifaces
.
gateways
()[
'default'
][
netifaces
.
AF_INET
]
...
...
@@ -76,7 +76,7 @@ class Plugin(GlancesPlugin):
except
KeyError
as
e
:
logger
.
debug
(
"Can not grab IP information (%s)"
.
format
(
e
))
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Not implemented yet
pass
...
...
glances/plugins/glances_load.py
浏览文件 @
abec1a72
...
...
@@ -76,7 +76,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Get the load using the os standard lib
...
...
@@ -89,7 +89,7 @@ class Plugin(GlancesPlugin):
'min5'
:
load
[
1
],
'min15'
:
load
[
2
],
'cpucore'
:
self
.
nb_log_core
}
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
self
.
stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
)
...
...
glances/plugins/glances_mem.py
浏览文件 @
abec1a72
...
...
@@ -78,7 +78,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Grab MEM using the PSUtil virtual_memory method
vm_stats
=
psutil
.
virtual_memory
()
...
...
@@ -112,12 +112,12 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'free'
]
+=
self
.
stats
[
'cached'
]
# used=total-free
self
.
stats
[
'used'
]
=
self
.
stats
[
'total'
]
-
self
.
stats
[
'free'
]
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
if
self
.
get_short_system_name
()
in
(
'windows'
,
'esxi'
):
if
self
.
short_system_name
in
(
'windows'
,
'esxi'
):
# Mem stats for Windows|Vmware Esxi are stored in the FS table
try
:
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
],
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
short_system_name
],
bulk
=
True
)
except
KeyError
:
self
.
reset
()
...
...
glances/plugins/glances_memswap.py
浏览文件 @
abec1a72
...
...
@@ -67,7 +67,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Grab SWAP using the PSUtil swap_memory method
sm_stats
=
psutil
.
swap_memory
()
...
...
@@ -84,12 +84,12 @@ class Plugin(GlancesPlugin):
'sin'
,
'sout'
]:
if
hasattr
(
sm_stats
,
swap
):
self
.
stats
[
swap
]
=
getattr
(
sm_stats
,
swap
)
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
if
self
.
get_short_system_name
()
==
'windows'
:
if
self
.
short_system_name
==
'windows'
:
# Mem stats for Windows OS are stored in the FS table
try
:
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
],
fs_stat
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
short_system_name
],
bulk
=
True
)
except
KeyError
:
self
.
reset
()
...
...
glances/plugins/glances_monitor.py
浏览文件 @
abec1a72
...
...
@@ -47,7 +47,7 @@ class Plugin(GlancesPlugin):
def
update
(
self
):
"""Update the monitored list."""
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'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
浏览文件 @
abec1a72
...
...
@@ -75,7 +75,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Grab network interface stat using the PsUtil net_io_counter method
...
...
@@ -123,12 +123,12 @@ class Plugin(GlancesPlugin):
# Save stats to compute next bitrate
self
.
network_old
=
network_new
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# SNMP bulk command to get all network interface in one shot
try
:
netiocounters
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
],
netiocounters
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
short_system_name
],
bulk
=
True
)
except
KeyError
:
netiocounters
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
'default'
],
...
...
@@ -154,7 +154,7 @@ class Plugin(GlancesPlugin):
netstat
=
{}
# Windows: a tips is needed to convert HEX to TXT
# http://blogs.technet.com/b/networking/archive/2009/12/18/how-to-query-the-list-of-network-interfaces-using-snmp-via-the-ifdescr-counter.aspx
if
self
.
get_short_system_name
()
==
'windows'
:
if
self
.
short_system_name
==
'windows'
:
try
:
netstat
[
'interface_name'
]
=
str
(
base64
.
b16decode
(
net
[
2
:
-
2
].
upper
()))
except
TypeError
:
...
...
glances/plugins/glances_now.py
浏览文件 @
abec1a72
...
...
@@ -39,7 +39,7 @@ class Plugin(GlancesPlugin):
self
.
display_curse
=
True
# Set the message position
self
.
set_align
(
'bottom'
)
self
.
align
=
'bottom'
def
update
(
self
):
"""Update current date/time."""
...
...
glances/plugins/glances_percpu.py
浏览文件 @
abec1a72
...
...
@@ -53,7 +53,7 @@ class Plugin(GlancesPlugin):
# Grab per-CPU stats using psutil's cpu_percent(percpu=True) and
# cpu_times_percent(percpu=True) methods
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
percpu_percent
=
psutil
.
cpu_percent
(
interval
=
0.0
,
percpu
=
True
)
percpu_times_percent
=
psutil
.
cpu_times_percent
(
interval
=
0.0
,
percpu
=
True
)
for
cputimes
in
percpu_times_percent
:
...
...
glances/plugins/glances_plugin.py
浏览文件 @
abec1a72
...
...
@@ -49,11 +49,11 @@ class GlancesPlugin(object):
self
.
args
=
args
# Init the default alignement (for curses)
self
.
set_align
(
'left'
)
self
.
_align
=
'left'
# Init the input method
self
.
input_method
=
'local'
self
.
short_system_name
=
None
self
.
_
input_method
=
'local'
self
.
_
short_system_name
=
None
# Init the stats list
self
.
stats
=
None
...
...
@@ -63,7 +63,7 @@ class GlancesPlugin(object):
self
.
stats_history
=
self
.
init_stats_history
()
# Init the limits dictionnary
self
.
limits
=
dict
()
self
.
_
limits
=
dict
()
# Init the actions
self
.
actions
=
GlancesActions
()
...
...
@@ -135,25 +135,30 @@ class GlancesPlugin(object):
"""Return the items history list"""
return
self
.
items_history_list
def
set_input
(
self
,
input_method
,
short_system_name
=
None
):
@
property
def
input_method
(
self
):
"""Get the input method."""
return
self
.
_input_method
@
input_method
.
setter
def
input_method
(
self
,
input_method
):
"""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
For SNMP, short_system_name is detected short OS name
"""
self
.
input_method
=
input_method
self
.
short_system_name
=
short_system_name
self
.
_input_method
=
input_method
def
get_input
(
self
):
"""Get the input method."""
return
self
.
input_method
@
property
def
short_system_name
(
self
):
"""Get the short detected OS name (SNMP)."""
return
self
.
_short_system_name
def
get_short_system_name
(
self
):
"""Get the short detected OS name"""
return
self
.
short_system_name
@
short_system_name
.
setter
def
short_system_name
(
self
,
short_name
):
"""Set the short detected OS name (SNMP)."""
self
.
_short_system_name
=
short_name
def
set_stats
(
self
,
input_stats
):
"""Set the stats to input_stats."""
...
...
@@ -325,24 +330,24 @@ class GlancesPlugin(object):
"""Load the limits from the configuration file."""
if
(
hasattr
(
config
,
'has_section'
)
and
config
.
has_section
(
self
.
plugin_name
)):
for
s
,
v
in
config
.
items
(
self
.
plugin_name
):
for
level
,
v
in
config
.
items
(
self
.
plugin_name
):
# Read limits
limit
=
'_'
.
join
([
self
.
plugin_name
,
level
])
try
:
self
.
limits
[
self
.
plugin_name
+
'_'
+
s
]
=
config
.
get_option
(
self
.
plugin_name
,
s
)
self
.
_limits
[
limit
]
=
config
.
get_option
(
self
.
plugin_name
,
level
)
except
ValueError
:
self
.
limits
[
self
.
plugin_name
+
'_'
+
s
]
=
config
.
get_raw_option
(
self
.
plugin_name
,
s
).
split
(
","
)
logger
.
debug
(
"Load limit: {0} = {1}"
.
format
(
self
.
plugin_name
+
'_'
+
s
,
self
.
limits
[
self
.
plugin_name
+
'_'
+
s
]))
def
set_limits
(
self
,
input_limits
):
"""Set the limits to input_limits."""
self
.
limits
=
input_limits
self
.
_limits
[
limit
]
=
config
.
get_raw_option
(
self
.
plugin_name
,
level
).
split
(
","
)
logger
.
debug
(
"Load limit: {0} = {1}"
.
format
(
limit
,
self
.
_limits
[
limit
]))
def
get_limits
(
self
):
@
property
def
limits
(
self
):
"""Return the limits object."""
return
self
.
limits
return
self
.
_limits
@
limits
.
setter
def
limits
(
self
,
input_limits
):
"""Set the limits to input_limits."""
self
.
_limits
=
input_limits
def
get_alert
(
self
,
current
=
0
,
minimum
=
0
,
maximum
=
100
,
header
=
""
,
log
=
False
):
"""Return the alert status relative to a current value.
...
...
@@ -435,11 +440,11 @@ class GlancesPlugin(object):
# Get the limit for stat + header
# Exemple: network_wlan0_rx_careful
try
:
limit
=
self
.
limits
[
stat_name
+
'_'
+
criticity
]
limit
=
self
.
_
limits
[
stat_name
+
'_'
+
criticity
]
except
KeyError
:
# Try fallback to plugin default limit
# Exemple: network_careful
limit
=
self
.
limits
[
self
.
plugin_name
+
'_'
+
criticity
]
limit
=
self
.
_
limits
[
self
.
plugin_name
+
'_'
+
criticity
]
# Return the limit
return
limit
...
...
@@ -449,11 +454,11 @@ class GlancesPlugin(object):
# Get the action for stat + header
# Exemple: network_wlan0_rx_careful_action
try
:
ret
=
self
.
limits
[
stat_name
+
'_'
+
criticity
+
'_action'
]
ret
=
self
.
_
limits
[
stat_name
+
'_'
+
criticity
+
'_action'
]
except
KeyError
:
# Try fallback to plugin default limit
# Exemple: network_careful_action
ret
=
self
.
limits
[
self
.
plugin_name
+
'_'
+
criticity
+
'_action'
]
ret
=
self
.
_
limits
[
self
.
plugin_name
+
'_'
+
criticity
+
'_action'
]
# Return the action list
return
ret
...
...
@@ -463,12 +468,12 @@ class GlancesPlugin(object):
# Get the log tag for stat + header
# Exemple: network_wlan0_rx_log
try
:
log_tag
=
self
.
limits
[
stat_name
+
'_log'
]
log_tag
=
self
.
_
limits
[
stat_name
+
'_log'
]
except
KeyError
:
# Try fallback to plugin default log
# Exemple: network_log
try
:
log_tag
=
self
.
limits
[
self
.
plugin_name
+
'_log'
]
log_tag
=
self
.
_
limits
[
self
.
plugin_name
+
'_log'
]
except
KeyError
:
# By defaukt, log are disabled
return
default_action
...
...
@@ -482,12 +487,12 @@ class GlancesPlugin(object):
plugin_name
=
self
.
plugin_name
if
header
==
""
:
try
:
return
self
.
limits
[
plugin_name
+
'_'
+
value
]
return
self
.
_
limits
[
plugin_name
+
'_'
+
value
]
except
KeyError
:
return
[]
else
:
try
:
return
self
.
limits
[
plugin_name
+
'_'
+
header
+
'_'
+
value
]
return
self
.
_
limits
[
plugin_name
+
'_'
+
header
+
'_'
+
value
]
except
KeyError
:
return
[]
...
...
@@ -498,7 +503,7 @@ class GlancesPlugin(object):
def
has_alias
(
self
,
header
):
"""Return the alias name for the relative header or None if nonexist"""
try
:
return
self
.
limits
[
self
.
plugin_name
+
'_'
+
header
+
'_'
+
'alias'
][
0
]
return
self
.
_
limits
[
self
.
plugin_name
+
'_'
+
header
+
'_'
+
'alias'
][
0
]
except
(
KeyError
,
IndexError
):
return
None
...
...
@@ -520,7 +525,7 @@ class GlancesPlugin(object):
if
hasattr
(
self
,
'display_curse'
):
display_curse
=
self
.
display_curse
if
hasattr
(
self
,
'align'
):
align_curse
=
self
.
align
align_curse
=
self
.
_
align
if
max_width
is
not
None
:
ret
=
{
'display'
:
display_curse
,
...
...
@@ -566,16 +571,18 @@ class GlancesPlugin(object):
"""Go to a new line."""
return
self
.
curse_add_line
(
'
\n
'
)
def
set_align
(
self
,
align
=
'left'
):
"""Set the Curse align"""
if
align
in
(
'left'
,
'right'
,
'bottom'
):
self
.
align
=
align
else
:
self
.
align
=
'left'
@
property
def
align
(
self
):
"""Get the curse align."""
return
self
.
_align
def
get_align
(
self
):
"""Get the Curse align"""
return
self
.
align
@
align
.
setter
def
align
(
self
,
value
):
"""Set the curse align.
value: left, right, bottom.
"""
self
.
_align
=
value
def
auto_unit
(
self
,
number
,
low_precision
=
False
):
"""Make a nice human-readable string out of number.
...
...
glances/plugins/glances_processcount.py
浏览文件 @
abec1a72
...
...
@@ -52,14 +52,14 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'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
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# !!! TODO
pass
...
...
glances/plugins/glances_processlist.py
浏览文件 @
abec1a72
...
...
@@ -59,7 +59,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
# Note: Update is done in the processcount plugin
# Just return the processes list
...
...
@@ -67,7 +67,7 @@ class Plugin(GlancesPlugin):
self
.
stats
=
glances_processes
.
gettree
()
else
:
self
.
stats
=
glances_processes
.
getlist
()
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# No SNMP grab for processes
pass
...
...
glances/plugins/glances_psutilversion.py
浏览文件 @
abec1a72
...
...
@@ -45,7 +45,7 @@ class Plugin(GlancesPlugin):
self
.
reset
()
# Return PsUtil version as a tuple
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# PsUtil version only available in local
try
:
self
.
stats
=
tuple
([
int
(
num
)
for
num
in
__psutil_version
.
split
(
'.'
)])
...
...
glances/plugins/glances_quicklook.py
浏览文件 @
abec1a72
...
...
@@ -55,13 +55,13 @@ class Plugin(GlancesPlugin):
self
.
reset
()
# Grab quicklook stats: CPU, MEM and SWAP
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Get the latest CPU percent value
self
.
stats
[
'cpu'
]
=
cpu_percent
.
get
()
# Use the PsUtil lib for the memory (virtual and swap)
self
.
stats
[
'mem'
]
=
psutil
.
virtual_memory
().
percent
self
.
stats
[
'swap'
]
=
psutil
.
swap_memory
().
percent
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Not available
pass
...
...
glances/plugins/glances_raid.py
浏览文件 @
abec1a72
...
...
@@ -57,7 +57,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the PyMDstat lib (https://github.com/nicolargo/pymdstat)
try
:
mds
=
MdStat
()
...
...
@@ -66,7 +66,7 @@ class Plugin(GlancesPlugin):
logger
.
debug
(
"Can not grab RAID stats (%s)"
%
e
)
return
self
.
stats
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# No standard way for the moment...
pass
...
...
glances/plugins/glances_sensors.py
浏览文件 @
abec1a72
...
...
@@ -83,7 +83,7 @@ class Plugin(GlancesPlugin):
# Reset the stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the dedicated lib
self
.
stats
=
[]
# Get the temperature
...
...
@@ -123,7 +123,7 @@ class Plugin(GlancesPlugin):
# Append Batteries %
self
.
stats
.
extend
(
batpercent
)
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
# No standard:
# http://www.net-snmp.org/wiki/index.php/Net-SNMP_and_lm-sensors_on_Ubuntu_10.04
...
...
glances/plugins/glances_system.py
浏览文件 @
abec1a72
...
...
@@ -103,7 +103,7 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
self
.
stats
[
'os_name'
]
=
platform
.
system
()
self
.
stats
[
'hostname'
]
=
platform
.
node
()
...
...
@@ -136,17 +136,17 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'os_name'
],
self
.
stats
[
'os_version'
])
self
.
stats
[
'hr_name'
]
+=
' ({0})'
.
format
(
self
.
stats
[
'platform'
])
elif
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
try
:
self
.
stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()
])
snmp_oid
=
snmp_oid
[
self
.
short_system_name
])
except
KeyError
:
self
.
stats
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
[
'default'
])
# Default behavor: display all the information
self
.
stats
[
'os_name'
]
=
self
.
stats
[
'system_name'
]
# Windows OS tips
if
self
.
get_short_system_name
()
==
'windows'
:
if
self
.
short_system_name
==
'windows'
:
try
:
iteritems
=
snmp_to_human
[
'windows'
].
iteritems
()
except
AttributeError
:
...
...
glances/plugins/glances_uptime.py
浏览文件 @
abec1a72
...
...
@@ -47,7 +47,7 @@ class Plugin(GlancesPlugin):
self
.
display_curse
=
True
# Set the message position
self
.
set_align
(
'right'
)
self
.
align
=
'right'
# Init the stats
self
.
reset
()
...
...
@@ -61,14 +61,14 @@ class Plugin(GlancesPlugin):
# Reset stats
self
.
reset
()
if
self
.
get_input
()
==
'local'
:
if
self
.
input_method
==
'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
self
.
get_input
()
==
'snmp'
:
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
uptime
=
self
.
get_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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录