]>
git.ipfire.org Git - oddments/fireinfo.git/blob - fireinfo/system.py
19 self
.hypervisor
= hypervisor
.Hypervisor()
23 "public_id" : self
.public_id
,
24 "private_id" : self
.private_id
,
27 "language" : self
.language
,
28 "release" : self
.release
,
29 "memory" : self
.memory
,
30 "kernel" : self
.kernel
,
31 "root_size" : self
.root_size
,
34 "virtual" : self
.virtual
,
37 for device
in self
.devices
:
39 "subsystem" : device
.subsystem
.lower(),
40 "vendor" : device
.vendor
.lower(),
41 "model" : device
.model
.lower(),
42 "deviceclass" : device
.deviceclass
46 "vendor" : self
.cpu
.vendor
,
47 "model" : self
.cpu
.model
,
48 "stepping" : self
.cpu
.stepping
,
49 "flags" : self
.cpu
.flags
,
50 "bogomips" : self
.cpu
.bogomips
,
51 "speed" : self
.cpu
.speed
,
52 "hypervisor" : self
.cpu
.hypervisor
,
53 "virtype" : self
.cpu
.virtype
,
54 "family" : self
.cpu
.family
,
55 "count" : self
.cpu
.count
58 # Only append hypervisor information if we are virtualized.
61 "type" : self
.hypervisor
.type,
62 "vendor" : self
.hypervisor
.vendor
,
75 This returns a globally (hopefully) ID to identify the host
76 later (by request) in the database.
78 return hashlib
.sha1(self
._unique
_id
).hexdigest()
83 The private ID is built out of the _unique_id and used to
84 permit a host to do changes on the database.
86 No one could ever guess this without access to the host.
88 return hashlib
.sha1("%s" % reversed(self
._unique
_id
)).hexdigest()
93 This is a helper ID which is generated out of some hardware information
94 that is considered to be constant over a PC's lifetime.
96 None of the data here is ever sent to the server.
98 return "123456789" # XXX just a dummy
102 with
open("/var/ipfire/main/settings", "r") as f
:
103 for line
in f
.readlines():
104 key
, val
= line
.split("=", 1)
110 with
open("/etc/system-release", "r") as f
:
111 return f
.read().strip()
115 with
open("/proc/meminfo", "r") as f
:
116 firstline
= f
.readline().strip()
117 return firstline
.split()[1]
125 with
open("/etc/mtab", "r") as f
:
126 dev
, mountpoint
, rest
= f
.readline().split(" ",2)
127 if mountpoint
== "/":
129 # cut off all digits at end of string
130 while dev
[-1] in string
.digits
:
136 path
="/sys/block/%s/size" %self
.root_disk
137 if not os
.path
.exists(path
):
139 with
open(path
, "r") as f
:
140 return int(f
.readline())*512/1024
143 toscan
= (("/sys/bus/pci/devices", device
.PCIDevice
),
144 ("/sys/bus/usb/devices", device
.USBDevice
))
145 for path
, cls
in toscan
:
146 dirlist
= os
.listdir(path
)
148 self
.devices
.append(cls(os
.path
.join(path
, dir)))
153 Say if the host is running in a virtual environment.
155 return self
.hypervisor
.virtual
159 if __name__
== "__main__":
168 print "------------\n", s
.devices
, "\n------------\n"
173 r
= urllib2
.Request("http://192.168.10.101:9001/send/%s" %s.public_id
, data
= urllib
.urlencode({"profile" : s
.profile()}))