some cleanups and bug fixes.
This commit is contained in:
parent
3447dbe03f
commit
7c12fe04e6
6 changed files with 25 additions and 17 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
This is what job_function needs as parameter for each job to successfully
|
This is what job_function needs as parameter for each job to successfully
|
||||||
execute.
|
execute.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@ def generateId():
|
||||||
yield i
|
yield i
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
class Job:
|
class Job:
|
||||||
def __init__(self, service, host):
|
def __init__(self, service, host):
|
||||||
self.service = service
|
self.service = service
|
||||||
|
|
@ -46,18 +48,17 @@ class Job:
|
||||||
jobInfo = JobInfo(self.host, self.service)
|
jobInfo = JobInfo(self.host, self.service)
|
||||||
result = self.service._execute(self.host)
|
result = self.service._execute(self.host)
|
||||||
jobInfo.set_result(result)
|
jobInfo.set_result(result)
|
||||||
jobInfo.set_successfull(self.service.was_execution_successful())
|
jobInfo.set_execution_successful(self.service.was_execution_successful())
|
||||||
jobInfo.set_execution_end()
|
jobInfo.set_execution_end()
|
||||||
|
|
||||||
self.handle_threshold(self.service.get_threshold(), self.service.was_execution_successful())
|
self.handle_threshold(self.service.get_threshold(), self.service.was_execution_successful())
|
||||||
|
|
||||||
|
|
||||||
self.jobInfos.append(jobInfo)
|
self.jobInfos.append(jobInfo)
|
||||||
|
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log.d(e)
|
self.log.d(e)
|
||||||
|
|
||||||
|
|
||||||
class JobInfo:
|
class JobInfo:
|
||||||
def __init__(self, host, service):
|
def __init__(self, host, service):
|
||||||
self.id = generateId()
|
self.id = generateId()
|
||||||
|
|
@ -72,6 +73,4 @@ class JobInfo:
|
||||||
self.executionEnd = datetime.now()
|
self.executionEnd = datetime.now()
|
||||||
|
|
||||||
def set_execution_successful(self, successful):
|
def set_execution_successful(self, successful):
|
||||||
self.executionSuccess = successful
|
self.executionSuccess = successful
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
'''
|
"""
|
||||||
Just the frontends.py stub... ;)
|
Just the frontends.py stub... ;)
|
||||||
|
|
||||||
If linspector is being started without a frontend "enabled" it just is doing stuff like: polling, alerting, logging etc.
|
If linspector is being started without a frontend "enabled" it just is doing stuff like: polling, alerting, logging etc.
|
||||||
|
|
||||||
Frontends a absolutely no requirement for running Linspector.
|
Frontends a absolutely no requirement for running Linspector.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Frontends():
|
class Frontend():
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
'''
|
"""
|
||||||
A HTTPS frontend to the current Linspector instance.
|
A HTTPS frontend to the current Linspector instance.
|
||||||
|
|
||||||
A Webserver listening for requests to give information about the internal state of linspector.
|
A Webserver listening for requests to give information about the internal state of linspector.
|
||||||
(maybe providing a JSON API to the instance too...)
|
(maybe providing a JSON API to the instance too...)
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
from lib.frontends.frontend import Frontend
|
||||||
|
|
||||||
|
|
||||||
|
class HttpsFrontend(Frontend):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
return
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
'''
|
"""
|
||||||
The Linspector Interactive Shell...
|
The Linspector Interactive Shell...
|
||||||
|
|
||||||
This will become an interface to Linspector at "start" time. Think about MidnightCommander... and then run
|
This will become an interface to Linspector at "start" time. Think about MidnightCommander... and then run
|
||||||
Linspector in a screen session and not as daemon, why not? BTW.: Daemonization is at this point of development
|
Linspector in a screen session and not as daemon, why not? BTW.: Daemonization is at this point of development
|
||||||
cancelled, because it makes no sense to daemonize everything. Linspector is a user software which will run in any
|
cancelled, because it makes no sense to daemonize everything. Linspector is a user software which will run in any
|
||||||
screen session perfectly.
|
screen session perfectly.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
class LishFrontend(Frontends):
|
from lib.frontends.frontend import Frontend
|
||||||
|
|
||||||
|
|
||||||
|
class LishFrontend(Frontend):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
@ -27,12 +27,11 @@ class TcpconnectService(Service):
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
except socket.error, msg:
|
except socket.error, msg:
|
||||||
|
|
||||||
#log.w("%s\n" % msg[1])
|
#log.w("%s\n" % msg[1])
|
||||||
self.errorcode = 1
|
self.errorcode = 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sock.connect((self.host, self.port))
|
sock.connect((host, self.port))
|
||||||
except socket.error, msg:
|
except socket.error, msg:
|
||||||
#log.w("%s\n" % msg[1])
|
#log.w("%s\n" % msg[1])
|
||||||
self.errorcode = 2
|
self.errorcode = 2
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
{
|
{
|
||||||
"class": "tcpconnect",
|
"class": "tcpconnect",
|
||||||
"args": {"port": 23232},
|
"args": {"port": 23232},
|
||||||
"periods": ["moes_time", "marges_birthday"],
|
"periods": ["doh"],
|
||||||
"fails": {"donut": 0},
|
"fails": {"donut": 0},
|
||||||
"threshold": 0,
|
"threshold": 0,
|
||||||
"comment": "my personal reminder, hehe"
|
"comment": "my personal reminder, hehe"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue