Commit 9a68ca09 authored by Rafael Monnerat's avatar Rafael Monnerat

monitor: Dump into csv is not required anymore.

  This feature became useless as fluentd isn't a priority anymore
parent 78bce37f
......@@ -15,11 +15,11 @@
[template]
filename = instance.cfg
md5sum = 677f827c03309bdcecbc3c6405bd760c
md5sum = a5af462b547ce228d5a3fc0db76c2622
[template-monitor]
filename = instance-monitor.cfg.jinja2
md5sum = 920a3451b946365536650dd67a50f847
md5sum = 26da87508315194930984180cc6cc3f8
[template-monitor-edgetest]
filename = instance-monitor-edgetest.cfg.jinja2
......@@ -37,6 +37,3 @@ md5sum = 2eb5596544d9c341acf653d4f7ce2680
filename = network_bench.cfg.in
md5sum = cfcbf2002b8eff5153e2bf68ed24b720
[monitor-collect-csv-dump]
filename = script/collect_csv_dump.py
md5sum = cad2402bbd21907cfed6bc5af8c5d3ab
......@@ -6,7 +6,6 @@ parts =
symlink-re6st-logs
symlink-collected-logs
python-symlink
monitor-collect-csv-wrapper
monitor-base
monitor-check-memory-usage
monitor-check-cpu-usage
......@@ -53,12 +52,6 @@ recipe = plone.recipe.command
command = ln -sf {{ buildout_bin }}/pythonwitheggs ${monitor-directory:bin}/python
update-command = ${:command}
[monitor-collect-csv-wrapper]
recipe = slapos.cookbook:wrapper
command-line =
${monitor-directory:bin}/python {{ monitor_collect_csv_dump }} --output_folder ${monitor-directory:consumption}
wrapper-path = ${monitor-directory:bin}/monitor-collect-csv-dump
[monitor-check-memory-usage]
recipe = slapos.cookbook:wrapper
command-line = {{ buildout_bin}}/check-computer-memory
......
......@@ -21,7 +21,6 @@ context = key develop_eggs_directory buildout:develop-eggs-directory
key slapparameter_dict slap-configuration:configuration
raw buildout_bin ${buildout:bin-directory}
raw monitor_template_output ${monitor-template:output}
raw monitor_collect_csv_dump ${monitor-collect-csv-dump:output}
mode = 0644
[instance-base-edgetest]
......@@ -51,7 +50,6 @@ context = import json_module json
key slapparameter_dict slap-configuration:configuration
raw buildout_bin ${buildout:bin-directory}
raw monitor_template_output ${monitor-template:output}
raw monitor_collect_csv_dump ${monitor-collect-csv-dump:output}
mode = 0644
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010-2016 Vifib SARL and Contributors.
# All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
import argparse
import csv
from slapos.util import mkdir_p
from slapos.collect.db import Database
def skip_bootstrap(self):
return
Database._bootstrap = skip_bootstrap
def parseArguments():
"""
Parse arguments for monitor collector instance.
"""
parser = argparse.ArgumentParser()
parser.add_argument('--output_folder',
help='Path of the folder where output files should be written.')
parser.add_argument('--collector_db',
default='/srv/slapgrid/var/data-log/',
help='The path of slapos collect database is located.')
return parser.parse_args()
def writeFile(name, folder, date_scope, rows):
if os.path.exists(
os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name))):
# File already exists, no reason to recreate it.
return
mkdir_p(os.path.join(folder, date_scope), 0o755)
file_io = open(os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name)), "w")
csv_output = csv.writer(file_io)
csv_output.writerows(rows)
file_io.close()
def dump_table_into_csv(db, folder):
db.connect()
table_list = db.getTableList()
# Save all dates first, as db.selector may switch the cursor
date_list = [(date_scope, _) \
for date_scope, _ in db.getDateScopeList(reported=1)]
for date_scope, amount in date_list:
for table in table_list:
if os.path.exists(
os.path.join(folder, "%s/dump_%s.csv" % (date_scope, table))):
# File already exists, no reason to recreate it.
continue
writeFile(table, folder, date_scope,
db.select(table, date_scope))
db.close()
if __name__ == "__main__":
parser = parseArguments()
if parser.output_folder is None:
raise Exception("Invalid ouput folder: %s" % parser.output_folder)
if parser.collector_db is None:
raise Exception("Invalid collector database folder: %s" % parser.collector_db)
if not os.path.exists(parser.output_folder) and \
os.path.isdir(parser.output_folder):
raise Exception("Invalid ouput folder: %s" % parser.output_folder)
if not os.path.exists(parser.collector_db):
print "Collector database not found..."
dump_table_into_csv(Database(parser.collector_db), parser.output_folder)
......@@ -6,9 +6,9 @@ extends =
../../component/python-cryptography/buildout.cfg
../../component/wget/buildout.cfg
../../stack/monitor/buildout.cfg
../../stack/slapos.cfg
../../stack/slapos-dev.cfg
parts =
parts +=
wget
slapos-cookbook
network-bench-cfg
......@@ -16,7 +16,6 @@ parts =
template
template-monitor-edgetest
template-monitor
monitor-collect-csv-dump
[template]
recipe = slapos.recipe.template
......@@ -50,12 +49,6 @@ url = ${:_profile_base_location_}/${:filename}
output = ${buildout:parts-directory}/${:_buildout_section_name_}
mode = 0644
[monitor-collect-csv-dump]
<= monitor-template-script
url = ${:_profile_base_location_}/script/${:filename}
filename = collect_csv_dump.py
output = ${:destination}/${:filename}
[extra-eggs]
<= monitor-eggs
interpreter = pythonwitheggs
......@@ -70,8 +63,6 @@ scripts =
networkbench
onetimedownload
monitor.bootstrap
monitor.collect
monitor.runpromise
monitor.genstatus
monitor.configwrite
check-computer-memory
......
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