1
2
3
4
5
6
7
8
9
10
11
12
13
14 from Globals import InitializeClass
15 from AccessControl import ClassSecurityInfo
16 from AccessControl import Permissions
17 from Commandable import Commandable
18 from Products.ZenRelations.RelSchema import *
19 from Acquisition import aq_chain
20 from zExceptions import NotFound
21
22 from OSComponent import OSComponent
23 from ZenPackable import ZenPackable
24
36
37 -class OSProcess(OSComponent, Commandable, ZenPackable):
38 """Hardware object"""
39 portal_type = meta_type = 'OSProcess'
40
41 procName = ""
42 parameters = ""
43 _procKey = ""
44 collectors = ('zenprocess', )
45
46 _properties = OSComponent._properties + (
47 {'id':'procName', 'type':'string', 'mode':'w'},
48 {'id':'parameters', 'type':'string', 'mode':'w'},
49 {'id':'zAlertOnRestarts', 'type':'boolean', 'mode':'w'},
50 {'id':'zFailSeverity', 'type':'int', 'mode':'w'},
51 )
52
53 _relations = OSComponent._relations + ZenPackable._relations + (
54 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "processes")),
55 ("osProcessClass", ToOne(ToMany, "Products.ZenModel.OSProcessClass", "instances")),
56 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
57 )
58
59 factory_type_information = (
60 {
61 'immediate_view' : 'osProcessDetail',
62 'actions' :
63 (
64 { 'id' : 'status'
65 , 'name' : 'Status'
66 , 'action' : 'osProcessDetail'
67 , 'permissions' : ( Permissions.view, )
68 },
69 { 'id' : 'perfConf'
70 , 'name' : 'Template'
71 , 'action' : 'objTemplates'
72 , 'permissions' : ("Change Device", )
73 },
74 { 'id' : 'manage'
75 , 'name' : 'Administration'
76 , 'action' : 'osProcessManage'
77 , 'permissions' : ("Manage DMD",)
78 },
79 { 'id' : 'viewHistory'
80 , 'name' : 'Modifications'
81 , 'action' : 'viewHistory'
82 , 'permissions' : ( Permissions.view, )
83 },
84 )
85 },
86 )
87
88 security = ClassSecurityInfo()
89
91 """Return information used to monitor this process.
92 """
93 ignoreParams = getattr(self.osProcessClass(), 'ignoreParameters', False)
94 return (self.id, self.name(), ignoreParams,
95 self.alertOnRestart(), self.getFailSeverity())
96
97
99 """Set the OSProcessClass based on procKey which is the proc + args.
100 We set by matching regular expressions of each proces class.
101 """
102 klass = self.getDmdObj(procKey)
103 klass.instances.addRelation(self)
104
105
107 """Return the current procKey.
108 """
109 pClass = self.osProcessClass()
110 if pClass:
111 return pClass.getPrimaryDmdId()
112
113
125
126
132
133
135 """Should this service be monitored or not. Use ServiceClass aq path.
136 """
137 return self.getAqProperty("zMonitor")
138
139
142
143
145 """Return a list of tuples with the possible severities
146 """
147 return self.ZenEventManager.getSeverities()
148
150 """Return the severity for this service when it fails.
151 """
152 return self.getAqProperty("zFailSeverity")
153
155 """Return a string representation of zFailSeverity
156 """
157 return self.ZenEventManager.severities[self.getAqProperty("zFailSeverity")]
158
159
161 return self.osProcessClass()
162
163
164 security.declareProtected('Manage DMD', 'manage_editOSProcess')
179
180
182 ''' Called by Commandable.doCommand() to ascertain objects on which
183 a UserCommand should be executed.
184 '''
185 return [self]
186
187
193
194
199
200
203
204
205 InitializeClass(OSProcess)
206