Htop for CPU and memory inspection


Hello, how can I see the CPU/cores and memory use of the cloud instance? Normally I would run htop at the command line. It’s important to ensure my code is actually taking advantage of the instance specs as intended.


I use psutil library in my code to check cpu and memory usage. Below there is some my sample code.

import psutil
import time
import threading
from deepsense import neptune

ctx = neptune.Context()

loop = True

def worker(ctx):
    while loop:
        ctx.channel_send('cpu', psutil.cpu_percent())
        ctx.channel_send('mem', psutil.virtual_memory().percent)
t = threading.Thread(target=worker, args=(ctx,))

# Your code here
Run my magic code

# Kill cpu plot thread
loop = False

This code will create separate thread which will send channel values and create cpu/mem plot.


Fantastic code snippet. Thank you!