class KibotNotify(NagiosNotification): template = "" def setupParser(self): p = NagiosNotification.setupParser(self) p.add_option("-s", "--socket", dest="socket", help="path to kibot socket") p.add_option("-c", "--channel", dest="channel", help="channel to send notification on") p.add_option("-e", "--error", dest="errorEmail", help="email to send tracebacks to") return p def parseArgs(self): opts, args = NagiosNotification.parseArgs(self) if not opts.socket: print "Socket not defined." self.usage() if not opts.channel: print "Channel not defined." self.usage() self.bot = Kibot(opts.socket) self.channel = opts.channel self.errorEmail = opts.errorEmail return opts, args @email_hook def notify(self): NagiosNotification.notify(self) msg = [] for line in (self.template % self.vars).split("\n"): if not line == "" and not line.strip().endswith(":"): msg.append(line) self.bot.inchan(self.channel, "say %s" % ", ".join(msg))
def parseArgs(self): opts, args = NagiosNotification.parseArgs(self) if not opts.socket: print "Socket not defined." self.usage() if not opts.channel: print "Channel not defined." self.usage() self.bot = Kibot(opts.socket) self.channel = opts.channel self.errorEmail = opts.errorEmail return opts, args