Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
5c3eeba0
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,发现更多精彩内容 >>
提交
5c3eeba0
编写于
7月 29, 2013
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add alert for the monitored processes list
上级
6ff103d4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
12 deletion
+26
-12
glances/glances.py
glances/glances.py
+26
-12
未找到文件。
glances/glances.py
浏览文件 @
5c3eeba0
...
...
@@ -643,15 +643,16 @@ class glancesLogs:
return
i
return
-
1
def
add
(
self
,
item_state
,
item_type
,
item_value
,
proc_list
=
[]):
def
add
(
self
,
item_state
,
item_type
,
item_value
,
proc_list
=
[]
,
proc_desc
=
""
):
"""
item_state = "OK|CAREFUL|WARNING|CRITICAL"
item_type = "CPU*|LOAD|MEM"
item_type = "CPU*|LOAD|MEM
|MON
"
item_value = value
Item is defined by:
["begin", "end", "WARNING|CRITICAL", "CPU|LOAD|MEM",
MAX, AVG, MIN, SUM, COUNT,
[top3 process list]]
[top3 process list],
"Processes description"]
If item is a 'new one':
Add the new item at the beginning of the logs list
Else:
...
...
@@ -666,7 +667,7 @@ class glancesLogs:
# Sort TOP process by io_counters (only for Linux OS)
sortby
=
'io_counters'
else
:
# Default TOP process sort is cpu_percent
(for CPU* and LOAD)
# Default TOP process sort is cpu_percent
sortby
=
'cpu_percent'
topprocess
=
sorted
(
proc_list
,
key
=
lambda
process
:
process
[
sortby
],
reverse
=
True
)
...
...
@@ -679,7 +680,9 @@ class glancesLogs:
# Time is stored in Epoch format
# Epoch -> DMYHMS = datetime.fromtimestamp(epoch)
item
=
[]
# START DATE
item
.
append
(
time
.
mktime
(
datetime
.
now
().
timetuple
()))
# END DATE
item
.
append
(
-
1
)
item
.
append
(
item_state
)
# STATE: WARNING|CRITICAL
item
.
append
(
item_type
)
# TYPE: CPU, LOAD, MEM...
...
...
@@ -689,6 +692,7 @@ class glancesLogs:
item
.
append
(
item_value
)
# SUM
item
.
append
(
1
)
# COUNT
item
.
append
(
topprocess
[
0
:
3
])
# TOP 3 PROCESS LIST
item
.
append
(
proc_desc
)
# MONITORED PROCESSES DESC
self
.
logs_list
.
insert
(
0
,
item
)
if
self
.
len
()
>
self
.
logs_max
:
self
.
logs_list
.
pop
()
...
...
@@ -720,6 +724,8 @@ class glancesLogs:
self
.
logs_list
[
item_index
][
8
])
# TOP PROCESS LIST
self
.
logs_list
[
item_index
][
9
]
=
topprocess
[
0
:
3
]
# MONITORED PROCESSES DESC
self
.
logs_list
[
item_index
][
10
]
=
proc_desc
return
self
.
len
()
...
...
@@ -2923,7 +2929,7 @@ class glancesScreen:
min
(
offset_y
-
3
,
screen_y
-
self
.
log_y
,
logs
.
len
()))
logtodisplay_count
=
min
(
screen_y
-
self
.
log_y
-
3
,
logs
.
len
())
logmsg
=
_
(
"WARNING|CRITICAL logs
for CPU|LOAD|MEM
"
)
logmsg
=
_
(
"WARNING|CRITICAL logs"
)
if
logtodisplay_count
>
1
:
logmsg
+=
(
_
(
" (lasts "
)
+
str
(
logtodisplay_count
)
+
_
(
" entries)"
))
...
...
@@ -2955,8 +2961,11 @@ class glancesScreen:
logmsg
+=
" {0} ({1:.1f}/{2:.1f}/{3:.1f})"
.
format
(
log
[
logcount
][
3
],
log
[
logcount
][
6
],
log
[
logcount
][
5
],
log
[
logcount
][
4
])
# Add top process
if
log
[
logcount
][
9
]
!=
[]:
# Add the monitored process description
if
log
[
logcount
][
10
]
!=
""
:
logmsg
+=
" - {0}"
.
format
(
log
[
logcount
][
10
])
elif
log
[
logcount
][
9
]
!=
[]:
# Add top processes
log_proc_name
=
log
[
logcount
][
9
][
0
][
'name'
]
logmsg
+=
" - Top process: {0}"
.
format
(
log_proc_name
)
# Display the log
...
...
@@ -3071,12 +3080,17 @@ class glancesScreen:
monitormsg2
=
"{0}"
.
format
(
cmdret
)
self
.
term_window
.
addnstr
(
monitor_y
,
self
.
process_x
+
35
,
monitormsg2
,
screen_x
-
process_x
-
35
)
# else:
# monitormsg2 = "Min: {0} Current: {1} Max: {2} processes".format(
# monitors.countmin(item), len(monitoredlist), monitors.countmax(item))
# self.term_window.addnstr(monitor_y, self.process_x + 35,
# monitormsg2, screen_x - process_x - 35)
# Generate log
logs
.
add
(
self
.
__getMonitoredAlert
(
len
(
monitoredlist
),
monitors
.
countmin
(
item
),
monitors
.
countmax
(
item
)),
"MON_"
+
str
(
item
+
1
),
len
(
monitoredlist
),
proc_list
=
monitoredlist
,
proc_desc
=
monitors
.
description
(
item
))
# Next...
item
+=
1
#*****************
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录