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.linspector import Linspector
|
||||||
from linspector.monitors import Monitors
|
from linspector.monitors import Monitors
|
||||||
|
|
||||||
__version__ = '0.25.0'
|
__version__ = '0.25.1'
|
||||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class MySQLDatabase(Database):
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.warning('database configuration error: {0}'.format(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:
|
try:
|
||||||
self._connection = pymysql.connect(cursorclass=pymysql.cursors.DictCursor,
|
self._connection = pymysql.connect(cursorclass=pymysql.cursors.DictCursor,
|
||||||
database=self._database,
|
database=self._database,
|
||||||
|
|
@ -62,16 +62,20 @@ class MySQLDatabase(Database):
|
||||||
with (self._connection):
|
with (self._connection):
|
||||||
with self._connection.cursor() as cursor:
|
with self._connection.cursor() as cursor:
|
||||||
sql = 'INSERT INTO ' + self._table + ' (' \
|
sql = 'INSERT INTO ' + self._table + ' (' \
|
||||||
|
'host, ' \
|
||||||
'identifier, ' \
|
'identifier, ' \
|
||||||
'json, ' \
|
'json, ' \
|
||||||
'message, ' \
|
'message, ' \
|
||||||
|
'service, ' \
|
||||||
'status, ' \
|
'status, ' \
|
||||||
'timestamp ' \
|
'timestamp ' \
|
||||||
') VALUES (\"' + \
|
') VALUES (\"' + \
|
||||||
str(identifier) + '\",\"' + \
|
str((host if host else "None")) + '\",\"' + \
|
||||||
str(json) + '\",\"' + \
|
str((identifier if identifier else "None")) + '\",\"' + \
|
||||||
str(message) + '\",\"' + \
|
str((json if json else "None")) + '\",\"' + \
|
||||||
str(status) + '\",\"' + \
|
str((message if message else "None")) + '\",\"' + \
|
||||||
|
str((service if service else "None")) + '\",\"' + \
|
||||||
|
str((status if status else "None")) + '\",\"' + \
|
||||||
str(timestamp) + '\")'
|
str(timestamp) + '\")'
|
||||||
self._log.debug(sql)
|
self._log.debug(sql)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
|
||||||
|
|
@ -125,9 +125,11 @@ class Monitor:
|
||||||
|
|
||||||
self._log.debug(self._databases)
|
self._log.debug(self._databases)
|
||||||
for database in 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,
|
||||||
self._result['message'],
|
self._result['message'],
|
||||||
|
self._result['service'],
|
||||||
self._result['status'],
|
self._result['status'],
|
||||||
int(time.time()))
|
int(time.time()))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,11 @@ class IsConnectedService(Service):
|
||||||
' service=' + service +
|
' service=' + service +
|
||||||
' status=' + ('OK' if fc.is_connected else 'ERROR'))
|
' 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() + " " +
|
"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
|
return result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue