Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nirina Malard
slapos
Commits
cd1c0816
Commit
cd1c0816
authored
Dec 11, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: more code simplification
parent
14001ab2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
21 deletions
+11
-21
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+1
-1
stack/monitor/monitor.py.in
stack/monitor/monitor.py.in
+10
-20
No files found.
stack/monitor/buildout.cfg
View file @
cd1c0816
...
@@ -48,7 +48,7 @@ mode = 0644
...
@@ -48,7 +48,7 @@ mode = 0644
recipe = hexagonit.recipe.download
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename}
url = ${:_profile_base_location_}/${:filename}
download-only = true
download-only = true
md5sum =
49587347fd82d93cca27715f787f8bec
md5sum =
5b12e864f1762d7984f7d4863d0b795d
destination = ${buildout:parts-directory}/monitor-template-monitor-bin
destination = ${buildout:parts-directory}/monitor-template-monitor-bin
filename = monitor.py.in
filename = monitor.py.in
mode = 0644
mode = 0644
...
...
stack/monitor/monitor.py.in
View file @
cd1c0816
#!{{ python_executable }}
#!{{ python_executable }}
import datetime
import json
import json
import os
import os
import subprocess
import subprocess
...
@@ -60,10 +59,8 @@ class Popen(subprocess.Popen):
...
@@ -60,10 +59,8 @@ class Popen(subprocess.Popen):
return event.__killed
return event.__killed
return killed
return killed
def init_db():
def init_db(db):
db = sqlite3.connect(db_path)
db.executescript("""
c = db.cursor()
c.executescript("""
CREATE TABLE IF NOT EXISTS status (
CREATE TABLE IF NOT EXISTS status (
timestamp INTEGER UNIQUE,
timestamp INTEGER UNIQUE,
status VARCHAR(255));
status VARCHAR(255));
...
@@ -73,8 +70,6 @@ CREATE TABLE IF NOT EXISTS individual_status (
...
@@ -73,8 +70,6 @@ CREATE TABLE IF NOT EXISTS individual_status (
element VARCHAR(255),
element VARCHAR(255),
output TEXT);
output TEXT);
""")
""")
db.commit()
db.close()
def getListOfScripts(directory):
def getListOfScripts(directory):
"""
"""
...
@@ -136,25 +131,20 @@ def runScripts(directory):
...
@@ -136,25 +131,20 @@ def runScripts(directory):
def writeFiles(monitors):
def writeFiles(monitors):
timestamp = int(time.time())
timestamp = int(time.time())
date = datetime.datetime.now().ctime()
init_db()
db = sqlite3.connect(db_path)
db = sqlite3.connect(db_path)
fail = False
init_db(db)
status = SUCCESS
for key, value in monitors.iteritems():
for key, value in monitors.iteritems():
if value:
element_status = status = FAILURE
else:
element_status = SUCCESS
element_status = SUCCESS
if value != "" :
fail = True
element_status = FAILURE
db.execute("insert into individual_status(timestamp, element, output, status) values (?, ?, ?, ?)", (timestamp, key, value, element_status))
db.execute("insert into individual_status(timestamp, element, output, status) values (?, ?, ?, ?)", (timestamp, key, value, element_status))
db.commit()
status = SUCCESS
if fail:
status = FAILURE
db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status))
db.execute("insert into status(timestamp, status) values (?, ?)", (timestamp, status))
db.commit()
db.commit()
db.close()
db.close()
monitors['datetime'] =
date
monitors['datetime'] =
time.ctime(timestamp)
open(monitoring_file_json, "w+").write(json.dumps(monitors
))
json.dump(monitors, open(monitoring_file_json, "w+"
))
def main():
def main():
parser = OptionParser(option_list=option_list)
parser = OptionParser(option_list=option_list)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment