Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # See if the first argument is there, its the sleep time
- if [ -z $1 ]
- then
- s=1
- else
- s=$1
- fi
- # The 5 represents approx. the number of lines needed for the graph title and key
- i=5
- # Forever loop
- while :
- do
- # Get the current UNIX timestamp
- t=$(date +%s)
- # Poll the sensors, looking for CPU and GPU readings, and print the ts, gpuT then cpuT out to the data file
- sensors | awk -v t=$t 'BEGIN {ORS = " "; print t} /Tdie|edge/ {print substr($2, 2, 4)} END {print "\n"}' >> ~/temperatureData.dat
- # Check if we've gotten enough new readings to just go by the LINES variable
- # (Its halved because every sensor poll line equals two graph lines)
- if (( $i < $LINES / 2 ))
- then
- l=$i
- let "i++"
- else
- l=$(($LINES / 2))
- fi
- #clear
- # Prepare a headed graph file (with the echo) and extract the tailing data entries to graph
- (echo "@ GPU,CPU"; tail -n $(($l - 3)) ~/temperatureData.dat) | termgraph --title "Component Temperatures (Celcius)" --no-labels --color {magenta,red}
- # Sleep for however long indicated (see first few lines) then poll again
- sleep $s
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement