The unified diff between revisions [f6ef05d7..] and [379e01ab..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'phonehome.py'
#
#
# patch "phonehome.py"
# from [7215d569159913685d473102ad7ca95d91637121]
# to [b8c0c8fb4603036b3cd9be15ca0129de7119c155]
#
============================================================
--- phonehome.py 7215d569159913685d473102ad7ca95d91637121
+++ phonehome.py b8c0c8fb4603036b3cd9be15ca0129de7119c155
@@ -3,20 +3,24 @@
#
# the phonehome client
#
-# python program with plugins; runs each plugin according to the configuration file
-#
+# python program with plugins that run various tests
+# also sends information about the machine to server
+# client<->server communication happens over SOAP
#
import sys
import os
import config
import traceback
+import ZSI
+from ZSI.client import Binding
if __name__ == '__main__':
# load each of the plugins
results = []
sys.path.insert(0, config.plugin_path)
+ # run each plugin
for plugin_name in config.plugins:
def run_plugin():
mod = __import__(plugin_name, globals(), locals(), [''])
@@ -28,11 +32,34 @@ if __name__ == '__main__':
try:
result = run_plugin()
except:
- result = [ ("critical", traceback.format_exc()) ]
+ result = [ ("traceback", traceback.format_exc()) ]
result = [(plugin_name,) + t for t in result]
results += result
+
+ # send the results of our plugins back to the server
+ b = Binding(url=config.soap_address, auth=(ZSI.AUTH.httpbasic, 'phonehome', 'goats'))
+ b.plugin_results(results)
+ sys.exit(0)
- for plugin_name, urgency, description in results:
- print plugin_name, urgency, description
+ # we also want to send over information about this machine
+ def cpuinfo():
+ rv = []
+ if not os.access('/proc/cpuinfo', os.R_OK):
+ return rv
+ for line in open('/proc/cpuinfo'):
+ fields = [t.strip() for t in line.split(':', 1)]
+ if len(fields) != 2: continue
+ key, value = fields
+ if key == 'cpu MHz':
+ rv.append(value)
+ return rv
+ cpus = cpuinfo()
+ b.cpu_info(cpus)
+ def memoryinfo():
+ if not os.access('/proc/meminfo', os.R_OK):
+ return None
+ return open('/proc/meminfo').readline().split(':', 1)[1].strip()
+ mem = memoryinfo()
+ b.memory_info(mem)