1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__='''WmiService
15
16 Provides Wmi config to zenwin clients.
17 '''
18
19 from Products.ZenHub.HubService import HubService
20 from Products.DataCollector.ApplyDataMap import ApplyDataMap
21 from Products.ZenModel.Device import Device
22 from Products.ZenModel.DeviceClass import DeviceClass
23
24 from Procrastinator import Procrastinate
25
27
32
34 """Return list of (devname,user,passwd,url) for each device.
35 user and passwd are used to connect via wmi.
36 """
37
38 devinfo = []
39 for dev in self.config.devices():
40 dev = dev.primaryAq()
41 if not dev.monitorDevice(): continue
42 if getattr(dev, 'zWmiMonitorIgnore', False): continue
43 user = getattr(dev,'zWinUser','')
44 passwd = getattr(dev, 'zWinPassword', '')
45 sev = getattr(dev, 'zWinEventlogMinSeverity', '')
46 devinfo.append((dev._lastChange,
47 dev.id,
48 dev.getManageIp(),
49 str(user),
50 str(passwd),
51 sev,
52 dev.absolute_url()))
53 return devinfo
54
55
57 """Return a list of (devname, user, passwd, {'EvtSys':0,'Exchange':0})
58 """
59 svcinfo = []
60 allsvcs = {}
61 for dev in self.config.devices():
62 dev = dev.primaryAq()
63 if not dev.monitorDevice(): continue
64 if getattr(dev, 'zWmiMonitorIgnore', False): continue
65 svcs = {}
66 for s in dev.getMonitoredComponents(type='WinService'):
67 name = s.name()
68 if type(name) == type(u''):
69 name = name.encode(s.zCollectorDecoding)
70 svcs[name] = (s.getStatus(), s.getAqProperty('zFailSeverity'))
71 if not svcs and not dev.zWinEventlog: continue
72 user = getattr(dev,'zWinUser','')
73 passwd = getattr(dev, 'zWinPassword', '')
74 svcinfo.append((dev.id, dev.getManageIp(), str(user), str(passwd), svcs))
75 return svcinfo
76
77
79 return self.config.propertyItems()
80
81 - def remote_applyDataMap(self,
82 url,
83 datamap,
84 relname="",
85 compname="",
86 modname=""):
97
107
108 - def push(self, object):
109 if (not object.monitorDevice() or
110 getattr(object, 'zWmiMonitorIgnore', False)):
111 self.deleted(object)
112 else:
113 for listener in self.listeners:
114 listener.callRemote('notifyConfigChanged')
115 self.procrastinator.clear()
116
118 for listener in self.listeners:
119 if isinstance(obj, Device):
120 listener.callRemote('deleteDevice', obj.id)
121