diff --git a/scripts/cpuload.py b/scripts/cpuload.py new file mode 100755 index 0000000..d59d892 --- /dev/null +++ b/scripts/cpuload.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +import subprocess +import serial +ser = serial.Serial("/dev/ttyACM0") +ser.write(b'\nxx\n') +last = 0 + +while 1: + p = subprocess.Popen("./getload.sh", shell=True); + r = p.wait() + r = round(r / 100 * 60) + #if (r < last - 2): + # r = last - 4 + last=r + ser.write(b'X') + ser.write(r.to_bytes(1, byteorder='big')) + ser.write(r.to_bytes(1, byteorder='big')) + ser.write(b'\n') + +ser.close() diff --git a/scripts/getload.sh b/scripts/getload.sh new file mode 100755 index 0000000..26353da --- /dev/null +++ b/scripts/getload.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cpu=`cat <(grep 'cpu ' /proc/stat) <(sleep 0.1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | sed "s/\..*//g"` +exit $cpu