]>
git.ipfire.org Git - oddments/fireinfo.git/blob - fireinfo/system.py
22 "public_id" : self
.public_id
,
23 "private_id" : self
.private_id
,
26 "language" : self
.language
,
27 "release" : self
.release
,
28 "memory" : self
.memory
,
29 "kernel" : self
.kernel
,
30 "root_size" : self
.root_size
,
33 "virtual" : self
.virtual
,
36 for device
in self
.devices
:
38 "subsystem" : device
.subsystem
.lower(),
39 "vendor" : device
.vendor
.lower(),
40 "model" : device
.model
.lower(),
41 "deviceclass" : device
.deviceclass
45 "vendor" : self
.cpu
.vendor
,
46 "model" : self
.cpu
.model
,
47 "stepping" : self
.cpu
.stepping
,
48 "flags" : self
.cpu
.flags
,
49 "bogomips" : self
.cpu
.bogomips
,
50 "speed" : self
.cpu
.speed
,
51 "modes" : self
.cpu
.modes
,
52 "hypervisor" : self
.cpu
.hypervisor
,
53 "virtype" : self
.cpu
.virtype
,
54 "family" : self
.cpu
.family
,
55 "count" : self
.cpu
.count
68 This returns a globally (hopefully) ID to identify the host
69 later (by request) in the database.
71 return hashlib
.sha1(self
._unique
_id
).hexdigest()
76 The private ID is built out of the _unique_id and used to
77 permit a host to do changes on the database.
79 No one could ever guess this without access to the host.
81 return hashlib
.sha1("%s" % reversed(self
._unique
_id
)).hexdigest()
86 This is a helper ID which is generated out of some hardware information
87 that is considered to be constant over a PC's lifetime.
89 None of the data here is ever sent to the server.
91 return "123456789" # XXX just a dummy
95 with
open("/var/ipfire/main/settings", "r") as f
:
96 for line
in f
.readlines():
97 key
, val
= line
.split("=", 1)
103 with
open("/etc/system-release", "r") as f
:
104 return f
.read().strip()
108 with
open("/proc/meminfo", "r") as f
:
109 firstline
= f
.readline().strip()
110 return firstline
.split()[1]
118 with
open("/etc/mtab", "r") as f
:
119 dev
, mountpoint
, rest
= f
.readline().split(" ",2)
120 if mountpoint
== "/":
122 # cut off all digits at end of string
123 while dev
[-1] in string
.digits
:
129 path
="/sys/block/%s/size" %self
.root_disk
130 if not os
.path
.exists(path
):
132 with
open(path
, "r") as f
:
133 return int(f
.readline())*512/1024
136 toscan
= (("/sys/bus/pci/devices", device
.PCIDevice
),
137 ("/sys/bus/usb/devices", device
.USBDevice
))
138 for path
, cls
in toscan
:
139 dirlist
= os
.listdir(path
)
141 self
.devices
.append(cls(os
.path
.join(path
, dir)))
146 Say if the host is running in a virtual environment.
148 return _fireinfo
.is_virtualized()
152 if __name__
== "__main__":
161 print "------------\n", s
.devices
, "\n------------\n"
166 r
= urllib2
.Request("http://192.168.10.101:9001/send/%s" %s.public_id
, data
= urllib
.urlencode({"profile" : s
.profile()}))