]>
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 "family" : self
.cpu
.family
,
53 "count" : self
.cpu
.count
56 # Only append hypervisor information if we are virtualized.
59 "type" : self
.hypervisor
.type,
60 "vendor" : self
.hypervisor
.vendor
,
73 This returns a globally (hopefully) ID to identify the host
74 later (by request) in the database.
76 return hashlib
.sha1(self
._unique
_id
).hexdigest()
81 The private ID is built out of the _unique_id and used to
82 permit a host to do changes on the database.
84 No one could ever guess this without access to the host.
86 return hashlib
.sha1("%s" % reversed(self
._unique
_id
)).hexdigest()
91 This is a helper ID which is generated out of some hardware information
92 that is considered to be constant over a PC's lifetime.
94 None of the data here is ever sent to the server.
96 return "123456789" # XXX just a dummy
100 # Return "unknown" if settings file does not exist.
101 filename
= "/var/ipfire/main/settings"
102 if not os
.path
.exists(filename
):
105 with
open(filename
, "r") as f
:
106 for line
in f
.readlines():
107 key
, val
= line
.split("=", 1)
113 with
open("/etc/system-release", "r") as f
:
114 return f
.read().strip()
118 with
open("/proc/meminfo", "r") as f
:
119 firstline
= f
.readline().strip()
120 return firstline
.split()[1]
128 with
open("/etc/mtab", "r") as f
:
129 dev
, mountpoint
, rest
= f
.readline().split(" ",2)
130 if mountpoint
== "/":
132 # cut off all digits at end of string
133 while dev
[-1] in string
.digits
:
139 path
="/sys/block/%s/size" %self
.root_disk
140 if not os
.path
.exists(path
):
142 with
open(path
, "r") as f
:
143 return int(f
.readline())*512/1024
146 toscan
= (("/sys/bus/pci/devices", device
.PCIDevice
),
147 ("/sys/bus/usb/devices", device
.USBDevice
))
148 for path
, cls
in toscan
:
149 dirlist
= os
.listdir(path
)
151 self
.devices
.append(cls(os
.path
.join(path
, dir)))
156 Say if the host is running in a virtual environment.
158 return self
.hypervisor
.virtual
162 if __name__
== "__main__":
171 print "------------\n", s
.devices
, "\n------------\n"
172 print json
.dumps(s
.profile(), sort_keys
=True, indent
=4)