renamed email task to mail because of some name collision in smtplib
This commit is contained in:
parent
15a6470cbb
commit
bccb205f6d
6 changed files with 19 additions and 18 deletions
|
|
@ -3,7 +3,8 @@
|
|||
"hanez":{
|
||||
"name": "Johannes Findeisen",
|
||||
"tasks": [
|
||||
{ "class":"email", "type": "email", "args": { "rcpt": "you@hanez.org" }}
|
||||
{ "class":"mail", "type": "mail", "args": { "rcpt": "you@hanez.org" }},
|
||||
{ "class":"mail", "type": "mail", "args": { "rcpt": "johannes.findeisen@com.puting.de" }}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
@ -19,7 +20,7 @@
|
|||
"class": "tcpconnect",
|
||||
"args": { "port": 80 },
|
||||
"periods": ["always"],
|
||||
"threshold": 5
|
||||
"threshold": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"root":{
|
||||
"name": "Admin",
|
||||
"comment": "The Linspector Admin",
|
||||
"tasks":[{ "class": "email", "type": "warning", "args":{ "rcpt": "admin@systems.hanez.org" }},
|
||||
"tasks":[{ "class": "mail", "type": "warning", "args":{ "rcpt": "admin@systems.hanez.org" }},
|
||||
{ "class": "sms", "type": "critical", "args":{ "rcpt": "+49112" }},
|
||||
{ "class": "xmpp", "type": "critical", "args":{ "rcpt": "admin@jabber.hanez.org" }}]
|
||||
},
|
||||
|
|
@ -11,13 +11,13 @@
|
|||
"name": "Johannes Findeisen",
|
||||
"comment": "Just a nerd doing admin stuff.",
|
||||
"parent": "darth",
|
||||
"tasks":[{ "class": "email", "type": "warning", "args":{ "rcpt": "you@hanez.org" }},
|
||||
"tasks":[{ "class": "mail", "type": "warning", "args":{ "rcpt": "you@hanez.org" }},
|
||||
{ "class": "sms", "type": "critical", "args":{ "rcpt": "+49110" }}]
|
||||
},
|
||||
"darth":{
|
||||
"name": "Darth Vader",
|
||||
"comment": "The father",
|
||||
"tasks":{ "class": "email", "type": "warning", "args":{ "rcpt": "darth.vader@hanez.org" }}
|
||||
"tasks":{ "class": "mail", "type": "warning", "args":{ "rcpt": "darth.vader@hanez.org" }}
|
||||
}
|
||||
},
|
||||
"periods":{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
"name": "Homer Simpson",
|
||||
"comment": "Security Inspector",
|
||||
"tasks": [
|
||||
{"class":"email", "type": "donut", "args": {"rcpt": "homer_j_simpson@burnscorp.sp"}},
|
||||
{"class":"email", "type": "donut", "args": {"rcpt": "homer_j_simpson@burnscorp.sp"}}
|
||||
{"class":"mail", "type": "donut", "args": {"rcpt": "homer_j_simpson@burnscorp.sp"}},
|
||||
{"class":"mail", "type": "donut", "args": {"rcpt": "homer_j_simpson@burnscorp.sp"}}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ class Job:
|
|||
self.handle_alarm(self.jobThreshold - serviceThreshold)
|
||||
|
||||
def handle_alarm(self, thresholdOffset):
|
||||
for member in self.service.get_hostgroup().get_members():
|
||||
for task in member.get_tasks():
|
||||
print(task)
|
||||
task.execute("Task executed!")
|
||||
pass
|
||||
|
||||
def handle_call(self):
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ The email task.
|
|||
http://docs.python.org/2/library/email-examples.html
|
||||
"""
|
||||
|
||||
#import smtplib
|
||||
#from email.mime.text import MIMEText
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from lib.tasks.task import Task
|
||||
|
||||
|
||||
class EmailTask(Task):
|
||||
class MailTask(Task):
|
||||
def __init__(self, **kwargs):
|
||||
if not "type" in kwargs:
|
||||
raise Exception("'type' not in typeDict " + str(kwargs))
|
||||
|
|
@ -19,7 +19,6 @@ class EmailTask(Task):
|
|||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
def execute(self, msg):
|
||||
'''
|
||||
message = MIMEText(msg)
|
||||
message['Subject'] = 'Warning from Linspector'
|
||||
message['From'] = "warning@linspector.org"
|
||||
|
|
@ -27,13 +26,7 @@ class EmailTask(Task):
|
|||
s = smtplib.SMTP('localhost')
|
||||
s.sendmail("warning@linspector.org", self.recipient, message.as_string())
|
||||
s.quit()
|
||||
'''
|
||||
|
||||
print("Task executed")
|
||||
print(msg)
|
||||
print(self.recipient)
|
||||
pass
|
||||
|
||||
|
||||
def create(taskDict):
|
||||
return EmailTask(**taskDict)
|
||||
return MailTask(**taskDict)
|
||||
|
|
@ -19,3 +19,6 @@ class Task:
|
|||
|
||||
def some_other_irrelevant_methods(self):
|
||||
pass
|
||||
|
||||
def execute(self, msg):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue