Package ZenEvents :: Module SendEvent
[hide private]
[frames] | no frames]

Source Code for Module ZenEvents.SendEvent

 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 logging 
15  import socket 
16  import xmlrpclib 
17   
18  from Products.ZenUtils.Utils import  basicAuthUrl 
19   
20 -class SendEvent(object):
21
22 - def __init__(self, agent, username, password, url):
23 self.agent = agent 24 self.url = basicAuthUrl(username, password, url) 25 self.server = xmlrpclib.Server(self.url) 26 severities = self.server.getSeverities() 27 for name, value in severities: 28 setattr(self, name, value)
29 30
31 - def sendEvent(self, deviceName, evclass, msg, severity, **kwargs):
32 """ 33 Send a ZenEvent to the event manager. Events must have: 34 deviceName - which is the FQDN of the device 35 evclass - the event class of the event 36 msg - the event message 37 severity - the severity of the event 38 39 agent - is the management collection system that the event came through 40 41 Other potential fields are: 42 43 """ 44 event = {} 45 event['Node'] = deviceName 46 event['Class'] = evclass 47 event['Summary'] = msg 48 event['Severity'] = severity 49 event['Agent'] = self.agent 50 event['Manager'] = socket.getfqdn() 51 event.update(kwargs) 52 try: 53 self.server.sendEvent(event) 54 except SystemExit: raise 55 except: 56 raise 57 logging.exception("Event notification failed url %s", self.url)
58