| Trees | Indices | Help |
|
|---|
|
|
1 ###########################################################################
2 #
3 # This program is part of Zenoss Core, an open source monitoring platform.
4 # Copyright (C) 2007, Zenoss Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License version 2 as published by
8 # the Free Software Foundation.
9 #
10 # For complete information please visit: http://www.zenoss.com/oss/
11 #
12 ###########################################################################
13
14 import os
15
16 from Globals import InitializeClass
17 from AccessControl import ClassSecurityInfo
18 from AccessControl import Permissions
19 from DateTime import DateTime
20
21 from Products.PageTemplates.Expressions import getEngine
22 from Products.ZenUtils.ZenTales import talesCompile
23 from Products.ZenRelations.RelSchema import *
24 from Products.ZenEvents.ZenEventClasses import Status_Nagios
25
26 from ZenModelRM import ZenModelRM
27
28
29 import warnings
30 warnings.warn("NagiosCmd is deprecated", DeprecationWarning)
32
33 usessh = True
34 cycletime = 60
35 enabled = True
36 component = ""
37 eventClass = "/Status/Nagios"
38 eventKey = ""
39 severity = 3
40 commandTemplate = ""
41
42 _properties = (
43 {'id':'enabled', 'type':'boolean', 'mode':'w'},
44 {'id':'usessh', 'type':'boolean', 'mode':'w'},
45 {'id':'component', 'type':'string', 'mode':'w'},
46 {'id':'eventClass', 'type':'string', 'mode':'w'},
47 {'id':'eventKey', 'type':'string', 'mode':'w'},
48 {'id':'severity', 'type':'int', 'mode':'w'},
49 {'id':'commandTemplate', 'type':'string', 'mode':'w'},
50 )
51
52 _relations = (
53 ("nagiosTemplate", ToOne(ToManyCont, "Products.ZenModel.NagiosTemplate", "nagiosCmds")),
54 )
55
56 factory_type_information = (
57 {
58 'immediate_view' : 'editNagiosCmd',
59 'actions' :
60 (
61 { 'name' : 'Nagios Command'
62 , 'action' : 'editNagiosCmd'
63 , 'permissions' : ( Permissions.view, )
64 },
65 { 'name' : 'Modifications'
66 , 'action' : 'viewHistory'
67 , 'permissions' : ( Permissions.view, )
68 },
69 )
70 },
71 )
72
73 security = ClassSecurityInfo()
74
75
77 """Return the breadcrumb links for this object add ActionRules list.
78 [('url','id'), ...]
79 """
80 from NagiosTemplate import crumbspath
81 crumbs = super(NagiosCmd, self).breadCrumbs(terminator)
82 return crumbspath(self.nagiosTemplate(), crumbs, -2)
83
84
86 """Return tuple that defines monitored info for this cmd.
87 (ssh,cycletime,compname,eventClass,eventKey,severity,commnad)
88 """
89 return (self.usessh, self.getCycleTime(context),
90 self.getComponentName(context), self.eventClass,
91 self.eventKey, self.severity, self.getCommand(context))
92
93
95 """Get cycle time of this monitor.
96 """
97 if self.cycletime != 0: return self.cycletime
98 return context.zNagiosCycleTime
99
100
101
103 from DeviceComponent import DeviceComponent
104 comp = self.component
105 if isinstance(context, DeviceComponent):
106 comp = context.name()
107 return comp
108
109
111 """Return localized command target.
112 """
113 """Perform a TALES eval on the express using context.
114 """
115 exp = "string:"+ self.commandTemplate
116 compiled = talesCompile(exp)
117 device = context.device()
118 environ = {'dev' : device, 'devname': device.id,
119 'here' : context,
120 'compname' : self.getComponentName(context),
121 'zNagiosPath' : context.zNagiosPath,
122 'nothing' : None, 'now' : DateTime() }
123 res = compiled(getEngine().getContext(environ))
124 if isinstance(res, Exception):
125 raise res
126 if not res.startswith(context.zNagiosPath):
127 res = os.path.join(context.zNagiosPath, res)
128 return res
129
130 InitializeClass(NagiosCmd)
131
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:21 2007 | http://epydoc.sourceforge.net |