Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Written by Charlie Cook on June 4th, 2020
- # Tested on a AMD Phenom 9500; Check your own machine
- # by running `sensors`, and alter the awk regex
- # (the string between the slashes) in this script
- # to fit what your CPU temperature is labelled.
- # (You may also need to tweak the numbers in substr(),
- # it works as follows; substr($N,J,K)
- # * N: field in the line where the temperature reading is (from 1)
- # * J: which character in the Nth field to start from (from 1)
- # * K: how many characters to take for the substring
- # Check if there is a first argument and use it as the sleep delay if so
- if [ -z $1 ]
- then
- s=1
- else
- s=$1
- fi
- # Sensor Poll counter
- i=6
- while :
- do
- # Get the UNIX timestamp currently to pair with our polled temp reading
- t=$(date +%s)
- # Poll the sensor, format the temperature with awk, append to data file
- sensors -u | awk -F ":" -v t=$t '/temp1_input/ {print t,substr($2,2,4)}' >> ~/temperatureData.dat
- # Determine how many graph lines to show based on number of polled readings
- if (( $i < $LINES ))
- then
- l=$i
- let "i++"
- else
- l=$LINES
- fi
- # Feed latest readings, accounting for graph title lines, to termgraph
- tail -n $(( $l - 5 )) ~/temperatureData.dat | termgraph --color blue --no-labels --title "[$(hostname)] CPU Temperature (Celcius)"
- # Delay before polling again
- sleep $s
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement