Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
00ae0f22
Commit
00ae0f22
authored
Oct 05, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mitop: Show new processes in bold.
parent
ffa063cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
examples/mitop.py
examples/mitop.py
+10
-10
No files found.
examples/mitop.py
View file @
00ae0f22
...
...
@@ -30,19 +30,14 @@ class Process(object):
rss
=
None
def
send_once
(
sender
):
args
=
[
'ps'
,
'-axwwo'
,
'user,pid,ppid,pgid,%cpu,rss,command'
]
output
=
subprocess
.
check_output
(
args
)
sender
.
put
(
output
)
@
mitogen
.
core
.
takes_router
def
remote_main
(
context_id
,
handle
,
delay
,
router
):
context
=
mitogen
.
core
.
Context
(
router
,
context_id
)
sender
=
mitogen
.
core
.
Sender
(
context
,
handle
)
args
=
[
'ps'
,
'-axwwo'
,
'user,pid,ppid,pgid,%cpu,rss,command'
]
while
True
:
send
_once
(
sender
)
send
er
.
put
(
subprocess
.
check_output
(
args
)
)
time
.
sleep
(
delay
)
...
...
@@ -52,6 +47,7 @@ def parse_output(host, s):
for
line
in
s
.
splitlines
()[
1
:]:
bits
=
line
.
split
(
None
,
6
)
pid
=
int
(
bits
[
1
])
new
=
pid
not
in
prev_pids
prev_pids
.
discard
(
pid
)
try
:
...
...
@@ -60,6 +56,7 @@ def parse_output(host, s):
host
.
procs
[
pid
]
=
proc
=
Process
()
proc
.
hostname
=
host
.
name
proc
.
new
=
new
proc
.
user
=
bits
[
0
]
proc
.
pid
=
pid
proc
.
ppid
=
int
(
bits
[
2
])
...
...
@@ -76,6 +73,7 @@ def parse_output(host, s):
class
Painter
(
object
):
def
__init__
(
self
,
hosts
):
self
.
stdscr
=
curses
.
initscr
()
curses
.
start_color
()
self
.
height
,
self
.
width
=
self
.
stdscr
.
getmaxyx
()
curses
.
cbreak
()
curses
.
noecho
()
...
...
@@ -114,6 +112,10 @@ class Painter(object):
for
i
,
proc
in
enumerate
(
all_procs
):
if
(
i
+
3
)
>=
self
.
height
:
break
if
proc
.
new
:
self
.
stdscr
.
attron
(
curses
.
A_BOLD
)
else
:
self
.
stdscr
.
attroff
(
curses
.
A_BOLD
)
self
.
stdscr
.
addstr
(
2
+
i
,
0
,
self
.
format
%
vars
(
proc
))
self
.
stdscr
.
refresh
()
...
...
@@ -130,14 +132,12 @@ def local_main(painter, router, select, delay):
def
main
(
router
,
argv
):
#mitogen.utils.log_to_file(level='DEBUG')
mitogen
.
utils
.
log_to_file
()
if
not
len
(
argv
):
print
'mitop: Need a list of SSH hosts to connect to.'
sys
.
exit
(
1
)
delay
=
1
.0
delay
=
2
.0
select
=
mitogen
.
master
.
Select
(
oneshot
=
False
)
hosts
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment