Package Products :: Package ZenEvents :: Module ActionRule
[hide private]
[frames] | no frames]

Source Code for Module Products.ZenEvents.ActionRule

 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 or (at your 
 8  # option) any later version as published by the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  import logging 
14  log = logging.getLogger("zen.ActionRule") 
15   
16  from Globals import InitializeClass 
17  from AccessControl import ClassSecurityInfo 
18   
19  from Products.ZenModel.ZenModelRM import ZenModelRM 
20  from Products.ZenRelations.RelSchema import * 
21  from Products.ZenEvents.EventFilter import EventFilter 
22   
23 -class ActionRule(ZenModelRM, EventFilter):
24 """ 25 Rule applied to events that then executes an action on matching events. 26 """ 27 28 meta_type = "ActionRule" 29 30 where = "severity >= 4 and eventState = 0 and prodState = 1000" 31 delay = 0 32 repeatTime = 0 33 action = "email" 34 format = "[zenoss] %(device)s %(summary)s" 35 body = "Device: %(device)s\n" \ 36 "Component: %(component)s\n" \ 37 "Severity: %(severityString)s\n" \ 38 "Time: %(firstTime)s\n" \ 39 "Message:\n%(message)s\n" \ 40 "<a href=\"%(eventUrl)s\">Event Detail</a>\n" \ 41 "<a href=\"%(ackUrl)s\">Acknowledge</a>\n" \ 42 "<a href=\"%(deleteUrl)s\">Delete</a>\n" \ 43 "<a href=\"%(eventsUrl)s\">Device Events</a>\n" 44 sendClear = True 45 clearFormat = "[zenoss] CLEAR: %(device)s %(clearOrEventSummary)s" 46 clearBody = \ 47 "Event: '%(summary)s'\n" \ 48 "Cleared by: '%(clearSummary)s'\n" \ 49 "At: %(clearFirstTime)s\n" \ 50 "Device: %(device)s\n" \ 51 "Component: %(component)s\n" \ 52 "Severity: %(severityString)s\n" \ 53 "Message:\n%(message)s\n" \ 54 "<a href=\"%(undeleteUrl)s\">Undelete</a>\n" 55 enabled = False 56 actionTypes = ("page", "email") 57 targetAddr = "" 58 plainText = False 59 60 _properties = ZenModelRM._properties + ( 61 {'id':'where', 'type':'text', 'mode':'w'}, 62 {'id':'format', 'type':'text', 'mode':'w'}, 63 {'id':'body', 'type':'text', 'mode':'w'}, 64 {'id':'sendClear', 'type':'boolean', 'mode':'w'}, 65 {'id':'clearFormat', 'type':'text', 'mode':'w'}, 66 {'id':'clearBody', 'type':'text', 'mode':'w'}, 67 {'id':'delay', 'type':'int', 'mode':'w'}, 68 {'id':'action', 'type':'selection', 'mode':'w', 69 'select_variable': 'actionTypes',}, 70 {'id':'enabled', 'type':'boolean', 'mode':'w'}, 71 {'id':'targetAddr', 'type':'string', 'mode':'w'}, 72 {'id':'repeatTime', 'type':'int', 'mode':'w'}, 73 {'id':'plainText', 'type':'boolean', 'mode':'w'}, 74 ) 75 76 _relations = ( 77 ("windows", ToManyCont(ToOne,"Products.ZenEvents.ActionRuleWindow","actionRule")), 78 ) 79 80 security = ClassSecurityInfo() 81
82 - def getUser(self):
83 """Return the user this action is for. 84 """ 85 return self.getPrimaryParent()
86
87 - def getUserid(self):
88 """Return the userid this action is for. 89 """ 90 return self.getUser().getId()
91 92 InitializeClass(ActionRule) 93