Advertisement
papampi

telegram_v19-1.2

Sep 24th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 18.25 KB | None | 0 0
  1. #!/bin/bash
  2. # Telegram Info Script
  3. # By BaliMiner et al...
  4. # for nvOC by fullzero
  5. # ref: http://bernaerts.dyndns.org/linux/75-debian/351-debian-send-telegram-notification
  6. #
  7.  
  8. source ~/1bash
  9.  
  10. if [ $TELEGRAM_TYPE == "BaliMiner" ]
  11. then
  12. CHATID=$TELEGRAM_CHATID
  13. APIKEY=$TELEGRAM_APIKEY
  14. CURRENTHASH=`/usr/bin/curl -s http://localhost:3333 | sed '/Total/!d; /Speed/!d;' | awk '{print $6}' | awk 'NR == 3'`
  15. GPU_UTILIZATIONS=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits)
  16. TEMP=$(/usr/bin/nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader)
  17. PD=$(/usr/bin/nvidia-smi --query-gpu=power.draw --format=csv,noheader)
  18. FAN=$(/usr/bin/nvidia-smi --query-gpu=fan.speed --format=csv,noheader)
  19. LF=$'\n'
  20. PROFIT=$(cat /home/m1/current-profit)
  21. MSG="$WORKERNAME $LF GPU_UTILIZATIONS: $GPU_UTILIZATIONS $LF TEMPS: $TEMP  $LF  POWERDRAW: $PD $LF  $CURRENTHASH"
  22. /usr/bin/curl -s -X POST --output /dev/null https://api.telegram.org/bot${APIKEY}/sendMessage -d "text=${MSG}" -d chat_id=${CHATID}
  23. fi
  24.  
  25.  
  26. #mod by papampi
  27. if [ $TELEGRAM_TYPE == "papampi" ]
  28. then
  29. CHATID=$TELEGRAM_CHATID
  30. APIKEY=$TELEGRAM_APIKEY
  31.  
  32. if [ $COIN == "SALFTER_NICEHASH_PROFIT_SWITCHING" ]
  33. then
  34. CURRENT_COIN=$(head -n 1 /home/m1/current-profit)
  35. elif [ $COIN == "SALFTER_MPH_PROFIT_SWITCHING" ]
  36. then
  37. CURRENT_COIN=$(head -n 1 /home/m1/current-profit)
  38. else
  39. CURRENT_COIN=$(head -n 130 /home/m1/1bash | grep COIN= | sed 's/COIN=//')
  40. fi
  41.  
  42.  
  43. SYSTEM_BOOT_TIME=$(uptime -s)
  44. SYSTEM_UP_TIME=$(uptime -p)
  45. GPU_COUNT=$(nvidia-smi -L | tail -n 1| cut -c 5 |awk '{ SUM += $1+1}  ; { print SUM }')
  46. REBOOT_REQUIRED=$([ -f /var/run/reboot-required ] && echo "Yes!!!" || echo "No")
  47. MINER_UP_TIME=$(ps -p `pgrep -f miner` -o etime | grep -v ELAPSED)
  48. GPU_UTILIZATIONS=$(tail -n 5 5_restartlog | grep 'GPU UTILIZATION' | awk '{gsub(/GPU UTILIZATION:  /,"")}1' | tail -n 1)
  49. TEMP_FAN_POWER=$(tail  -n 20 /home/m1/6_autotemplog  | grep GPU | awk '{gsub(/:/,": ")}1' |tail -n $GPU_COUNT)
  50. STARTING_MINER=$(tail -n 5 /home/m1/5_restartlog | grep Starting | tail -n 1)
  51. LOST_GPU=$(tail -n 5 /home/m1/5_restartlog | grep Lost| tail -n 1)
  52. REBOOT_ALERT=$(tail -n 5 /home/m1/5_restartlog | grep 'reboot in' |tail -n 1)
  53. UTILIZATION_LOW_REBOOTING=$(tail -n 5 /home/m1/5_restartlog | grep 'low: reviving' |tail -n 1)
  54. UTILIZATION_LOW_RESTART_3MAIN=$(tail -n 5 /home/m1/5_restartlog | grep 'low: restart' |tail -n 1)
  55. FAILURES_REINIT=$(tail -n 5 /home/m1/5_restartlog | grep 'Before reinit')
  56. LF=$'\n'
  57.  
  58. MSG=" Worker: $WORKERNAME
  59. Boot Time: $SYSTEM_BOOT_TIME
  60. System Up Time: $SYSTEM_UP_TIME
  61. Miner Uptime: $MINER_UP_TIME
  62. Currently Mining: $CURRENT_COIN
  63. Reboot Required: $REBOOT_REQUIRED
  64. GPU Count: $GPU_COUNT
  65. GPU Utilization:
  66. $GPU_UTILIZATIONS
  67. Temp, Fan, Power:
  68. $TEMP_FAN_POWER
  69. $STARTING_MINER
  70. $FAILURES_REINIT
  71. $UTILIZATION_LOW_RESTART_3MAIN
  72. $LOST_GPU
  73. $REBOOT_ALERT
  74. $UTILIZATION_LOW_REBOOTING
  75. "
  76.  
  77. /usr/bin/curl -m 5 -s -X POST --output /dev/null https://api.telegram.org/bot${APIKEY}/sendMessage -d "text=${MSG}" -d chat_id=${CHATID}
  78.  
  79. if [ $SLOW_USB_KEY_MODE == "YES" ]
  80. then
  81.  > /home/m1/5_restartlog
  82.  > /home/m1/6_autotemplog
  83. fi
  84. fi
  85.  
  86.  
  87. #mod by kk003
  88. if [ $TELEGRAM_TYPE == "kk003" ]
  89. then
  90. CHATID=$TELEGRAM_CHATID
  91. APIKEY=$TELEGRAM_APIKEY
  92. # Number of gpus I know for sure the sistem must have (change this to nº of gpus your system have)
  93. NUMBER_GPUS_FOR_SURE=13
  94.  
  95. # String I search for to check if I am running claymore
  96. KEY_CLAYMORE="ethdcrminer64"    # Exec for Claumor 9.8. Other vesions may have a different name
  97.                                                             # You must check if this entry is right for your
  98.                                                         # system to get the script runnin correctly
  99.  
  100. # If claymore is running use the provided data?
  101. USE_CLAYMORE_STATICS="YES" # YES or NO
  102.  
  103. # Aliases
  104. # Cos telegram cut off the lines I want to make them as short as possible
  105. # Just add the gpu name such as is showed by nvidia-smi follow by the alias you want
  106. # Fields must be space separated
  107. MODELS=("GeForce GTX 1060 3GB" "GF1060_3G" "GeForce GTX 1060 6GB" "GF1060_6G")
  108.  
  109. # Query arguments for nvidia-smi
  110. # You can get a complete list of the query arguments by issuing: nvidia-smi --help-query-gpu
  111. # Add what you want here. Args must be coma separated
  112. NVIDIA_SMI_QUERY_ARGUMENTS="index,gpu_name,gpu_bus_id,pstate,utilization.gpu,power.draw,temperature.gpu,fan.speed,clocks.mem,clocks.gr,memory.used"
  113.  
  114. # Error exit codes (or RETURN VALUE as nvidia call them) for nvidia-smi
  115. # I'll treat them as an array so in couples; even value is the code number and odd value is the text that explains it
  116. NVIDIA_SMI_RETURN_VALUE=(
  117.                 "0" "Success"
  118.                 "2" "A supplied argument or flag is invalid"
  119.                 "3" "The requested operation is not available on target device"
  120.                 "4" "The current user does not have permission to access this device or perform this operation"
  121.                 "6" "A query to find an object was unsuccessful"
  122.                 "8" "A device is external power cables are not properly attached"
  123.                 "9" "NVIDIA driver is not loaded"
  124.                 "10" "NVIDIA Kernel detected an interrupt issue with a GPU"
  125.                 "12" "NVML Shared Library couldn't be found or loaded"
  126.                 "13" "Local version of NVML doesn't implement this function"
  127.                 "14" "infoROM is corrupted"
  128.                 "15" "The GPU has fallen off the bus or has otherwise become inaccessible"
  129.                 "255" "Other error or internal driver error occurred"
  130.          )
  131.  
  132. LF=$'\n' # New line
  133.  
  134.  
  135. function my_custom_mods ()
  136. {
  137.  
  138. # I organize some things my way
  139. # comment out the call to this function and you will get the standar output from nvidia-smi
  140. ###
  141. # Beginning of block
  142. ###
  143.  
  144. # Save header and remove it from the csv file
  145. CSV_HEADER=$(head -n 1 nvidia_smi_values.csv)     # Save the header of csv file
  146. sed -i -e "1d" nvidia_smi_values.csv              # Remove the header (first line of file)
  147.  
  148. ##### Changing the gpu's name for the alias (if I have it)
  149. #
  150. # First must check that elements in the array are a even number (Multiples of 2) and is not empty
  151. MODELS_LENGTH=${#MODELS[@]} # Get number of elements
  152.  
  153. if [[ $MODELS_LENGTH -ne 0 ]]; then # Is not empty?
  154.  
  155.     if [[ $((MODELS_LENGTH%2)) -eq 0 ]]; then   # Number of elements is even?. If so I assume names and alias are well matched in array
  156.  
  157.         for ((INDEX_EVEN=0; INDEX_EVEN < $MODELS_LENGTH ; INDEX_EVEN=INDEX_EVEN+2)) # First element of array have index 0
  158.         do                                                                          # Even elements are the gpu names, odd elements are alias
  159.  
  160.             NAME_GPU_IN_ARRAY=${MODELS[$INDEX_EVEN]}                                # Get the name of the gpu in array
  161.             INDEX_ODD=$(($INDEX_EVEN + 1))                                          # +1 to get the alias index
  162.             ALIAS_GPU_IN_ARRAY=${MODELS[$INDEX_ODD]}                                # Get the alias of the gpu in array
  163.  
  164.             # Find and replace gpu name if exists
  165.             sed -i "s/${NAME_GPU_IN_ARRAY}/${ALIAS_GPU_IN_ARRAY}/g" nvidia_smi_values.csv
  166.  
  167.         done
  168.  
  169.     # I get this way out if number of elements in array are odd and I don't replace names for alias
  170.     else
  171.         echo "Number of elements in variable MODELS are odd and I don't replace gpu names for alias."
  172.         echo "Check variable MODELS if you want to replace names for alias"
  173.     fi
  174.  
  175. # I get this way out if array in variable MODELS is empty
  176. else
  177.     echo "Variable MODELS is empty and I don't replace gpu names for alias."
  178.     echo "Check variable MODELS if you want to replace names for alias"
  179. fi
  180.  
  181. ##### END of Changing gpu's name by the alias (if I have it)
  182.  
  183.  
  184. # I don't want any spaces but to align thing
  185. sed -i 's/ //g' nvidia_smi_values.csv
  186.  
  187. # Get number of elements on NVIDIA_SMI_QUERY_ARGUMENTS variable
  188. NVIDIA_SMI_QUERY_ARGUMENTS_LENGTH=$(echo $NVIDIA_SMI_QUERY_ARGUMENTS | sed 's/[^,]//g' | wc -c)
  189.  
  190. # Review all the elements in variable NVIDIA_SMI_QUERY_ARGUMENTS and do some mods about the output for some fields
  191. for ((INDEX=1; INDEX <= $NVIDIA_SMI_QUERY_ARGUMENTS_LENGTH ; INDEX=INDEX+1)) # Gives me the column number
  192. do
  193.  
  194.     NVIDIA_SMI_ARGUMENT=$(echo $NVIDIA_SMI_QUERY_ARGUMENTS | cut -d, -f $INDEX)    # Gives me the name of nvidia-smi argument on array
  195.  
  196.     #### Arrange the output for the "index" nvidia-smi argument
  197.     #### I want to aling numbers <= 9 if I have more than 9 gpus so I add a space in front
  198.  
  199.     if [[ "$NVIDIA_SMI_ARGUMENT" == "index" && $GPU_COUNT -gt 10 ]]; then
  200.             LINES_TO_MODIFY=10
  201.  
  202.             for ((L=1; L <= $LINES_TO_MODIFY ; L=L+1))
  203.             do
  204.             OLD_VALUE=`sed -n -e "${L}p" nvidia_smi_values.csv | cut -d, -f$INDEX`      # Extraigo el dato original
  205.             NEW_VALUE=" "$OLD_VALUE
  206.             sed -i "$L"'s/^\(\([^,]*,\)\{'"$(($INDEX -1))"'\}\)[^,]*/\1'"$NEW_VALUE"'/' nvidia_smi_values.csv
  207.             done
  208.     fi
  209.  
  210.     #### END of Arrange the output for the "index" nvidia-smi argument
  211.  
  212.     #### Arrange the output for the "pci.bus_id" nvidia-smi argument
  213.     #### I don't want the "00000000:" at the beginning
  214.  
  215.     if [[ "$NVIDIA_SMI_ARGUMENT" == "gpu_bus_id" ]]; then
  216.         LINES_TO_MODIFY=$GPU_COUNT
  217.  
  218.         for ((L=1; L <= $LINES_TO_MODIFY ; L=L+1))
  219.         do
  220.             OLD_VALUE=`sed -n -e "${L}p" nvidia_smi_values.csv | cut -d, -f$INDEX`      # Extraigo el dato original
  221.             NEW_VALUE=$(echo "$OLD_VALUE" | sed "s/00000000://")
  222.             sed -i "$L"'s/^\(\([^,]*,\)\{'"$(($INDEX -1))"'\}\)[^,]*/\1'"$NEW_VALUE"'/' nvidia_smi_values.csv
  223.         done
  224.     fi
  225.  
  226.     #### END of Arrange the output for the "index" nvidia-smi argument
  227.  
  228.  
  229.     #### Arrange the output for the "utilization.gpu" nvidia-smi argument
  230.     #### I want to aling values to the right and keep the "%"
  231.  
  232.     if [[ "$NVIDIA_SMI_ARGUMENT" == "utilization.gpu" ]]; then
  233.             LINES_TO_MODIFY=$GPU_COUNT
  234.  
  235.             for ((L=1; L <= $LINES_TO_MODIFY ; L=L+1))
  236.             do
  237.             OLD_VALUE=`sed -n -e "${L}p" nvidia_smi_values.csv | cut -d, -f$INDEX`      # Extraigo el dato original
  238.             LEN=${#OLD_VALUE}
  239.  
  240.             case $LEN in
  241.  
  242.                 2)  NEW_VALUE="  "$OLD_VALUE
  243.                             ;;
  244.                 3)  NEW_VALUE=" "$OLD_VALUE
  245.                             ;;
  246.                 *)  NEW_VALUE=$OLD_VALUE
  247.                             ;;
  248.             esac
  249.  
  250.             sed -i "$L"'s/^\(\([^,]*,\)\{'"$(($INDEX -1))"'\}\)[^,]*/\1'"$NEW_VALUE"'/' nvidia_smi_values.csv
  251.             done
  252.     fi
  253.  
  254.     #### END of Arrange the output for the "utilization.gpu" nvidia-smi argument
  255.  
  256.  
  257.     #### Arrange the output for the "temperature.gpu" nvidia-smi argument
  258.     #### I want to aling values to the right and add the "ºC"
  259.  
  260.     if [[ "$NVIDIA_SMI_ARGUMENT" == "temperature.gpu" ]]; then
  261.         LINES_TO_MODIFY=$GPU_COUNT
  262.  
  263.         for ((L=1; L <= $LINES_TO_MODIFY ; L=L+1))
  264.         do
  265.             OLD_VALUE=`sed -n -e "${L}p" nvidia_smi_values.csv | cut -d, -f$INDEX`      # Extraigo el dato original
  266.             LEN=${#OLD_VALUE}
  267.                     CENTIGRADO="ºC"
  268.  
  269.                 case $LEN in
  270.  
  271.                         1)  NEW_VALUE="  "$OLD_VALUE$CENTIGRADO
  272.                                     ;;
  273.                         2)  NEW_VALUE=" "$OLD_VALUE$CENTIGRADO
  274.                                 ;;
  275.                         *)  NEW_VALUE=$OLD_VALUE$CENTIGRADO
  276.                                 ;;
  277.                     esac
  278.  
  279.             sed -i "$L"'s/^\(\([^,]*,\)\{'"$(($INDEX -1))"'\}\)[^,]*/\1'"$NEW_VALUE"'/' nvidia_smi_values.csv
  280.         done
  281.     fi
  282.  
  283.     #### END of Arrange the output for the "temperature.gpu" nvidia-smi argument
  284.  
  285. done
  286.  
  287. # Insert the whole header line as the first one
  288. sed -i "1s/^/$CSV_HEADER\n/" nvidia_smi_values.csv
  289.  
  290. ###
  291. # End of block with custom my mods
  292. ###
  293.  
  294. }
  295.  
  296.  
  297. function claymore_statics ()
  298. {
  299. #### Arrange the output for claymore statics
  300.  
  301. if [[ "$USE_CLAYMORE_STATICS" == "YES" ]]; then
  302.  
  303.     # Check if claymore is running
  304.     if  pgrep -x "$KEY_CLAYMORE" > /dev/null
  305.     then
  306.             CLAYMORE_IS_RUNNING="YES"
  307.             echo
  308.             echo "It seems that Claymore is running!!"
  309.  
  310.             #
  311.             # Don't know why http://localhost:3333 access forces claymore's output to show up a line like:
  312.             # "GPU #XX: GeForce GTX 1060 3GB, 3013 MB available, 9 compute units, capability: 6.1", one line x gpu in the system
  313.             # Get the latest total hashrates
  314.             LATEST_TOTAL_HASHRATES=`curl -s http://localhost:3333 | sed '/Total/!d; /Speed/!d;' | awk '{print $6}'`
  315.             echo -e "Latest Total Hashrates :\n$LATEST_TOTAL_HASHRATES" > latest_total_hashrates.txt
  316.  
  317.             # Get the indivual gpus hashrates and remove some charaters and spaces I don't want
  318.             GPUS_HASHRATES=`curl -s http://localhost:3333 | sed '/ETH: GPU/!d' | awk 'NR == 3' | sed 's/[^GPU]*\(GPU.*\)/\1/' | sed 's/ M/M/g' | sed 's/ G/G/g'`
  319.             # Make the string with individual hashrates vertical replacing "," for new line "\n" and removing the "GPUX" part
  320.             echo $GPUS_HASHRATES | sed "s/,/\n/g" | sed 's/^[^ ]* //' > gpus_hashrate.txt
  321.  
  322.             # Get total individual and rejected shares and for how long claymore is runing in one single string
  323.             # For 13 gpus should look something like this:
  324.             # Speed: 318.710 Mh/s, Total Shares: 15835(1233+1212+1226+1256+1216+1243+1228+1303+1220+1177+1237+1209+1222), Rejected: 0, Time: 55:32
  325.             #
  326.             SOME_GPUS_DATA_FROM_CLAYMORE=`curl -s http://localhost:3333 | sed '/ETH - Total/!d; /Speed/!d; /(/!d; /+/!d; s/[^Speed]*\(Speed.*\)/\1/;' | awk 'NR == 3'`
  327.  
  328.             # Get the total shares
  329.             TOTAL_SHARES=$(echo $SOME_GPUS_DATA_FROM_CLAYMORE | cut -d"(" -f 1 | cut -d" " -f 6)
  330.  
  331.             # Get the individual shares (I capture the values between the two parentheses)
  332.             # and replace the "+" signs for new line so I set the data vertical
  333.             echo $SOME_GPUS_DATA_FROM_CLAYMORE | sed 's/^.*(//; s/).*$//; s/+/\n/g' > individual_shares.txt
  334.  
  335.             # Get the rejected shares and remove de ","
  336.             REJECTED_SHARES=$(echo $SOME_GPUS_DATA_FROM_CLAYMORE | cut -d" " -f 8 | sed 's/,//')
  337.  
  338.             # How long claymore has been running?
  339.             TIME_CLAYMORE_IS_RUNNING=$(echo $SOME_GPUS_DATA_FROM_CLAYMORE | cut -d" " -f 10)
  340.  
  341.             # Creating a vertical gpux list
  342.             # If the file exists and is not empty clear it
  343.             if [[ -s v_gpus.txt ]]; then
  344.             > v_gpus.txt
  345.             fi
  346.  
  347.             LINES_TO_ADD=$(($GPU_COUNT - 1))
  348.  
  349.       for ((L=0; L <= $LINES_TO_ADD ; L=L+1))
  350.       do
  351.                 case "$L" in
  352.  
  353.                     0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 )
  354.                         echo "GPU $L" >> v_gpus.txt
  355.                         ;;
  356.                     *)
  357.                         echo "GPU$L" >> v_gpus.txt
  358.                         ;;
  359.                 esac
  360.       done
  361.  
  362.  
  363.             # Paste the whole vertical thing together
  364.             paste -d, v_gpus.txt individual_shares.txt gpus_hashrate.txt > claymore_statics.tmp
  365.  
  366.             # Mount the header field for claymore statics
  367.             CLAYMOR_STATICS_HEADER="Index, Shares, Hashrate"
  368.  
  369.             # Insert the whole header line as the first one
  370.             sed -i "1s/^/$CLAYMOR_STATICS_HEADER\n/" claymore_statics.tmp
  371.  
  372.             # Insert a new line on top
  373.             sed -i "1s/^/\n/" claymore_statics.tmp
  374.  
  375.             # Add the list of latest total hashrates and put it all togather
  376.             cat latest_total_hashrates.txt claymore_statics.tmp > claymore_statics.txt
  377.  
  378.             # Insert the Title for claymore mining information
  379.             sed -i "1s/^/** Claymore mining  Information **\n/" claymore_statics.txt
  380.             sed -i "1s/^/\n/" claymore_statics.txt
  381.  
  382.             # At the end of file add
  383.             echo " " >> claymore_statics.txt
  384.             echo "Total shares     :" $TOTAL_SHARES >> claymore_statics.txt
  385.             echo "Rejected shares  :" $REJECTED_SHARES >> claymore_statics.txt
  386.             echo "Claymore up time :" $TIME_CLAYMORE_IS_RUNNING >> claymore_statics.txt
  387.  
  388.  
  389.     else
  390.             echo "Claymore does not seem to be running!!. Skiping this bit."
  391.             CLAYMORE_IS_RUNNING="NO"
  392.     fi
  393.  
  394. fi
  395.  
  396. #### END of Arrange the output for claymore statics
  397.  
  398. }
  399.  
  400.  
  401. function salida ()
  402. {
  403. END_TIME=`date "+%Y-%m-%d %H:%M:%S"`
  404.  
  405. echo "$MSG"
  406. echo
  407. echo "End time: " $END_TIME
  408.  
  409. echo
  410. echo "**************************"
  411. echo
  412. exit
  413. }
  414.  
  415. START_TIME=`date "+%Y-%m-%d %H:%M:%S"`
  416. echo "Start time: " $START_TIME
  417.  
  418. # Is the script already running?. If so exit
  419. echo -n "Process ID :"
  420. if pidof -x $(basename $0); then
  421.     for p in $(pidof -x $(basename $0)); do
  422.         if [ $p -ne $$ ]; then
  423.             echo "$0 already running. Exiting..."
  424.             salida # exit
  425.         fi
  426.     done
  427. fi
  428.  
  429. #
  430. # Collect some info from the system
  431. #
  432.  
  433. # Clear the file's content if exists and is not empty
  434. if [[ -s system_data ]]; then
  435.     > system_data
  436. fi
  437.  
  438. # Title for system information
  439. echo "** System information **" >> system_data
  440.  
  441. # Hostname
  442. echo -n "Hostname : " >> system_data
  443. hostname >> system_data
  444. # Ips
  445. echo -n "Ips      : " >> system_data
  446. hostname -I >> system_data
  447. #
  448. # Up since
  449. echo -n "Up since : " >> system_data
  450. uptime -s >> system_data
  451. #
  452. # Up time
  453. echo -n "Up time  : " >> system_data
  454. uptime >> system_data
  455. #
  456. # who is in the system
  457. echo "Connected users : " >> system_data
  458. who >> system_data
  459.  
  460. # Here I check if there is an open sesion on any display (like display 0). If not may be the x server is down
  461. DISPLAY=$(who | grep "(:")
  462.  
  463. if [[ -z "$DISPLAY" ]]; then
  464.     echo "Not a user on any Display. May be X server is NOT running" >> system_data
  465. fi
  466.  
  467. echo "" >> system_data
  468.  
  469. #
  470. # Number of gpus nvidia-smi reports
  471. #
  472. GPU_COUNT=$(nvidia-smi --query-gpu=count --format=csv,noheader,nounits | tail -1)
  473.  
  474. echo "System is reporting : $GPU_COUNT Gpus" >> system_data
  475. echo "System should have  : $NUMBER_GPUS_FOR_SURE Gpus" >> system_data
  476.  
  477. if [[ $GPU_COUNT -ne $NUMBER_GPUS_FOR_SURE ]]; then
  478.     echo "MAY BE A PROBLEM; we should have $NUMBER_GPUS_FOR_SURE GPUs but nvidia-smi only reports $GPU_COUNT" >> system_data
  479. fi
  480.  
  481. echo "" >> system_data
  482.  
  483. # Get the gpus's info I am interested in
  484. nvidia-smi --query-gpu=$NVIDIA_SMI_QUERY_ARGUMENTS --format=csv -f nvidia_smi_values.csv
  485.  
  486. # I organize some things my way. Just comment out the call to the function and/or
  487. # delete the whole function if you don't like it and you will get the standar output from nvidia-smi
  488. my_custom_mods # Comment out this line if you don't want my custom mods
  489.  
  490. # Insert the Title for nvidia-smi report
  491. sed -i "1s/^/** Nvidia-smi Information **\n/" nvidia_smi_values.csv
  492.  
  493. # Peek up the claymore statics if configured so
  494. claymore_statics
  495.  
  496. # Put the System info+nvidia-smi+mining info together
  497. if [[ "$USE_CLAYMORE_STATICS" == "YES" && "$CLAYMORE_IS_RUNNING" == "YES" ]]; then
  498.     cat system_data nvidia_smi_values.csv claymore_statics.txt > report
  499. else
  500.     cat system_data nvidia_smi_values.csv > report
  501. fi
  502.  
  503. CONTENT=$(cat report)
  504.  
  505. MSG="$CONTENT"
  506.  
  507.  
  508. curl -s -X POST --output /dev/null https://api.telegram.org/bot${APIKEY}/sendMessage -d "text=${MSG}" -d chat_id=${CHATID}
  509. CODE_CURL=$?
  510.  
  511. # Check if the mgs went out ok
  512. if [[ $CODE_CURL -eq 0 ]]; then
  513.     echo "Msg send ok!!"
  514. else
  515.     echo "Got a non zero exit code from curl : $CODE_CURL . The message has probably not reached its destination"
  516. fi
  517.  
  518. salida # exit
  519.  
  520. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement