Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
e54e68fb
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 搜索 >>
提交
e54e68fb
编写于
7月 04, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finalize logging message
上级
95847495
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
47 addition
and
50 deletion
+47
-50
AUTHORS
AUTHORS
+2
-2
glances/__init__.py
glances/__init__.py
+12
-8
glances/core/glances_config.py
glances/core/glances_config.py
+4
-3
glances/core/glances_monitor_list.py
glances/core/glances_monitor_list.py
+2
-2
glances/core/glances_password.py
glances/core/glances_password.py
+5
-4
glances/core/glances_snmp.py
glances/core/glances_snmp.py
+1
-1
glances/core/glances_stats.py
glances/core/glances_stats.py
+7
-9
glances/outputs/glances_colorconsole.py
glances/outputs/glances_colorconsole.py
+3
-1
glances/outputs/glances_csv.py
glances/outputs/glances_csv.py
+5
-4
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+2
-4
glances/plugins/glances_batpercent.py
glances/plugins/glances_batpercent.py
+2
-1
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+0
-1
glances/plugins/glances_monitor.py
glances/plugins/glances_monitor.py
+2
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+0
-9
未找到文件。
AUTHORS
浏览文件 @
e54e68fb
...
...
@@ -20,8 +20,8 @@ https://github.com/jrenner
Packagers
=========
Geoffroy Youri Berret
for the Debian package
http
://packages.debian.org/fr/sid/
glances
Rémi Verchère
for the Debian package
http
s://github.com/rverchere/debian-
glances
gasol.wu@gmail.com for the FreeBSD port
...
...
glances/__init__.py
浏览文件 @
e54e68fb
...
...
@@ -37,19 +37,23 @@ except ImportError:
print
(
'psutil library not found. Glances cannot start.'
)
sys
.
exit
(
1
)
# Check psutil version
psutil_min_version
=
(
2
,
0
,
0
)
psutil_version
=
tuple
([
int
(
num
)
for
num
in
__psutil_version
.
split
(
'.'
)])
if
psutil_version
<
psutil_min_version
:
print
(
'psutil version {0} detected.'
).
format
(
__psutil_version
)
print
(
'psutil 2.0 or higher is needed. Glances cannot start.'
)
sys
.
exit
(
1
)
# Import Glances libs
# Note: others Glances libs will be imported optionally
from
glances.core.glances_globals
import
gettext_domain
,
locale_dir
,
logger
from
glances.core.glances_main
import
GlancesMain
# Get PSutil version
psutil_min_version
=
(
2
,
0
,
0
)
psutil_version
=
tuple
([
int
(
num
)
for
num
in
__psutil_version
.
split
(
'.'
)])
# First log with Glances and PSUtil version
logger
.
info
(
'Start Glances {} with PSutil {}'
.
format
(
__version__
,
__psutil_version
))
# Check PSutil version
if
psutil_version
<
psutil_min_version
:
logger
.
critical
(
'PSutil 2.0 or higher is needed. Glances cannot start.'
)
sys
.
exit
(
1
)
def
__signal_handler
(
signal
,
frame
):
"""Callback for CTRL-C."""
...
...
glances/core/glances_config.py
浏览文件 @
e54e68fb
...
...
@@ -38,7 +38,8 @@ from glances.core.glances_globals import (
is_py3
,
is_windows
,
sys_prefix
,
work_path
work_path
,
logger
)
...
...
@@ -69,9 +70,9 @@ class Config(object):
self
.
parser
.
read
(
config_file
,
encoding
=
'utf-8'
)
else
:
self
.
parser
.
read
(
config_file
)
# print(_("DEBUG:
Read configuration file %s") % config_file)
logger
.
info
(
_
(
"
Read configuration file %s"
)
%
config_file
)
except
UnicodeDecodeError
as
e
:
print
(
_
(
"Error:
Cannot decode configuration file '{0}': {1}"
).
format
(
config_file
,
e
))
logger
.
error
(
_
(
"
Cannot decode configuration file '{0}': {1}"
).
format
(
config_file
,
e
))
sys
.
exit
(
1
)
# Save the loaded configuration file path (issue #374)
self
.
_loaded_config_file
=
config_file
...
...
glances/core/glances_monitor_list.py
浏览文件 @
e54e68fb
...
...
@@ -24,7 +24,7 @@ import re
import
subprocess
# Import Glances lib
from
glances.core.glances_globals
import
glances_processes
from
glances.core.glances_globals
import
glances_processes
,
logger
class
MonitorList
(
object
):
...
...
@@ -72,7 +72,7 @@ class MonitorList(object):
countmin
=
self
.
config
.
get_raw_option
(
section
,
key
+
"countmin"
)
countmax
=
self
.
config
.
get_raw_option
(
section
,
key
+
"countmax"
)
except
Exception
as
e
:
print
(
_
(
"Error:
Cannot read monitored list: {0}"
).
format
(
e
))
logger
.
error
(
_
(
"
Cannot read monitored list: {0}"
).
format
(
e
))
pass
else
:
if
description
is
not
None
and
regex
is
not
None
:
...
...
glances/core/glances_password.py
浏览文件 @
e54e68fb
...
...
@@ -32,7 +32,8 @@ from glances.core.glances_globals import (
is_bsd
,
is_linux
,
is_mac
,
is_windows
is_windows
,
logger
)
# Trick: bind raw_input to input in Python 2
...
...
@@ -106,7 +107,7 @@ class GlancesPassword(object):
"""
if
os
.
path
.
exists
(
self
.
password_filepath
)
and
not
clear
:
# If the password file exist then use it
print
(
_
(
"Info:
Read password from file: {0}"
).
format
(
self
.
password_filepath
))
logger
.
info
(
_
(
"
Read password from file: {0}"
).
format
(
self
.
password_filepath
))
password
=
self
.
load_password
()
else
:
# Else enter the password from the command line
...
...
@@ -122,7 +123,7 @@ class GlancesPassword(object):
password_confirm
=
hashlib
.
sha256
(
getpass
.
getpass
(
_
(
"Password (confirm): "
)).
encode
(
'utf-8'
)).
hexdigest
()
if
not
self
.
check_password
(
password_hashed
,
password_confirm
):
print
(
_
(
"Error:
Sorry, but passwords did not match..."
))
logger
.
critical
(
_
(
"
Sorry, but passwords did not match..."
))
sys
.
exit
(
1
)
# Return the plain or hashed password
...
...
@@ -147,7 +148,7 @@ class GlancesPassword(object):
try
:
os
.
makedirs
(
self
.
password_path
)
except
OSError
as
e
:
print
(
_
(
"Warning:
Cannot create Glances directory: {0}"
).
format
(
e
))
logger
.
error
(
_
(
"
Cannot create Glances directory: {0}"
).
format
(
e
))
return
# Create/overwrite the password file
...
...
glances/core/glances_snmp.py
浏览文件 @
e54e68fb
...
...
@@ -27,7 +27,7 @@ try:
from
pysnmp.entity.rfc3413.oneliner
import
cmdgen
except
ImportError
:
logger
.
critical
(
_
(
"PySNMP library not found."
))
print
(
_
(
"Install using pip: # pip install pysnmp"
))
print
(
_
(
"Install
it
using pip: # pip install pysnmp"
))
sys
.
exit
(
2
)
...
...
glances/core/glances_stats.py
浏览文件 @
e54e68fb
...
...
@@ -95,7 +95,7 @@ class GlancesStats(object):
# Restoring system path
sys
.
path
=
sys_path
# Log plugins list
logger
.
debug
(
"Available plugins list: %s"
,
self
.
getAllPlugins
())
logger
.
debug
(
_
(
"Available plugins list: %s"
)
,
self
.
getAllPlugins
())
def
getAllPlugins
(
self
):
"""Return the plugins list."""
...
...
@@ -105,7 +105,7 @@ class GlancesStats(object):
"""Load the stats limits."""
# For each plugins, call the init_limits method
for
p
in
self
.
_plugins
:
#
print "DEBUG: Load limits for %s" % p
#
logger.debug(_("Load limits for %s") % p)
self
.
_plugins
[
p
].
load_limits
(
config
)
def
__update__
(
self
,
input_stats
):
...
...
@@ -113,8 +113,8 @@ class GlancesStats(object):
if
input_stats
==
{}:
# For standalone and server modes
# For each plugins, call the update method
for
p
in
self
.
_plugins
:
#
print "DEBUG: Update %s stats" % p
for
p
in
self
.
_plugins
:
#
logger.debug(_("Update %s stats") % p)
self
.
_plugins
[
p
].
update
()
else
:
# For Glances client mode
...
...
@@ -193,8 +193,8 @@ class GlancesStatsClient(GlancesStats):
# Add the plugin to the dictionary
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
# print "DEBUG: Init %s plugin" % item
# generate self._plugins_list["xxx"] = ...
logger
.
debug
(
_
(
"Init %s plugin"
)
%
item
)
self
.
_plugins
[
item
]
=
plugin
.
Plugin
()
# Restoring system path
sys
.
path
=
sys_path
...
...
@@ -267,9 +267,7 @@ class GlancesStatsClientSNMP(GlancesStats):
for
p
in
self
.
_plugins
:
# Set the input method to SNMP
self
.
_plugins
[
p
].
set_input
(
'snmp'
,
self
.
system_name
)
# print "DEBUG: Update %s stats using SNMP request" % p
try
:
self
.
_plugins
[
p
].
update
()
except
Exception
as
e
:
print
(
_
(
"Error: Update {0} failed: {1}"
).
format
(
p
,
e
))
# pass
logger
.
error
(
_
(
"Error: Update {0} failed: {1}"
).
format
(
p
,
e
))
glances/outputs/glances_colorconsole.py
浏览文件 @
e54e68fb
...
...
@@ -21,12 +21,14 @@ import sys
import
threading
import
time
from
glances.core.glances_globals
import
logger
import
msvcrt
try
:
import
colorconsole
import
colorconsole.terminal
except
ImportError
:
print
(
'Colorconsole module not found. Glances cannot start in standalone mode.'
)
logger
.
critical
(
_
(
'Colorconsole module not found. Glances cannot start in standalone mode.'
)
)
sys
.
exit
(
1
)
try
:
...
...
glances/outputs/glances_csv.py
浏览文件 @
e54e68fb
...
...
@@ -20,10 +20,11 @@
"""CSV interface class."""
# Import sys libs
import
csv
import
sys
import
csv
# Import Glances libs
# Import Glances lib
from
glances.core.glances_globals
import
logger
from
glances.core.glances_globals
import
is_py3
# List of stats enabled in the CSV output
...
...
@@ -46,10 +47,10 @@ class GlancesCSV(object):
self
.
csv_file
=
open
(
self
.
csv_filename
,
'wb'
)
self
.
writer
=
csv
.
writer
(
self
.
csv_file
)
except
IOError
as
e
:
print
(
_
(
"Error: Cannot create the CSV file: {0}"
).
format
(
e
))
logger
.
critical
(
_
(
"Error: Cannot create the CSV file: {0}"
).
format
(
e
))
sys
.
exit
(
2
)
print
(
_
(
"Stats dumped to CSV file: {0}"
).
format
(
self
.
csv_filename
))
logger
.
info
(
_
(
"Stats dumped to CSV file: {0}"
).
format
(
self
.
csv_filename
))
def
exit
(
self
):
"""Close the CSV file."""
...
...
glances/outputs/glances_curses.py
浏览文件 @
e54e68fb
...
...
@@ -32,7 +32,7 @@ if not is_windows:
import
curses
import
curses.panel
except
ImportError
:
print
(
'Curses module not found. Glances cannot start in standalone mode.'
)
logger
.
critical
(
'Curses module not found. Glances cannot start in standalone mode.'
)
sys
.
exit
(
1
)
else
:
from
glances.outputs.glances_colorconsole
import
WCurseLight
...
...
@@ -58,7 +58,7 @@ class GlancesCurses(object):
# Init the curses screen
self
.
screen
=
curses
.
initscr
()
if
not
self
.
screen
:
print
(
_
(
"Error: Cannot init the curses library.
\n
"
))
logger
.
critical
(
_
(
"Error: Cannot init the curses library.
\n
"
))
sys
.
exit
(
1
)
# Set curses options
...
...
@@ -399,8 +399,6 @@ class GlancesCurses(object):
self
.
new_line
()
self
.
display_plugin
(
stats_now
)
# print "%s|%s" % (self.column, self.next_column)
# If space available...
if
screen_x
>
52
:
# Restore line position
...
...
glances/plugins/glances_batpercent.py
浏览文件 @
e54e68fb
...
...
@@ -26,6 +26,7 @@ except ImportError:
pass
# Import Glances libs
from
glances.core.glances_globals
import
logger
from
glances.plugins.glances_plugin
import
GlancesPlugin
...
...
@@ -84,7 +85,7 @@ class GlancesGrabBat(object):
self
.
bat_list
=
[]
self
.
update
()
except
Exception
:
# print(_("Warning:
Cannot grab battery sensor. Missing BatInfo library."))
logger
.
error
(
_
(
"
Cannot grab battery sensor. Missing BatInfo library."
))
self
.
initok
=
False
def
update
(
self
):
...
...
glances/plugins/glances_cpu.py
浏览文件 @
e54e68fb
...
...
@@ -91,7 +91,6 @@ class Plugin(GlancesPlugin):
# 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)
# print snmp_oid[self.get_short_system_name()]
try
:
cpu_stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
[
self
.
get_short_system_name
()],
bulk
=
True
)
...
...
glances/plugins/glances_monitor.py
浏览文件 @
e54e68fb
...
...
@@ -20,6 +20,7 @@
"""Monitor plugin."""
# Import Glances lib
from
glances.core.glances_globals
import
logger
from
glances.core.glances_monitor_list
import
MonitorList
as
glancesMonitorList
from
glances.plugins.glances_plugin
import
GlancesPlugin
...
...
@@ -41,7 +42,7 @@ class Plugin(GlancesPlugin):
def
load_limits
(
self
,
config
):
"""Load the monitored list from the conf file."""
# print "DEBUG: Monitor plugin load config file %s" % config
logger
.
debug
(
_
(
"Monitor plugin configuration detected in the configuration file"
))
self
.
glances_monitors
=
glancesMonitorList
(
config
)
def
update
(
self
):
...
...
glances/plugins/glances_plugin.py
浏览文件 @
e54e68fb
...
...
@@ -131,13 +131,6 @@ class GlancesPlugin(object):
if
item_stats
!=
{}:
ret
[
item_key
]
=
item_stats
index
+=
1
# if '1.3.6.1.2.1.25.3.3.1.2' in snmp_oid.values():
# # if '1.3.6.1.2.1.25.2.3.1.3' in snmp_oid.values():
# print snmp_oid
# print snmpresult
# print ret
else
:
# Simple get request
snmpresult
=
clientsnmp
.
get_by_oid
(
*
snmp_oid
.
values
())
...
...
@@ -160,10 +153,8 @@ class GlancesPlugin(object):
"""Load the limits from the configuration file."""
if
(
hasattr
(
config
,
'has_section'
)
and
config
.
has_section
(
self
.
plugin_name
)):
# print "Load limits for %s" % self.plugin_name
for
s
,
v
in
config
.
items
(
self
.
plugin_name
):
# Read limits
# print "\t%s = %s" % (self.plugin_name + '_' + s, v)
try
:
self
.
limits
[
self
.
plugin_name
+
'_'
+
s
]
=
config
.
get_option
(
self
.
plugin_name
,
s
)
except
ValueError
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录