summaryrefslogtreecommitdiff
path: root/.local/bin/cpuse
blob: ad7e1c6601fd223e4b9b1900c3cd8fd87b14bd54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/awk -f
# cpuse - print average cpu usage since last run

BEGIN {
	getline < "/tmp/cpuse";
	ou=$1; ot=$2;
	while (getline < "/proc/stat") {
		if ($1 == "cpu") {
			u=$2+$3+$4+$7+$8+$9+$10+$11; t=u+$5+$6;
			print u,t > "/tmp/cpuse";
			printf "%i%%\n", ((u-ou)*100)/(t-ot);
			exit;
		}
	}
}