Skip to content

Instantly share code, notes, and snippets.

@vidplace7
Last active November 4, 2015 17:33
Show Gist options
  • Save vidplace7/85baf18d545266adcd87 to your computer and use it in GitHub Desktop.
Save vidplace7/85baf18d545266adcd87 to your computer and use it in GitHub Desktop.
Stats basis
import subprocess
import os
import requests
if os.geteuid() != 0:
exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
cmd_info = {
'_id': "lsblk --nodeps -no serial /dev/sda | md5sum | awk '{ print $1 }'",
'device': "dmidecode -s system-product-name",
'os_version': "lsb_release -r | awk '{ print $2 }'",
'cpu_model': "dmidecode -s processor-version",
'locale': "echo $LANG",
'ram': "free -m | grep Mem | awk '{ print $2 }'"
}
collected = {}
for cmd in cmd_info:
print cmd_info[cmd]
proc = subprocess.Popen(cmd_info[cmd], shell=True, stdout=subprocess.PIPE)
tmp = proc.stdout.read()[0:-1]
collected[cmd] = tmp
print collected
put = requests.post("https://stats.galliumos.org/new_install/", json=collected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment