Collect statistic information about this boot
authorUlrich Dangel <mru@grml.org>
Thu, 24 Nov 2011 21:01:09 +0000 (22:01 +0100)
committerChristian Hofstaedtler <ch@grml.org>
Tue, 6 Dec 2011 10:46:13 +0000 (11:46 +0100)
[ch: squashed, reworded]

autoconfig
autoconfig.functions
grml-autoconfig

index 88ee853..29a6d67 100644 (file)
@@ -87,6 +87,7 @@ CONFIG_PASSWD='yes'           # set password via bootparam passwd
 CONFIG_SCRIPTS='yes'          # execute scripts from the scripts option
 CONFIG_SERVICES='yes'         # check for services to run, provided via bootparam
 CONFIG_SMALL='yes'            # use a less "bloat" /etc/inittab for small computer with less RAM
+CONFIG_STATS='yes'            # Report stats to stats server
 CONFIG_SSH='yes'              # check for bootparam ssh
 CONFIG_SWRAID='yes'           # check for software raid devices [only in live-mode]
 CONFIG_TESTCD='yes'           # CD checker
index 0215837..61f4266 100755 (executable)
@@ -1346,6 +1346,34 @@ config_netscript() {
 }
 # }}}
 
+# {{{ stats
+config_stats() {
+ if ! checkbootparam 'nostats' ; then
+   BASE_URL="http://stats.grml.org/report/"
+   ACTION_NAME=Boot
+
+   HOST_ID=$(cat /proc/sys/kernel/random/boot_id)
+
+   grep -q " lm " /proc/cpuinfo && HAS_64BIT="1" || HAS_64BIT="0"
+   DATE_STRING=$(date +'h=%H&m=%M&s=%S')
+   [ -e /etc/grml_version ] && VERSION=$(cat /etc/grml_version) || \
+     VERSION=$(lsb_release -d | awk -F: '{gsub(/^[ \t]+/, "", $2); print $2}')
+
+   PARAMS="$( echo "$CMDLINE" | sed -e 's/=[^ ]*/=VALUE/g' | tr " " "\n"|sort|tr "\n" " " )"
+
+   echo "$CMDLINE" | grep -q -e "fetch|nfsroot" && BOOT="remote"
+   [ -z "$BOOT" ] && BOOT="local"
+
+   ADDITIONAL_PARAMS=""
+   ( [ -n "$COLUMNS" ] && [ -n "$LINES" ] ) && \
+     ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS&res=$((COLUMNS * 8))x$((LINES * 16))"
+
+   URI='$BASE_URL?action=${ACTION_NAME}\&$DATE_STRING\&unique_id=${HOST_ID}\&support_64bit=$HAS_64BIT\&version=$version\&bootup=$BOOT\&params=$PARAMS$ADDITIONAL_PARAMS'
+
+   get_remote_file "$URI" "/dev/null"  >/dev/null 2>&1 &!
+ fi
+}
+# }}}
 # {{{ fix/workaround for unionfs
 fix_unionfs(){
   if [ -z "$INSTALLED" ]; then
index 30f496d..70eef3c 100755 (executable)
@@ -170,6 +170,8 @@ checkvalue $CONFIG_NETCONFIG && config_netconfig
 
 checkvalue $CONFIG_NETSCRIPT && config_netscript
 
+checkvalue $CONFIG_STATS && config_stats
+
 checkvalue $CONFIG_SERVICES && config_services
 
 checkvalue $CONFIG_NETIPV6 && config_ipv6