renamed xmpp task to jabber to avoid conflicts; added simple xmpp/jabber support to tasks
This commit is contained in:
parent
bccb205f6d
commit
1e8ad1f110
5 changed files with 41 additions and 27 deletions
|
|
@ -3,8 +3,7 @@
|
||||||
"hanez":{
|
"hanez":{
|
||||||
"name": "Johannes Findeisen",
|
"name": "Johannes Findeisen",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{ "class":"mail", "type": "mail", "args": { "rcpt": "you@hanez.org" }},
|
{ "class":"jabber", "type": "jabber", "args": { "rcpt": "hanez@systemchaos.org" }}
|
||||||
{ "class":"mail", "type": "mail", "args": { "rcpt": "johannes.findeisen@com.puting.de" }}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -20,7 +19,7 @@
|
||||||
"class": "tcpconnect",
|
"class": "tcpconnect",
|
||||||
"args": { "port": 80 },
|
"args": { "port": 80 },
|
||||||
"periods": ["always"],
|
"periods": ["always"],
|
||||||
"threshold": 1
|
"threshold": 10
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -30,5 +29,11 @@
|
||||||
"hostgroups": ["servers"],
|
"hostgroups": ["servers"],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"core":{
|
||||||
|
"max_logfile_size": 1024000,
|
||||||
|
"max_logfile_count": 4,
|
||||||
|
"max_worker_threads": 8,
|
||||||
|
"members":[ "root" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"comment": "The Linspector Admin",
|
"comment": "The Linspector Admin",
|
||||||
"tasks":[{ "class": "mail", "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": "sms", "type": "critical", "args":{ "rcpt": "+49112" }},
|
||||||
{ "class": "xmpp", "type": "critical", "args":{ "rcpt": "admin@jabber.hanez.org" }}]
|
{ "class": "jabber", "type": "critical", "args":{ "rcpt": "admin@jabber.hanez.org" }}]
|
||||||
},
|
},
|
||||||
"hanez":{
|
"hanez":{
|
||||||
"name": "Johannes Findeisen",
|
"name": "Johannes Findeisen",
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class Job:
|
||||||
for member in self.service.get_hostgroup().get_members():
|
for member in self.service.get_hostgroup().get_members():
|
||||||
for task in member.get_tasks():
|
for task in member.get_tasks():
|
||||||
print(task)
|
print(task)
|
||||||
task.execute("Task executed!")
|
task.execute("Task executed for host: " + self.host)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_call(self):
|
def handle_call(self):
|
||||||
|
|
|
||||||
31
lib/tasks/jabber.py
Normal file
31
lib/tasks/jabber.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
"""
|
||||||
|
The Jabber task.
|
||||||
|
|
||||||
|
Uses: http://xmpppy.sourceforge.net/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import xmpp
|
||||||
|
from lib.tasks.task import Task
|
||||||
|
|
||||||
|
|
||||||
|
class JabberTask(Task):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
if not "type" in kwargs:
|
||||||
|
raise Exception("'type' not in typeDict " + str(kwargs))
|
||||||
|
if not "args" in kwargs:
|
||||||
|
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
|
||||||
|
self.set_task_type(kwargs["type"])
|
||||||
|
self.recipient = kwargs["args"]["rcpt"]
|
||||||
|
|
||||||
|
def execute(self, msg):
|
||||||
|
client = xmpp.Client('systemchaos.org')
|
||||||
|
client.connect(server=('systemchaos.org', 5222))
|
||||||
|
client.auth('linspector', 'PASSWORD', 'alert')
|
||||||
|
client.sendInitPresence()
|
||||||
|
message = xmpp.Message('hanez@systemchaos.org', msg)
|
||||||
|
message.setAttr('type', 'chat')
|
||||||
|
client.send(message)
|
||||||
|
|
||||||
|
|
||||||
|
def create(taskDict):
|
||||||
|
return JabberTask(**taskDict)
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
"""
|
|
||||||
The xmpp task.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from lib.tasks.task import Task
|
|
||||||
|
|
||||||
|
|
||||||
class XmppTask(Task):
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
if not "type" in kwargs:
|
|
||||||
raise Exception("'type' not in typeDict " + str(kwargs))
|
|
||||||
if not "args" in kwargs:
|
|
||||||
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
|
|
||||||
self.set_task_type(kwargs["type"])
|
|
||||||
self.recipient = kwargs["args"]["rcpt"]
|
|
||||||
|
|
||||||
def execute_task(self, msg):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def create(taskDict):
|
|
||||||
return XmppTask(**taskDict)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue