okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
53623e56f
main
1"""Sample host RAM in use (total - available), swap and GPU state once per second (Windows, psutil + nvidia-smi).""" 2import json ,subprocess ,time ,psutil 3while True : 4vm ,sw = psutil .virtual_memory (),psutil .swap_memory () 5try : 6g = subprocess .check_output (["nvidia-smi" ,"--query-gpu=memory.used,memory.total,utilization.gpu,power.draw,temperature.gpu,pcie.link.gen.current,pcie.link.width.current" ,"--format=csv,noheader,nounits" ],text = True ,timeout = 5 ).strip () 7except Exception as e : 8g = repr (e ) 9json .dumps ({"epoch_s" :time .time (),"host_used_gib" :round ((vm .total - vm .available )/ 2 ** 30 ,3 ), 10"host_total_gib" :round (vm .total / 2 ** 30 ,3 ),"swap_used_gib" :round (sw .used / 2 ** 30 ,3 ),"gpu" :g }),flush = True ) 11time .sleep (1 )