Cleanup monitor.py

parent bb51f5da
...@@ -28,15 +28,12 @@ ...@@ -28,15 +28,12 @@
import datetime import datetime
import os import os
import time import time
import resource
from time import strftime from time import strftime
import logging import logging
import sys import sys
from lxml import etree as ElementTree from lxml import etree as ElementTree
import platform
import psutil import psutil
from optparse import OptionParser from optparse import OptionParser
import tempfile
import sqlite3.dbapi2 as sqlite3 import sqlite3.dbapi2 as sqlite3
#define global variable for log file #define global variable for log file
...@@ -59,7 +56,6 @@ class GenerateXML(object): ...@@ -59,7 +56,6 @@ class GenerateXML(object):
self.element_tree = element_tree self.element_tree = element_tree
self.path_database = path_database self.path_database = path_database
self.path_xml = path_xml self.path_xml = path_xml
#self.log_file = log_file
def dump_xml(self): def dump_xml(self):
"""This func read data from database and through """This func read data from database and through
...@@ -286,7 +282,7 @@ class SlapReport(object): ...@@ -286,7 +282,7 @@ class SlapReport(object):
cursor.execute("UPDATE data set reported='1' WHERE time=?", (row[5],)) cursor.execute("UPDATE data set reported='1' WHERE time=?", (row[5],))
conn.commit() conn.commit()
except Exception, e: except Exception:
if log_file: if log_file:
logging.info("ERROR : Unable to connect to % at %s" logging.info("ERROR : Unable to connect to % at %s"
% (self.ssh_parameters['ip'], strftime("%Y-%m-%d at %H:%m"))) % (self.ssh_parameters['ip'], strftime("%Y-%m-%d at %H:%m")))
...@@ -383,7 +379,7 @@ def run_slapreport(): ...@@ -383,7 +379,7 @@ def run_slapreport():
except IOError: except IOError:
if log_file: if log_file:
logging.info("ERROR : process with pid : %s watched by slap monitor exited too quickly at %s" logging.info("ERROR : process with pid : %s watched by slap monitor exited too quickly at %s"
% (self.proc.pid, strftime("%Y-%m-%d at %H:%m"))) % (proc.pid, strftime("%Y-%m-%d at %H:%m")))
sys.exit(1) sys.exit(1)
if log_file: if log_file:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment