Advertisement
LinuxLaci

CPU_teszt

Jul 27th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.51 KB | None | 0 0
  1. #!/bin/bash
  2. # Log temperature over some time  interval given as days, hours, minutes or seconds.
  3. # enter the variables according to your usage in the following seciton :
  4. duration="$1"  #duration format is  ndnhnmns where n is some number and d is day,
  5. # h is hours, m is minutes and s is seconds. For example, 4d , 4d5h30m , 5m30s, 6h30m30s are all valid.
  6.  
  7. step="$2"
  8. #----------------------------------------------------------------------
  9. #starting time taken as current
  10. dt=$(date '+%Y-%m-%dT%H:%M:%S');
  11. #et=$(date '+%Y-%m-%dT%H:%M:%S');
  12.  
  13. #----------------------------------------------------------------------
  14. a=$(dateutils.dadd $dt  $duration )
  15. b=$(dateutils.ddiff $dt $a -f '%S')
  16. echo $a $b
  17.  
  18. ntimes=$((b/step))
  19. echo $ntimes
  20.  
  21.  
  22. echo "logging...";
  23. rm t_log.txt
  24. nms=0
  25. while [  $nms -lt $ntimes ];  do
  26.         cat /proc/cpuinfo | grep "MHz" | cut -c12-15 |tr "\n" "\t" >> temp.txt
  27.         let nms=nms+1
  28.         sleep  $step
  29.         now=$(date +"%m/%d/%Y %T")
  30. #       now=$nms
  31. #       echo $now
  32.         echo -e "$(cat temp.txt)""\t$now"  >> t_log.txt
  33.         rm temp.txt
  34. done
  35.  
  36.  
  37. #plotting using gnuplot to get a beautiful plot.
  38. day=86400 #different x-axis for different  time duration. A day = 86400 seconds
  39.  
  40. fcode=$(date "+%Y-%m-%d_%H%M%S") # generate a time stamp
  41. #echo $fcode
  42. if [[ "$b" > "$day" ]]
  43. then
  44.         gnuplot -e "filename='temp_plot_$fcode'" plot_day
  45. else
  46.         gnuplot -e "filename='temp_plot_$fcode'" plot_time
  47. fi
  48. #end-of-script---------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement