SHARE
TWEET

tempgraph.sh

cookchar Jun 4th, 2020 (edited) 942 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # See if the first argument is there, its the sleep time
  4. if [ -z $1 ]
  5. then
  6.     s=1
  7. else
  8.     s=$1
  9. fi
  10.  
  11. # The 5 represents approx. the number of lines needed for the graph title and key
  12. i=5
  13. # Forever loop
  14. while :
  15. do
  16.     # Get the current UNIX timestamp
  17.     t=$(date +%s)
  18.     # Poll the sensors, looking for CPU and GPU readings, and print the ts, gpuT then cpuT out to the data file
  19.     sensors | awk -v t=$t 'BEGIN {ORS = " "; print t} /Tdie|edge/ {print substr($2, 2, 4)} END {print "\n"}' >> ~/temperatureData.dat
  20.     # Check if we've gotten enough new readings to just go by the LINES variable
  21.     # (Its halved because every sensor poll line equals two graph lines)
  22.     if (( $i < $LINES / 2 ))
  23.     then
  24.         l=$i
  25.         let "i++"
  26.     else
  27.         l=$(($LINES / 2))
  28.     fi
  29.     #clear
  30.     # Prepare a headed graph file (with the echo) and extract the tailing data entries to graph
  31.     (echo "@ GPU,CPU"; tail -n $(($l - 3)) ~/temperatureData.dat) | termgraph --title "Component Temperatures (Celcius)" --no-labels --color {magenta,red}
  32.     # Sleep for however long indicated (see first few lines) then poll again
  33.     sleep $s
  34. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top