Răsfoiți Sursa

fix(stats): fix stats bugs with language and sending stats (#2727)

* Update info_stats.sh
* added CPU frequency
* feat: swapped event label and event action
* fix: prevent df from displaying non-english text with disk space vars

* fix force English language on df to ensure a point is used
Daniel Gibbs 6 ani în urmă
părinte
comite
466bc15e7b
2 a modificat fișierele cu 33 adăugiri și 27 ștergeri
  1. 4 4
      lgsm/functions/info_distro.sh
  2. 29 23
      lgsm/functions/info_stats.sh

+ 4 - 4
lgsm/functions/info_distro.sh

@@ -172,10 +172,10 @@ fi
 ### Disk information
 ### Disk information
 
 
 ## Available disk space on the partition.
 ## Available disk space on the partition.
-filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}')
-totalspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $2}')
-usedspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $3}')
-availspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $4}')
+filesystem=$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $1}')
+totalspace=$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $2}')
+usedspace=$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $3}')
+availspace=$(LC_ALL=C df -hP "${rootdir}" | tail -n 1 | awk '{print $4}')
 
 
 ## LinuxGSM used space total.
 ## LinuxGSM used space total.
 rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
 rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')

+ 29 - 23
lgsm/functions/info_stats.sh

@@ -14,54 +14,59 @@ if [ ! -f "${datadir}/uuid.txt" ];then
 		uuidgen > "${datadir}/uuid.txt"
 		uuidgen > "${datadir}/uuid.txt"
 	else
 	else
 		cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt"
 		cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt"
-  fi
+	fi
 fi
 fi
 
 
 uuid=$(cat "${datadir}/uuid.txt")
 uuid=$(cat "${datadir}/uuid.txt")
-# results are rounded up to reduce number of different results in analytics
-# nearest 100Mhz
+# results are rounded up to reduce number of different results in analytics.
+# nearest 100Mhz.
 cpuusedmhzroundup=$(((cpuusedmhz + 99) / 100 * 100))
 cpuusedmhzroundup=$(((cpuusedmhz + 99) / 100 * 100))
 # nearest 100MB
 # nearest 100MB
 memusedroundup=$(((memused + 99) / 100 * 100))
 memusedroundup=$(((memused + 99) / 100 * 100))
 
 
-# Level 1 Stats
-## Distro
-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=${gamename}" -d "el=${distroname}" -d "v=1" > /dev/null 2>&1
-## Game Server Name
+## Distro.
+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
+## Game Server Name.
 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
 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
-## Game Server Name
-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=${version}" -d "v=1" > /dev/null 2>&1
+## LinuxGSM Version.
+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
 
 
-# Level 2 Stats
-## CPU usage of a game server
+## CPU usage of a game server.
 if [ "${cpuusedmhzroundup}" ]; then
 if [ "${cpuusedmhzroundup}" ]; then
-  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=${gamename}" -d "el=${cpuusedmhzroundup}MHz" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
-## Ram usage of a game server
+## Ram usage of a game server.
 if [ "${memusedroundup}" ]; then
 if [ "${memusedroundup}" ]; then
-  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=${gamename}" -d "el=${memusedroundup}MB" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
-## Disk usage of a game server
+## Disk usage of a game server.
 if [ "${serverfilesdu}" ]; then
 if [ "${serverfilesdu}" ]; then
-  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=${gamename}" -d "el=${serverfilesdu}" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
 
 
-# Level 3 Stats
-## CPU Model
+## CPU Model.
 if [ "${cpumodel}" ]; then
 if [ "${cpumodel}" ]; then
-  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=${gamename}" -d "el=${cpumodel} cores:${cpucores}" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
 
 
-## Server RAM
+## CPU Frequency.
+if [ "${cpufreqency}" ]; then
+	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
+fi
+
+## Server RAM.
 if [ "${physmemtotal}" ]; then
 if [ "${physmemtotal}" ]; then
-  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=${gamename}" -d "el=${physmemtotal}" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
 
 
-## Server Disk
+## Server Disk.
 if [ "${totalspace}" ]; then
 if [ "${totalspace}" ]; then
-  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=${gamename}" -d "el=${totalspace}" -d "v=1" > /dev/null 2>&1
+	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
 fi
 fi
 
 
+## Summary Stats
+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
+
 fn_script_log_info "Send LinuxGSM stats"
 fn_script_log_info "Send LinuxGSM stats"
 fn_script_log_info "* UUID: ${uuid}"
 fn_script_log_info "* UUID: ${uuid}"
 fn_script_log_info "* Game Name: ${gamename}"
 fn_script_log_info "* Game Name: ${gamename}"
@@ -70,5 +75,6 @@ fn_script_log_info "* Game Server CPU Used: ${cpuusedmhzroundup}MHz"
 fn_script_log_info "* Game Server RAM Used: ${memusedroundup}MB"
 fn_script_log_info "* Game Server RAM Used: ${memusedroundup}MB"
 fn_script_log_info "* Game Server Disk Used: ${serverfilesdu}"
 fn_script_log_info "* Game Server Disk Used: ${serverfilesdu}"
 fn_script_log_info "* Server CPU Model: ${cpumodel}"
 fn_script_log_info "* Server CPU Model: ${cpumodel}"
+fn_script_log_info "* Server CPU Frequency: ${cpufreqency}"
 fn_script_log_info "* Server RAM: ${physmemtotal}"
 fn_script_log_info "* Server RAM: ${physmemtotal}"
 fn_script_log_info "* Server Disk: ${totalspace}"
 fn_script_log_info "* Server Disk: ${totalspace}"