Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
6d0fe0f7
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 搜索 >>
提交
6d0fe0f7
编写于
4月 10, 2017
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new repeat function to the action (issue #952)
上级
e9260c3d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
17 deletion
+37
-17
NEWS
NEWS
+2
-1
conf/glances.conf
conf/glances.conf
+1
-0
docs/aoa/actions.rst
docs/aoa/actions.rst
+10
-0
docs/man/glances.1
docs/man/glances.1
+1
-1
glances/actions.py
glances/actions.py
+6
-3
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+17
-12
未找到文件。
NEWS
浏览文件 @
6d0fe0f7
...
...
@@ -7,9 +7,10 @@ Version 2.9.2
Enhancements and new features:
* New plugin to scan remote Web sites (URL) (issue #981)
* New plugin to scan remote Web sites (URL) (issue #981)
* Use -> and <- arrows keys to switch between processing sort (issue #1075)
* Add trends in the Curses interface (issue #1077)
* Add new repeat function to the action (issue #952)
Bugs corrected:
...
...
conf/glances.conf
浏览文件 @
6d0fe0f7
...
...
@@ -87,6 +87,7 @@ mem_critical=90
# Define RAM thresholds in %
# Default values if not defined: 50/70/90
careful
=
50
#careful_action_repeat=echo {{percent}} >> /tmp/memory.alert
warning
=
70
critical
=
90
...
...
docs/aoa/actions.rst
浏览文件 @
6d0fe0f7
...
...
@@ -31,4 +31,14 @@ reached:
https://github.com/nicolargo/glances/wiki/The-Glances-2.x-API-How-to
for the stats list.
It is also possible to repeat action until the end of the alert.
Keep in mind that the command line is executed every refresh time so
use with caution:
.. code-block:: ini
[load]
critical=5.0
critical_action_repeat=/home/myhome/bin/bipper.sh
.. _{{mustache}}: https://mustache.github.io/
docs/man/glances.1
浏览文件 @
6d0fe0f7
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "Apr
03
, 2017" "2.9.2_DEVELOP" "Glances"
.TH "GLANCES" "1" "Apr
10
, 2017" "2.9.2_DEVELOP" "Glances"
.SH NAME
glances \- An eye on your system
.
...
...
glances/actions.py
浏览文件 @
6d0fe0f7
...
...
@@ -63,21 +63,24 @@ class GlancesActions(object):
"""Set the stat_name to criticity."""
self
.
status
[
stat_name
]
=
criticity
def
run
(
self
,
stat_name
,
criticity
,
commands
,
mustache_dict
=
None
):
def
run
(
self
,
stat_name
,
criticity
,
commands
,
repeat
,
mustache_dict
=
None
):
"""Run the commands (in background).
- stats_name: plugin_name (+ header)
- criticity: criticity of the trigger
- commands: a list of command line with optional {{mustache}}
- If True, then repeat the action
- mustache_dict: Plugin stats (can be use within {{mustache}})
Return True if the commands have been ran.
"""
if
self
.
get
(
stat_name
)
==
criticity
or
not
self
.
start_timer
.
finished
():
if
(
self
.
get
(
stat_name
)
==
criticity
and
not
repeat
)
or
\
not
self
.
start_timer
.
finished
():
# Action already executed => Exit
return
False
logger
.
debug
(
"Run action {} for {} ({}) with stats {}"
.
format
(
logger
.
debug
(
"{} action {} for {} ({}) with stats {}"
.
format
(
"Repeat"
if
repeat
else
"Run"
,
commands
,
stat_name
,
criticity
,
mustache_dict
))
# Run all actions in background
...
...
glances/plugins/glances_plugin.py
浏览文件 @
6d0fe0f7
...
...
@@ -559,7 +559,7 @@ class GlancesPlugin(object):
"""Manage the action for the current stat"""
# Here is a command line for the current trigger ?
try
:
command
=
self
.
get_limit_action
(
trigger
,
stat_name
=
stat_name
)
command
,
repeat
=
self
.
get_limit_action
(
trigger
,
stat_name
=
stat_name
)
except
KeyError
:
# Reset the trigger
self
.
actions
.
set
(
stat_name
,
trigger
)
...
...
@@ -584,7 +584,8 @@ class GlancesPlugin(object):
mustache_dict
=
self
.
get_stats_action
()
# 2) Run the action
self
.
actions
.
run
(
stat_name
,
trigger
,
command
,
mustache_dict
=
mustache_dict
)
stat_name
,
trigger
,
command
,
repeat
,
mustache_dict
=
mustache_dict
)
def
get_alert_log
(
self
,
current
=
0
,
...
...
@@ -617,18 +618,22 @@ class GlancesPlugin(object):
return
limit
def
get_limit_action
(
self
,
criticity
,
stat_name
=
""
):
"""Return the action for the alert."""
"""Return the tuple (action, repeat) for the alert.
- action is a command line
- repeat is a bool"""
# Get the action for stat + header
# Exemple: network_wlan0_rx_careful_action
try
:
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'
]
# Return the action list
return
ret
# Action key available ?
ret
=
[(
stat_name
+
'_'
+
criticity
+
'_action'
,
False
),
(
stat_name
+
'_'
+
criticity
+
'_action_repeat'
,
True
),
(
self
.
plugin_name
+
'_'
+
criticity
+
'_action'
,
False
),
(
self
.
plugin_name
+
'_'
+
criticity
+
'_action_repeat'
,
True
)]
for
r
in
ret
:
if
r
[
0
]
in
self
.
_limits
:
return
self
.
_limits
[
r
[
0
]],
r
[
1
]
# No key found, the raise an error
raise
KeyError
def
get_limit_log
(
self
,
stat_name
,
default_action
=
False
):
"""Return the log tag for the alert."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录