info_stats.sh 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # LinuxGSM info_stats.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Optional Stats to send to LinuxGSM Developer
  6. # Uses Google analytics
  7. info_distro.sh
  8. # generate uuid
  9. if [ ! -f "${datadir}/uuid.txt" ]; then
  10. mkdir -p "${datadir}"
  11. touch "${datadir}/uuid.txt"
  12. if [ "$(command -v uuidgen 2>/dev/null)" ]; then
  13. uuidgen > "${datadir}/uuid.txt"
  14. else
  15. cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt"
  16. fi
  17. fi
  18. uuid=$(cat "${datadir}/uuid.txt")
  19. # results are rounded up to reduce number of different results in analytics.
  20. # nearest 100Mhz.
  21. cpuusedmhzroundup=$(((cpuusedmhz + 99) / 100 * 100))
  22. # nearest 100MB
  23. memusedroundup=$(((memused + 99) / 100 * 100))
  24. ## Distro.
  25. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=distro" -d "ea=${distroname}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  26. ## Game Server Name.
  27. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=game" -d "ea=${gamename}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  28. ## LinuxGSM Version.
  29. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=version" -d "ea=${version}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  30. ## CPU usage of a game server.
  31. if [ "${cpuusedmhzroundup}" ]; then
  32. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=cpuused" -d "ea=${cpuusedmhzroundup}MHz" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  33. fi
  34. ## Ram usage of a game server.
  35. if [ "${memusedroundup}" ]; then
  36. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=ramused" -d "ea=${memusedroundup}MB" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  37. fi
  38. ## Disk usage of a game server.
  39. if [ "${serverfilesdu}" ]; then
  40. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=diskused" -d "ea=${serverfilesdu}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  41. fi
  42. ## CPU Model.
  43. if [ "${cpumodel}" ]; then
  44. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=servercpu" -d "ea=${cpumodel} ${cpucores} cores" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  45. fi
  46. ## CPU Frequency.
  47. if [ "${cpufreqency}" ]; then
  48. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=servercpufreq" -d "ea=${cpufreqency} x${cpucores}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  49. fi
  50. ## Server RAM.
  51. if [ "${physmemtotal}" ]; then
  52. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=serverram" -d "ea=${physmemtotal}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  53. fi
  54. ## Server Disk.
  55. if [ "${totalspace}" ]; then
  56. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=serverdisk" -d "ea=${totalspace}" -d "el=${gamename}" -d "v=1" > /dev/null 2>&1
  57. fi
  58. ## Summary Stats
  59. curl https://www.google-analytics.com/collect -d "tid=UA-655379-31" -d "aip=1" -d "cid=${uuid}" -d "t=event" -d "ec=summary" -d "ea=GAME: ${gamename} | DISTRO: ${distroname} | CPU MODEL: ${cpumodel} ${cpucores} cores | RAM: ${physmemtotal} | DISK: ${totalspace}" -d "v=1" > /dev/null 2>&1
  60. fn_script_log_info "Send LinuxGSM stats"
  61. fn_script_log_info "* UUID: ${uuid}"
  62. fn_script_log_info "* Game Name: ${gamename}"
  63. fn_script_log_info "* Distro Name: ${distroname}"
  64. fn_script_log_info "* Game Server CPU Used: ${cpuusedmhzroundup}MHz"
  65. fn_script_log_info "* Game Server RAM Used: ${memusedroundup}MB"
  66. fn_script_log_info "* Game Server Disk Used: ${serverfilesdu}"
  67. fn_script_log_info "* Server CPU Model: ${cpumodel}"
  68. fn_script_log_info "* Server CPU Frequency: ${cpufreqency}"
  69. fn_script_log_info "* Server RAM: ${physmemtotal}"
  70. fn_script_log_info "* Server Disk: ${totalspace}"