Advertisement
Guest User

drivenote from 19.28

a guest
Aug 22nd, 2019
1,149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.11 KB | None | 0 0
  1. #!/bin/bash
  2. # shellcheck disable=SC2129
  3. # Disable consolidating output redirects in shellcheck - they are actually as consolidated as they can be to OUTPUT_FILE
  4.  
  5. if [[ $1 == --debug ]] ; then
  6.   set -x
  7.   shift
  8. fi
  9.  
  10. . /etc/tesla.env
  11. if [ -e /etc/RunQtCar.env ]; then
  12.   . /etc/RunQtCar.env
  13. fi
  14.  
  15. target_mcu()    { [ "$UI_TARGET" = "MCU" ]; }
  16. target_ice()    { [ "$UI_TARGET" = "ICE" ]; }
  17.  
  18. platform_m3()   { [ "$UI_PLATFORM" = "M3" ]; }
  19. platform_sx()   { [ "$UI_PLATFORM" = "SX" ]; }
  20.  
  21. have_ic_host()  { target_mcu; }
  22.  
  23. # run as root
  24. # XXX: Replace with escalator usage directly from UI when supported on Tegra
  25. if [ $EUID != 0 ] ; then
  26.   exec /usr/local/bin/notehelper
  27. fi
  28.  
  29. TESLA_CAP_DIR=$TESLA_HOME/.Tesla/data/drivenotes
  30. mkdir -p "$TESLA_CAP_DIR"
  31.  
  32. CAP_DATE=$(date "+%Y-%m-%d-%H:%M:%S")
  33. OUTPUT_FILE=$TESLA_CAP_DIR/note.$CAP_DATE.txt
  34.  
  35. echo "File: $OUTPUT_FILE" > "$OUTPUT_FILE"
  36.  
  37. VIN=$(< /var/etc/vin)
  38. {
  39.   echo "Vin: $VIN"
  40.  
  41.   # get cid and ic screenshots early to indicate visually we're doing something
  42.   echo
  43.   screenshot
  44.  
  45.   # get process info
  46.   printf "\n\n-------------------- CID PROCESSES\n"
  47.   ps -AwwL -o pid,ppid,tid,pcpu,vsize,rss,tty,psr,nwchan,wchan:42,stat,start,time,command
  48.   if have_ic_host ; then
  49.     printf "\n\n-------------------- IC PROCESSES\n"
  50.     ssh ic "ps -AwwL -o pid,ppid,tid,pcpu,vsize,rss,tty,psr,nwchan,wchan:42,stat,start,time,command"
  51.   fi
  52.  
  53.   # save all published data values
  54.   printf "\n\n-------------------- DATA VALUES\n"
  55.   curl -s "http://localhost:4035/get_data_values?format=csv&show_invalid=true"
  56.  
  57.   # get network config and stats
  58.   printf "\n\n-------------------- NETWORK CONFIGURATION/STATS\n"
  59.   ifconfig
  60. } >> "$OUTPUT_FILE"
  61.  
  62. nme -a >> "$OUTPUT_FILE" 2>/dev/null
  63.  
  64. {
  65.   netstat -s
  66.  
  67.   # get disk stats
  68.   printf "\n\n-------------------- CID DISK INFO\n"
  69.   df
  70.   if ! target_ice ; then # busybox df does not support inode option
  71.     echo
  72.     df -i
  73.   fi
  74.  
  75.   if have_ic_host ; then
  76.     printf "\n\n-------------------- IC DISK INFO\n"
  77.     ssh ic "df"
  78.     echo
  79.     ssh ic "df -i"
  80.   fi
  81.  
  82.   # other system info
  83.   if target_mcu ; then
  84.     printf "\n\n-------------------- DSPT\n"
  85.     tail -250 /var/log/dspt.log
  86.   else
  87.     echo
  88.     if platform_m3 ; then
  89.       # Only the Model3 platform has the ability to check the speakers
  90.       # and doing so on Info1/2 causes an audible pop
  91.       AUDIOOPTIONS="check-speakers"
  92.     fi
  93.     AUDIOLOGS=$(/usr/bin/audiologs.sh $AUDIOOPTIONS)
  94.     echo "Audiologs: $AUDIOLOGS"
  95.   fi
  96.   printf "\n\n-------------------- LSUSB\n"
  97.   lsusb -v
  98.  
  99.   # display status
  100.   if target_ice ; then
  101.     printf "\n\n-------------------- DISPLAYS\n"
  102.     ice-display
  103.   fi
  104. } >> "$OUTPUT_FILE"
  105.  
  106. # post vitals to mothership
  107. "$TESLA_BIN/mothership.sh" vitals &>/dev/null
  108.  
  109. {
  110.   # get memory stats
  111.   printf "\n\n-------------------- CID MEMORY INFO\n"
  112.   cat /proc/meminfo
  113.   echo
  114.   cat /proc/zoneinfo
  115.   echo
  116.   slabtop -o -s c
  117.   if have_ic_host ; then
  118.     printf "\n\n-------------------- IC MEMORY INFO\n"
  119.     ssh ic "cat /proc/meminfo"
  120.     echo
  121.     ssh ic "cat /proc/zoneinfo"
  122.     echo
  123.     ssh -t ic "slabtop -o -s c"
  124.   fi
  125. } >> "$OUTPUT_FILE"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement