Last active
November 4, 2015 17:33
-
-
Save vidplace7/85baf18d545266adcd87 to your computer and use it in GitHub Desktop.
Stats basis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment