forked from p34709852/monkey
all info works
This commit is contained in:
parent
805c7ad38a
commit
020c6398cd
|
@ -20,9 +20,9 @@ WMI_CLASSES = set(["Win32_OperatingSystem",
|
||||||
"Win32_LoggedOnUser",
|
"Win32_LoggedOnUser",
|
||||||
"Win32_UserProfile",
|
"Win32_UserProfile",
|
||||||
"win32_UserAccount",
|
"win32_UserAccount",
|
||||||
#"Win32_Process",
|
"Win32_Product",
|
||||||
#"Win32_Product",
|
"Win32_Process",
|
||||||
#"Win32_Service"
|
"Win32_Service"
|
||||||
])
|
])
|
||||||
|
|
||||||
def fix_obj_for_mongo(o):
|
def fix_obj_for_mongo(o):
|
||||||
|
@ -39,40 +39,40 @@ def fix_obj_for_mongo(o):
|
||||||
# mongo dosn't like unprintable chars, so we use repr :/
|
# mongo dosn't like unprintable chars, so we use repr :/
|
||||||
return repr(o)
|
return repr(o)
|
||||||
|
|
||||||
|
elif hasattr(o, "__class__") and o.__class__ == wmi._wmi_object:
|
||||||
|
return fix_wmi_obj_for_mongo(o)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return repr(o)
|
return repr(o)
|
||||||
|
|
||||||
"""
|
|
||||||
def fix_wmi_obj_for_mongo(o):
|
def fix_wmi_obj_for_mongo(o):
|
||||||
for item in wmi_class:
|
|
||||||
row = {}
|
row = {}
|
||||||
|
|
||||||
for prop in item.properties:
|
for prop in o.properties:
|
||||||
try:
|
try:
|
||||||
value = getattr(item, prop)
|
value = getattr(o, prop)
|
||||||
except wmi.x_wmi:
|
except wmi.x_wmi:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
row[prop] = value
|
row[prop] = fix_obj_for_mongo(value)
|
||||||
|
|
||||||
for method_name in item.methods:
|
for method_name in o.methods:
|
||||||
if not method_name.startswith("GetOwner"):
|
if not method_name.startswith("GetOwner"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
method = getattr(item, method_name)
|
method = getattr(o, method_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
row[method_name[3:]] = method()
|
value = method()
|
||||||
|
value = fix_obj_for_mongo(value)
|
||||||
|
row[method_name[3:]] = value
|
||||||
|
|
||||||
except wmi.x_wmi:
|
except wmi.x_wmi:
|
||||||
#LOG.error("Error running wmi method '%s'" % (method_name, ))
|
#LOG.error("Error running wmi method '%s'" % (method_name, ))
|
||||||
#LOG.error(traceback.format_exc())
|
#LOG.error(traceback.format_exc())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result.append(row)
|
return row
|
||||||
"""
|
|
||||||
|
|
||||||
class WindowsInfoCollector(InfoCollector):
|
class WindowsInfoCollector(InfoCollector):
|
||||||
"""
|
"""
|
||||||
|
@ -111,7 +111,7 @@ class WindowsInfoCollector(InfoCollector):
|
||||||
|
|
||||||
def get_wmi_info(self):
|
def get_wmi_info(self):
|
||||||
for wmi_class_name in WMI_CLASSES:
|
for wmi_class_name in WMI_CLASSES:
|
||||||
self.info[wmi_class_name] = fix_obj_for_mongo(self.get_wmi_class(wmi_class_name))
|
self.info[wmi_class_name] = self.get_wmi_class(wmi_class_name)
|
||||||
|
|
||||||
def get_wmi_class(self, class_name):
|
def get_wmi_class(self, class_name):
|
||||||
if not self.wmi:
|
if not self.wmi:
|
||||||
|
@ -124,12 +124,7 @@ class WindowsInfoCollector(InfoCollector):
|
||||||
#LOG.error(traceback.format_exc())
|
#LOG.error(traceback.format_exc())
|
||||||
return
|
return
|
||||||
|
|
||||||
print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
return fix_obj_for_mongo(wmi_class)
|
||||||
print type(wmi_class)
|
|
||||||
print "@" * 20
|
|
||||||
os._exit(1)
|
|
||||||
|
|
||||||
return wmi_class
|
|
||||||
|
|
||||||
def get_reg_key(self, subkey_path, store=_winreg.HKEY_LOCAL_MACHINE):
|
def get_reg_key(self, subkey_path, store=_winreg.HKEY_LOCAL_MACHINE):
|
||||||
key = _winreg.ConnectRegistry(None, store)
|
key = _winreg.ConnectRegistry(None, store)
|
||||||
|
|
Loading…
Reference in New Issue