Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
25cca792
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 搜索 >>
提交
25cca792
编写于
11月 10, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PID column too small if kernel.pid_max is > 99999 #959
上级
408208b2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
4 deletion
+46
-4
NEWS
NEWS
+1
-0
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+14
-2
glances/processes.py
glances/processes.py
+31
-2
未找到文件。
NEWS
浏览文件 @
25cca792
...
...
@@ -22,6 +22,7 @@ Enhancements and news features:
* Make the log logger configurable (issue #900)
* System uptime in export (issue #890)
* Refactor the --disable-* options (issue #948)
* PID column too small if kernel.pid_max is > 99999 (issue #959)
Bugs corrected:
...
...
glances/plugins/glances_processlist.py
浏览文件 @
25cca792
...
...
@@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# Copyright (C) 201
5
Nicolargo <nicolas@nicolargo.com>
# Copyright (C) 201
6
Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -82,6 +82,10 @@ class Plugin(GlancesPlugin):
# Get the max values (dict)
self
.
max_values
=
glances_processes
.
max_values
()
# Get the maximum PID number
# Use to optimize space (see https://github.com/nicolargo/glances/issues/959)
self
.
pid_max
=
glances_processes
.
pid_max
# Note: 'glances_processes' is already init in the processes.py script
def
get_key
(
self
):
...
...
@@ -240,7 +244,7 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# PID
msg
=
'{:>
6}'
.
format
(
p
[
'pid'
]
)
msg
=
'{:>
{width}}'
.
format
(
p
[
'pid'
],
width
=
self
.
__max_pid_size
()
+
1
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# USER
if
'username'
in
p
:
...
...
@@ -647,3 +651,11 @@ class Plugin(GlancesPlugin):
return
sort_stats
(
self
.
stats
,
sortedby
,
tree
=
glances_processes
.
is_tree_enabled
(),
reverse
=
glances_processes
.
sort_reverse
)
def
__max_pid_size
(
self
):
"""Return the maximum PID size in number of char"""
if
self
.
pid_max
is
not
None
:
return
len
(
str
(
self
.
pid_max
))
else
:
# By default return 5 (corresponding to 99999 PID number)
return
5
glances/processes.py
浏览文件 @
25cca792
...
...
@@ -69,7 +69,7 @@ class GlancesProcesses(object):
self
.
_sort_key
=
'cpu_percent'
self
.
allprocesslist
=
[]
self
.
processlist
=
[]
self
.
processcount
=
{
'total'
:
0
,
'running'
:
0
,
'sleeping'
:
0
,
'thread'
:
0
}
self
.
reset_processcount
()
# Tag to enable/disable the processes stats (to reduce the Glances CPU consumption)
# Default is to enable the processes stats
...
...
@@ -94,6 +94,13 @@ class GlancesProcesses(object):
self
.
_max_values
=
{}
self
.
reset_max_values
()
def
reset_processcount
(
self
):
self
.
processcount
=
{
'total'
:
0
,
'running'
:
0
,
'sleeping'
:
0
,
'thread'
:
0
,
'pid_max'
:
None
}
def
enable
(
self
):
"""Enable process stats."""
self
.
disable_tag
=
False
...
...
@@ -112,6 +119,25 @@ class GlancesProcesses(object):
"""Disable extended process stats."""
self
.
disable_extended_tag
=
True
@
property
def
pid_max
(
self
):
"""Get the maximum number of PID
On a Linux operating system, the value is read from
the /proc/sys/kernel/pid_max file.
If the file is unreadable or not available (on others OS),
return None.
:returns: int or None
"""
if
LINUX
:
# For the moment, only available on LINUX
# Waiting from https://github.com/giampaolo/psutil/issues/720
try
:
return
int
(
open
(
'/proc/sys/kernel/pid_max'
).
readline
().
rstrip
())
except
IOError
:
return
None
@
property
def
max_processes
(
self
):
"""Get the maximum number of processes showed in the UI."""
...
...
@@ -406,7 +432,7 @@ class GlancesProcesses(object):
"""Update the processes stats."""
# Reset the stats
self
.
processlist
=
[]
self
.
processcount
=
{
'total'
:
0
,
'running'
:
0
,
'sleeping'
:
0
,
'thread'
:
0
}
self
.
reset_processcount
()
# Do not process if disable tag is set
if
self
.
disable_tag
:
...
...
@@ -418,6 +444,9 @@ class GlancesProcesses(object):
# Reset the max dict
self
.
reset_max_values
()
# Update the maximum process ID (pid) number
self
.
processcount
[
'pid_max'
]
=
self
.
pid_max
# Build an internal dict with only mandatories stats (sort keys)
processdict
=
{}
excluded_processes
=
set
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录