Created
June 12, 2017 05:42
-
-
Save hyounggyu/6b15da78366c32cf0814e83e8275c246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import zmq | |
import psutil | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind("tcp://*:5556") | |
while True: | |
pinfo = [] | |
for proc in psutil.process_iter(): | |
try: | |
pinfo.append(proc.as_dict(attrs=['pid', 'name'])) | |
except psutil.NoSuchProcess: | |
pass | |
socket.send_string(json.dumps(pinfo)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment