Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Log temperature over some time interval given as days, hours, minutes or seconds.
- # enter the variables according to your usage in the following seciton :
- duration="$1" #duration format is ndnhnmns where n is some number and d is day,
- # h is hours, m is minutes and s is seconds. For example, 4d , 4d5h30m , 5m30s, 6h30m30s are all valid.
- step="$2"
- #----------------------------------------------------------------------
- #starting time taken as current
- dt=$(date '+%Y-%m-%dT%H:%M:%S');
- #et=$(date '+%Y-%m-%dT%H:%M:%S');
- #----------------------------------------------------------------------
- a=$(dateutils.dadd $dt $duration )
- b=$(dateutils.ddiff $dt $a -f '%S')
- echo $a $b
- ntimes=$((b/step))
- echo $ntimes
- echo "logging...";
- rm t_log.txt
- nms=0
- while [ $nms -lt $ntimes ]; do
- cat /proc/cpuinfo | grep "MHz" | cut -c12-15 |tr "\n" "\t" >> temp.txt
- let nms=nms+1
- sleep $step
- now=$(date +"%m/%d/%Y %T")
- # now=$nms
- # echo $now
- echo -e "$(cat temp.txt)""\t$now" >> t_log.txt
- rm temp.txt
- done
- #plotting using gnuplot to get a beautiful plot.
- day=86400 #different x-axis for different time duration. A day = 86400 seconds
- fcode=$(date "+%Y-%m-%d_%H%M%S") # generate a time stamp
- #echo $fcode
- if [[ "$b" > "$day" ]]
- then
- gnuplot -e "filename='temp_plot_$fcode'" plot_day
- else
- gnuplot -e "filename='temp_plot_$fcode'" plot_time
- fi
- #end-of-script---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement