Skip to content

Commit

Permalink
fixed CPU usage script, added some lines to README
Browse files Browse the repository at this point in the history
  • Loading branch information
s55ma committed Nov 15, 2015
1 parent a34a5e0 commit 5f2aaf4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ How to use:
4. Edit rpisystat.py to match your network adapter (eth0 or wlan0)
5. Edit rx.sh and tx.sh to match your network adapter (eth0 or wlan0)
6. Run rpisystat.py

7. chmod +x *.sh *.py
For detailed instructions, check my blog post (coming soon).

Video: https://www.youtube.com/watch?v=5YkLTBd5-bw
Expand Down
2 changes: 2 additions & 0 deletions cpu_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
awk -v a="$(awk '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat; sleep 1)" '/cpu /{split(a,b," "); print 100*($2+$4-b[1])/($2+$4+$5-b[2])}' /proc/stat
6 changes: 3 additions & 3 deletions rpisystat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def run_cmd(cmd):
# Rpi GPU temperature
cmd4 ="/opt/vc/bin/vcgencmd measure_temp | cut -c 6- | cut -c -4"

# CPU usage - print s/4 means divided by four (number of cores)
cmd5 = "top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'"
# CPU usage
cmd5 = "bash cpu_usage.sh"

# Memory usage
cmd6 = "free | awk 'FNR == 3 {print $3/($3+$4)*100}' | cut -c -3"

# Get free disk space
cmd7 = "df -h | awk 'NR==2 { print $3 }'"
cmd7 = "df -h | sed -n 2p | awk '{ printf $4 }'"

# Calculate RX rate
cmd8 ="bash rx.sh"
Expand Down

0 comments on commit 5f2aaf4

Please sign in to comment.