feat: add markdown module header and async bash execution result structs
Introduce `include/markdown.h` with retoor copyright header and add `r_process_result_t` struct plus `r_bash_execute_ext` / `r_process_result_free` declarations to `include/bash_executor.h` for advanced async process handling.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import psutil
|
||||
import time
|
||||
|
||||
LOG_FILE = 'usage.log'
|
||||
INTERVAL = 5 # seconds
|
||||
|
||||
try:
|
||||
with open(LOG_FILE, 'a') as log:
|
||||
while True:
|
||||
cpu_percent = psutil.cpu_percent(interval=1)
|
||||
mem = psutil.virtual_memory()
|
||||
log_entry = f"CPU: {cpu_percent}%, Memory: {mem.percent}%\n"
|
||||
log.write(log_entry)
|
||||
log.flush()
|
||||
print(log_entry.strip())
|
||||
time.sleep(INTERVAL - 1)
|
||||
except KeyboardInterrupt:
|
||||
print('Monitoring stopped by user.')
|
||||
Reference in New Issue
Block a user