diff --git a/examples/hanez.json b/examples/hanez.json index 04ea252..b87f047 100644 --- a/examples/hanez.json +++ b/examples/hanez.json @@ -3,8 +3,7 @@ "hanez":{ "name": "Johannes Findeisen", "tasks": [ - { "class":"mail", "type": "mail", "args": { "rcpt": "you@hanez.org" }}, - { "class":"mail", "type": "mail", "args": { "rcpt": "johannes.findeisen@com.puting.de" }} + { "class":"jabber", "type": "jabber", "args": { "rcpt": "hanez@systemchaos.org" }} ] } }, @@ -20,7 +19,7 @@ "class": "tcpconnect", "args": { "port": 80 }, "periods": ["always"], - "threshold": 1 + "threshold": 10 } ] } @@ -30,5 +29,11 @@ "hostgroups": ["servers"], "enabled": true } + }, + "core":{ + "max_logfile_size": 1024000, + "max_logfile_count": 4, + "max_worker_threads": 8, + "members":[ "root" ] } } \ No newline at end of file diff --git a/examples/linspector.json b/examples/linspector.json index a195480..b12465f 100644 --- a/examples/linspector.json +++ b/examples/linspector.json @@ -5,7 +5,7 @@ "comment": "The Linspector Admin", "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" }}] + { "class": "jabber", "type": "critical", "args":{ "rcpt": "admin@jabber.hanez.org" }}] }, "hanez":{ "name": "Johannes Findeisen", diff --git a/lib/core/job.py b/lib/core/job.py index ec1286f..8237e1a 100644 --- a/lib/core/job.py +++ b/lib/core/job.py @@ -46,7 +46,7 @@ class Job: for member in self.service.get_hostgroup().get_members(): for task in member.get_tasks(): print(task) - task.execute("Task executed!") + task.execute("Task executed for host: " + self.host) pass def handle_call(self): diff --git a/lib/tasks/jabber.py b/lib/tasks/jabber.py new file mode 100644 index 0000000..8c84720 --- /dev/null +++ b/lib/tasks/jabber.py @@ -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) \ No newline at end of file diff --git a/lib/tasks/xmpp.py b/lib/tasks/xmpp.py deleted file mode 100644 index 91073ad..0000000 --- a/lib/tasks/xmpp.py +++ /dev/null @@ -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) \ No newline at end of file