Added more fields to MySQL module. (0.25.1)
This commit is contained in:
parent
c429619040
commit
802ad69781
4 changed files with 18 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ from linspector.environment import Environment
|
|||
from linspector.linspector import Linspector
|
||||
from linspector.monitors import Monitors
|
||||
|
||||
__version__ = '0.25.0'
|
||||
__version__ = '0.25.1'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class MySQLDatabase(Database):
|
|||
except Exception as err:
|
||||
log.warning('database configuration error: {0}'.format(err))
|
||||
|
||||
def insert(self, identifier, json, message, status, timestamp):
|
||||
def insert(self, host, identifier, json, message, service, status, timestamp):
|
||||
try:
|
||||
self._connection = pymysql.connect(cursorclass=pymysql.cursors.DictCursor,
|
||||
database=self._database,
|
||||
|
|
@ -62,16 +62,20 @@ class MySQLDatabase(Database):
|
|||
with (self._connection):
|
||||
with self._connection.cursor() as cursor:
|
||||
sql = 'INSERT INTO ' + self._table + ' (' \
|
||||
'host, ' \
|
||||
'identifier, ' \
|
||||
'json, ' \
|
||||
'message, ' \
|
||||
'service, ' \
|
||||
'status, ' \
|
||||
'timestamp ' \
|
||||
') VALUES (\"' + \
|
||||
str(identifier) + '\",\"' + \
|
||||
str(json) + '\",\"' + \
|
||||
str(message) + '\",\"' + \
|
||||
str(status) + '\",\"' + \
|
||||
str((host if host else "None")) + '\",\"' + \
|
||||
str((identifier if identifier else "None")) + '\",\"' + \
|
||||
str((json if json else "None")) + '\",\"' + \
|
||||
str((message if message else "None")) + '\",\"' + \
|
||||
str((service if service else "None")) + '\",\"' + \
|
||||
str((status if status else "None")) + '\",\"' + \
|
||||
str(timestamp) + '\")'
|
||||
self._log.debug(sql)
|
||||
cursor.execute(sql)
|
||||
|
|
|
|||
|
|
@ -125,9 +125,11 @@ class Monitor:
|
|||
|
||||
self._log.debug(self._databases)
|
||||
for database in self._databases:
|
||||
self._databases[database].insert(self._identifier,
|
||||
self._databases[database].insert(self._result['host'],
|
||||
self._identifier,
|
||||
self._result,
|
||||
self._result['message'],
|
||||
self._result['service'],
|
||||
self._result['status'],
|
||||
int(time.time()))
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,11 @@ class IsConnectedService(Service):
|
|||
' service=' + service +
|
||||
' status=' + ('OK' if fc.is_connected else 'ERROR'))
|
||||
|
||||
result = {"status": ('OK' if fc.is_connected else 'ERROR'),
|
||||
result = {"host": monitor.get_host(),
|
||||
|
||||
"message": "Uplink on host " + monitor.get_host() + " " +
|
||||
('UP' if fc.is_connected else 'DOWN')}
|
||||
('UP' if fc.is_connected else 'DOWN'),
|
||||
"service": service,
|
||||
"status": ('OK' if fc.is_connected else 'ERROR')}
|
||||
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue