Skip to content

Commit

Permalink
CPU on host
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksanagari committed Jul 5, 2018
1 parent 1e78d4d commit 37a75cd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cpu_host
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

head -1 /proc/stat > file.txt
sleep 1s
for value in {2..60}
do
head -1 /proc/stat >> file.txt
sleep 1s
done

awk '{sum2+=$2; sum3+=$3; sum4+=$4; sum5+=$5; sum6+=$6; sum7+=$7; sum8+=$8; sum9+=$9;} END {print sum2/60,sum3/60,sum4/60,sum5/60,sum6/60,sum7/60,sum8/60,sum9/60}' file.txt | awk '{print ((($1+$2+$3+$4+$5+$6+$7+$8)-($4+$5))/($1+$2+$3+$4+$5+$6+$7+$8))*100}'


0 comments on commit 37a75cd

Please sign in to comment.