diff --git a/sys_stats/socketio_impl/main.py b/sys_stats/socketio_impl/main.py index 5e470e8..f77b8c0 100644 --- a/sys_stats/socketio_impl/main.py +++ b/sys_stats/socketio_impl/main.py @@ -22,7 +22,9 @@ def connect(sid, environ): @sio.on('list_processes') def list_processes(sid, data): - sio.emit("process-list", stats.processes(search_keyword='')) + search_keyword = data['search_keyword'] + print(search_keyword) + sio.emit("process-list", stats.processes(search_keyword=search_keyword)) print('Received message:', data) @@ -38,6 +40,16 @@ def resource_usage(sid, data): print('Received message:', data) +@sio.on('kill_process') +def kill_process(sid, data): + _pid_to_kill = int(data['process_id']) + print('Received message:', data) + sio.emit("process-kill-status", { + "status": stats.kill_process_by_pid(_pid_to_kill), + "pid": _pid_to_kill + }) + + @sio.event def disconnect(sid): print('Client disconnected:', sid) diff --git a/sys_stats/socketio_impl/static/index.html b/sys_stats/socketio_impl/static/index.html index c760fe2..41588a6 100644 --- a/sys_stats/socketio_impl/static/index.html +++ b/sys_stats/socketio_impl/static/index.html @@ -93,10 +93,22 @@