Commit c370722f authored by Rafael Monnerat's avatar Rafael Monnerat

monitor sr: Drop smartctl implementation at the software release

 smartctl requires root, so it may never work. The appropriated way is run by another mean and only read the reports via Computer Partition
parent c641993c
...@@ -18,7 +18,6 @@ parts = ...@@ -18,7 +18,6 @@ parts =
cgi-httpd-graceful-wrapper cgi-httpd-graceful-wrapper
monitor-promise monitor-promise
monitor-instance-log-access monitor-instance-log-access
cron-smart-monitor-logs
cron-network-bench cron-network-bench
symlink-re6st-logs symlink-re6st-logs
symlink-collected-logs symlink-collected-logs
...@@ -30,13 +29,6 @@ eggs-directory = ${buildout:eggs-directory} ...@@ -30,13 +29,6 @@ eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
[cron-smart-monitor-logs]
<= cron
recipe = slapos.cookbook:cron.d
name = smartctl-mon
frequency = 11 * * * *
command = $${smartmon-logs:rendered}
[cron-network-bench] [cron-network-bench]
<= cron <= cron
recipe = slapos.cookbook:cron.d recipe = slapos.cookbook:cron.d
...@@ -44,7 +36,6 @@ name = network-bench-test ...@@ -44,7 +36,6 @@ name = network-bench-test
frequency = */10 * * * * frequency = */10 * * * *
command = ${buildout:bin-directory}/networkbench $${network-bench-configuration:rendered} $${monitor-directory:monitor-log} command = ${buildout:bin-directory}/networkbench $${network-bench-configuration:rendered} $${monitor-directory:monitor-log}
[symlink-re6st-logs] [symlink-re6st-logs]
recipe = cns.recipe.symlink recipe = cns.recipe.symlink
symlink = /var/log/re6stnet = $${monitor-directory:system-log}/re6stnet symlink = /var/log/re6stnet = $${monitor-directory:system-log}/re6stnet
...@@ -55,17 +46,6 @@ recipe = cns.recipe.symlink ...@@ -55,17 +46,6 @@ recipe = cns.recipe.symlink
symlink = /srv/slapgrid/var/data-log = $${monitor-directory:server-log}/data-log symlink = /srv/slapgrid/var/data-log = $${monitor-directory:server-log}/data-log
autocreate = true autocreate = true
[smartmon-logs]
recipe = slapos.recipe.template:jinja2
template = ${smartmon-logs-script:output}
rendered = $${monitor-directory:bin}/smartmon-logs.py
mode = 0744
context =
key buildout_directory buildout:directory
raw smartctl_binary ${smartmontools:location}/sbin/smartctl
key monitor_log_directory monitor-directory:monitor-log
raw python_executable ${buildout:executable}
[network-bench-configuration] [network-bench-configuration]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = ${network-bench-cfg:output} template = ${network-bench-cfg:output}
......
#!{{ python_executable }}
SMARCTBIN={{ smartctl_binary }}
LOGFOLDER={{ monitor_log_directory }}
import subprocess
import logging
import os
logger = logging.getLogger("SMARTMON")
logger.setLevel(logging.DEBUG)
ch = logging.FileHandler(os.path.join(LOGFOLDER, "smartmontools.log"))
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
def _call(cmd):
p = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
shell=True)
return p.communicate()
def get_disk_list():
output, err = _call("%s --scan" % SMARCTBIN)
disk_list = []
for line in output.split("\n"):
if line != '':
disk_path = line.split(" ")[0]
if disk_path.startswith("/dev/"):
disk_list.append(disk_path)
return disk_list
logger.debug("Starting new Data collection.")
disk_list = get_disk_list()
logger.debug("Identified disks: %s" % disk_list)
for disk in disk_list:
logger.info("Starting test for %s" % disk)
output, err = _call("%s --all %s" % (SMARCTBIN, disk))
for l in output.split("\n"):
logger.info("%s - %s" % (disk, l))
if err is not None:
logger.warning(err)
logger.debug("Stopped to Collect Data.")
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
extends = extends =
../../component/pycurl/buildout.cfg ../../component/pycurl/buildout.cfg
../../stack/monitor/buildout.cfg ../../stack/monitor/buildout.cfg
../../stack/slapos.cfg
../../component/smartmontools/buildout.cfg
../../component/lmsensors/buildout.cfg
../../component/fluentd/buildout.cfg ../../component/fluentd/buildout.cfg
../../stack/slapos.cfg
parts = parts =
slapos-cookbook slapos-cookbook
...@@ -15,9 +13,7 @@ parts = ...@@ -15,9 +13,7 @@ parts =
network-bench-cfg network-bench-cfg
template-monitor template-monitor
eggs eggs
smartmontools fluentd
lmsensors
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
...@@ -30,7 +26,7 @@ mode = 0644 ...@@ -30,7 +26,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-monitor.cfg.jinja2 url = ${:_profile_base_location_}/instance-monitor.cfg.jinja2
output = ${buildout:directory}/template-monitor.cfg output = ${buildout:directory}/template-monitor.cfg
md5sum = b5ef3caea873f5ca202792220263aef2 md5sum = bf6bb18ed86fcb450e5e23d7815a208f
mode = 0644 mode = 0644
# stupify index for now # stupify index for now
...@@ -42,13 +38,6 @@ md5sum = 876f18b159fbd9325332d0f42e9172ac ...@@ -42,13 +38,6 @@ md5sum = 876f18b159fbd9325332d0f42e9172ac
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
md5sum = 1f30b17f5ea11fd033984d17c38bcfd3 md5sum = 1f30b17f5ea11fd033984d17c38bcfd3
[smartmon-logs-script]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/smartmon.py.in
md5sum = a3ea2604abf53067af1b952b278fba94
output = ${buildout:directory}/template-smartmon-logs.py.in
mode = 0644
[network-bench-cfg] [network-bench-cfg]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/network_bench.cfg.in url = ${:_profile_base_location_}/network_bench.cfg.in
......
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