summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Yu <Gabriel.yuyang@huawei.com>2018-05-02 12:14:49 +0800
committerYang Yu <Gabriel.yuyang@huawei.com>2018-05-02 15:07:48 +0800
commit742fc9ab94ede1187c9146e5336e28fe84d510c5 (patch)
treee63f6b7eba22a907197341bc03efd9fdebc19a40
parent2833e627cbf31eb89f313ec167f215c48fa70217 (diff)
Style-check for monitoring scripts
Fix the style-check errors for monitoring scripts. In another patch, the scripts will be restructured according the dicretory structure. Change-Id: I4149b18177fa1bdeb1b12a84ecad3d7d0b78260b Signed-off-by: Yang Yu <Gabriel.yuyang@huawei.com>
-rw-r--r--monitor/automate_cadvisor_client.py26
-rw-r--r--monitor/automate_collectd_client.py33
-rw-r--r--monitor/automated_dashboard_datasource.py (renamed from monitor/automated-dashboard-datasource.py)4
-rw-r--r--monitor/barometer_automated_client_install.py31
-rw-r--r--monitor/barometer_collectd.conf (renamed from monitor/barometer-collectd.conf)0
-rw-r--r--monitor/barometer_install_client.sh4
-rw-r--r--monitor/barometer_install_script.sh (renamed from monitor/barometer-install-script.sh)4
-rw-r--r--monitor/client_ip_configure.py10
-rw-r--r--monitor/custom_dashboard.py (renamed from monitor/custom-dashboard.py)10
-rw-r--r--monitor/custom_query_dashboard.json (renamed from monitor/custom-query-dashboard.json)0
-rw-r--r--monitor/grafana/dashboards/prometheus_system_rev1.json (renamed from monitor/grafana/dashboards/prometheus-system_rev1.json)0
-rw-r--r--monitor/install_collectd_client.sh (renamed from monitor/install-collectd-client.sh)2
-rw-r--r--monitor/monitoring.sh6
-rw-r--r--monitor/server_ip_configure.py10
14 files changed, 79 insertions, 61 deletions
diff --git a/monitor/automate_cadvisor_client.py b/monitor/automate_cadvisor_client.py
index 95b98e9..f84892d 100644
--- a/monitor/automate_cadvisor_client.py
+++ b/monitor/automate_cadvisor_client.py
@@ -8,30 +8,34 @@
##############################################################################
import logging
-import sys
import yaml
-sys.path.insert(0, '/home/opnfv/bottlenecks/utils/infra_setup/passwordless_SSH/')
-import ssh
+import utils.infra_setup.passwordless_SSH.ssh as ssh
logger = logging.getLogger(__name__)
+cadvisor_install_sh = "/home/opnfv/bottlenecks/monitor/cadvisor_install.sh"
+
with open('/tmp/pod.yaml') as f:
dataMap = yaml.safe_load(f)
for x in dataMap:
for y in dataMap[x]:
- if (y['role']=='Controller') or (y['role']=='Compute'):
+ if (y['role'] == 'Controller') or (y['role'] == 'Compute'):
ip = str(y['ip'])
user = str(y['user'])
pwd = str(y['password'])
- ssh_d = ssh.SSH(user, host= ip, password= pwd)
- status, stdout, stderr = ssh_d.execute("cd /etc && mkdir cadvisor-config")
+ ssh_d = ssh.SSH(user, host=ip, password=pwd)
+ status, stdout, stderr = ssh_d.execute(
+ "cd /etc && mkdir cadvisor_config"
+ )
if status:
raise Exception("Command failed with non-zero status.")
logger.info(stdout.splitlines())
- with open("/home/opnfv/bottlenecks/monitor/cadvisor_install.sh") as stdin_file:
- ssh_d.run("cat > /etc/cadvisor-config/install.sh", stdin=stdin_file)
- status, stdout, stderr = ssh_d.execute("sudo apt-get install docker.io")
+ with open(cadvisor_install_sh) as stdin_file:
+ ssh_d.run("cat > /etc/cadvisor_config/install.sh",
+ stdin=stdin_file)
+ status, stdout, stderr = ssh_d.execute(
+ "sudo apt-get install docker.io"
+ )
if status:
raise Exception("Command for installing docker failed.")
logger.info(stdout.splitlines())
- ssh_d.run("cd /etc/cadvisor-config/ && bash ./install.sh")
-
+ ssh_d.run("cd /etc/cadvisor_config/ && bash ./install.sh")
diff --git a/monitor/automate_collectd_client.py b/monitor/automate_collectd_client.py
index 6dd7067..8358cfc 100644
--- a/monitor/automate_collectd_client.py
+++ b/monitor/automate_collectd_client.py
@@ -8,31 +8,40 @@
##############################################################################
import logging
-import sys
import yaml
-sys.path.insert(0, '/home/opnfv/bottlenecks/utils/infra_setup/passwordless_SSH/')
-import ssh
+import utils.infra_setup.passwordless_SSH.ssh as ssh
logger = logging.getLogger(__name__)
+collectd_client_install_sh =\
+ "/home/opnfv/bottlenecks/monitor/install_collectd_client.sh"
+collectd_client_install_conf =\
+ "/home/opnfv/bottlenecks/monitor/config/collectd_client.conf"
+
with open('/tmp/pod.yaml') as f:
dataMap = yaml.safe_load(f)
for x in dataMap:
for y in dataMap[x]:
- if (y['role']=='Controller') or (y['role']=='Compute'):
+ if (y['role'] == 'Controller') or (y['role'] == 'Compute'):
ip = str(y['ip'])
user = str(y['user'])
pwd = str(y['password'])
- ssh_d = ssh.SSH(user, host= ip, password= pwd)
- status, stdout, stderr = ssh_d.execute("cd /etc && mkdir collectd-config")
+ ssh_d = ssh.SSH(user, host=ip, password=pwd)
+ status, stdout, stderr = ssh_d.execute(
+ "cd /etc && mkdir collectd_config"
+ )
if status:
raise Exception("Command failed with non-zero status.")
logger.info(stdout.splitlines())
- with open("/home/opnfv/bottlenecks/monitor/install-collectd-client.sh") as stdin_file:
- ssh_d.run("cat > /etc/collectd-config/install.sh", stdin=stdin_file)
- with open("/home/opnfv/bottlenecks/monitor/config/collectd-client.conf") as stdin_file:
- ssh_d.run("cat > /etc/collectd-config/collectd.conf", stdin=stdin_file)
- status, stdout, stderr = ssh_d.execute("sudo apt-get install docker.io")
+ with open(collectd_client_install_sh) as stdin_file:
+ ssh_d.run("cat > /etc/collectd_config/install.sh",
+ stdin=stdin_file)
+ with open(collectd_client_install_conf) as stdin_file:
+ ssh_d.run("cat > /etc/collectd_config/collectd.conf",
+ stdin=stdin_file)
+ status, stdout, stderr = ssh_d.execute(
+ "sudo apt-get install docker.io"
+ )
if status:
raise Exception("Command for installing docker failed.")
logger.info(stdout.splitlines())
- ssh_d.run("cd /etc/collectd-config/ && bash ./install.sh")
+ ssh_d.run("cd /etc/collectd_config/ && bash ./install.sh")
diff --git a/monitor/automated-dashboard-datasource.py b/monitor/automated_dashboard_datasource.py
index 69f3ebe..ee60504 100644
--- a/monitor/automated-dashboard-datasource.py
+++ b/monitor/automated_dashboard_datasource.py
@@ -23,7 +23,7 @@ def _create_dashboard(ip, port, path):
data = jsonutils.load(f)
try:
post(url, {"dashboard": data})
- logger.info( "Trying to post dashboard json!")
+ logger.info("Trying to post dashboard json!")
except Exception:
logger.info("Create dashboard failed")
raise
@@ -66,6 +66,6 @@ ip_address = socket.gethostbyname(socket.gethostname())
_create_data_source(ip_address, 3000)
_create_dashboard(ip_address, 3000, '/var/lib/grafana/' +
'dashboards/' +
- 'prometheus-system_rev1.json')
+ 'prometheus_system_rev1.json')
_create_dashboard(ip_address, 3000,
'prototype_dashboard_collapsible.json')
diff --git a/monitor/barometer_automated_client_install.py b/monitor/barometer_automated_client_install.py
index 7bbfa70..9bb2c6b 100644
--- a/monitor/barometer_automated_client_install.py
+++ b/monitor/barometer_automated_client_install.py
@@ -8,29 +8,36 @@
##############################################################################
import logging
-import sys
import yaml
-sys.path.insert(0, '/home/opnfv/bottlenecks/utils/infra_setup/passwordless_SSH/')
-import ssh
+import utils.infra_setup.passwordless_SSH.ssh as ssh
logger = logging.getLogger(__name__)
+barometer_client_install_sh =\
+ "/home/opnfv/bottlenecks/monitor/barometer_install_client.sh"
+barometer_client_install_conf =\
+ "/home/opnfv/bottlenecks/monitor/barometer_client.conf"
+
with open('/tmp/pod.yaml') as f:
dataMap = yaml.safe_load(f)
for x in dataMap:
for y in dataMap[x]:
- if (y['role']=='Controller') or (y['role']=='Compute'):
+ if (y['role'] == 'Controller') or (y['role'] == 'Compute'):
ip = str(y['ip'])
user = str(y['user'])
pwd = str(y['password'])
- ssh_d = ssh.SSH(user, host= ip, password= pwd)
- status, stdout, stderr = ssh_d.execute("cd /etc && mkdir barometer-config")
+ ssh_d = ssh.SSH(user, host=ip, password=pwd)
+ status, stdout, stderr = ssh_d.execute(
+ "cd /etc && mkdir barometer_config"
+ )
if status:
raise Exception("Command failed with non-zero status.")
logger.info(stdout.splitlines())
- with open("/home/opnfv/bottlenecks/monitor/barometer_client.conf") as stdin_file:
- ssh_d.run("cat > /etc/barometer-config/barometer_client_collectd.conf", stdin=stdin_file)
-
- with open("/home/opnfv/bottlenecks/monitor/barometer_install_client.sh") as stdin_file:
- ssh_d.run("cat > /etc/barometer-config/install.sh", stdin=stdin_file)
+ with open(barometer_client_install_conf) as stdin_file:
+ ssh_d.run("cat > /etc/barometer_config/\
+ barometer_client_collectd.conf",
+ stdin=stdin_file)
+ with open(barometer_client_install_sh) as stdin_file:
+ ssh_d.run("cat > /etc/barometer_config/install.sh",
+ stdin=stdin_file)
- ssh_d.run("cd /etc/barometer-config/ && bash ./install.sh")
+ ssh_d.run("cd /etc/barometer_config/ && bash ./install.sh")
diff --git a/monitor/barometer-collectd.conf b/monitor/barometer_collectd.conf
index ecb1261..ecb1261 100644
--- a/monitor/barometer-collectd.conf
+++ b/monitor/barometer_collectd.conf
diff --git a/monitor/barometer_install_client.sh b/monitor/barometer_install_client.sh
index d75adf1..2bf6cd8 100644
--- a/monitor/barometer_install_client.sh
+++ b/monitor/barometer_install_client.sh
@@ -1,5 +1,5 @@
docker pull opnfv/barometer
sudo docker run --name bottlenecks-barometer-client -tid --net=host -v `pwd`/../src/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
--v /etc/barometer-config/barometer_client_collectd.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
--v /etc/barometer-config/barometer_client_collectd.conf:/opt/collectd/etc/collectd.conf \
+-v /etc/barometer_config/barometer_client_collectd.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
+-v /etc/barometer_config/barometer_client_collectd.conf:/opt/collectd/etc/collectd.conf \
-v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer /run_collectd.sh
diff --git a/monitor/barometer-install-script.sh b/monitor/barometer_install_script.sh
index 9dc2009..b0abbb9 100644
--- a/monitor/barometer-install-script.sh
+++ b/monitor/barometer_install_script.sh
@@ -1,5 +1,5 @@
docker pull opnfv/barometer
sudo docker run --name bottlenecks-barometer-server -tid --net=host -v `pwd`/../src/collectd_sample_configs:/opt/collectd/etc/collectd.conf.d \
--v /home/opnfv/bottlenecks/monitor/barometer-collectd.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
--v /etc/barometer-config/barometer_client_collectd.conf:/opt/collectd/etc/collectd.conf \
+-v /home/opnfv/bottlenecks/monitor/barometer_collectd.conf:/src/barometer/src/collectd/collectd/src/collectd.conf \
+-v /etc/barometer_config/barometer_client_collectd.conf:/opt/collectd/etc/collectd.conf \
-v /var/run:/var/run -v /tmp:/tmp --privileged opnfv/barometer /run_collectd.sh
diff --git a/monitor/client_ip_configure.py b/monitor/client_ip_configure.py
index 9bfb12c..2a66f7b 100644
--- a/monitor/client_ip_configure.py
+++ b/monitor/client_ip_configure.py
@@ -10,18 +10,16 @@ import fileinput
import re
import logging
import socket
-import requests
-from oslo_serialization import jsonutils
logger = logging.getLogger(__name__)
ip_address = socket.gethostbyname(socket.gethostname())
for line in fileinput.input(inplace=1):
- ip = " Server \"" + str(ip_address) +"\" \"25826\""
- line = re.sub(r'.*Server.*25826.*', r''+str(ip), line.rstrip())
+ ip = " Server \"" + str(ip_address) + "\" \"25826\""
+ line = re.sub(r'.*Server.*25826.*', r'' + str(ip), line.rstrip())
print(line)
for line in fileinput.input(inplace=1):
- ip = " URL \"http://"+str(ip_address)+":9103/collectd-post\""
- line = re.sub(r'.*URL.*collectd-post.*', r''+str(ip), line.rstrip())
+ ip = " URL \"http://" + str(ip_address) + ":9103/collectd-post\""
+ line = re.sub(r'.*URL.*collectd-post.*', r'' + str(ip), line.rstrip())
print(line)
diff --git a/monitor/custom-dashboard.py b/monitor/custom_dashboard.py
index 48173f8..2a4f79c 100644
--- a/monitor/custom-dashboard.py
+++ b/monitor/custom_dashboard.py
@@ -9,14 +9,15 @@
import json
+
def customize_query(filename, rowtitle, panelname, expr):
with open(filename, 'r+') as f:
data = json.load(f)
- x = data['rows'] #this is an array of the rows of the dashboard
+ x = data['rows'] # this is an array of the rows of the dashboard
for y in x:
if y['title'] == rowtitle:
pan = y['panels']
- for i in range(len(pan)-1) :
+ for i in range(len(pan) - 1):
z = pan[i]
if z['title'] == panelname:
tar = z['targets']
@@ -26,6 +27,7 @@ def customize_query(filename, rowtitle, panelname, expr):
json.dump(data, f, indent=4)
f.truncate()
-customize_query("/home/opnfv/bottlenecks/monitor/custom-query-dashboard.json",
- "Dashboard Row", "Memory Usage per Container", "Sample Prometheus Query")
+customize_query("/home/opnfv/bottlenecks/monitor/custom-query-dashboard.json",
+ "Dashboard Row", "Memory Usage per Container",
+ "Sample Prometheus Query")
diff --git a/monitor/custom-query-dashboard.json b/monitor/custom_query_dashboard.json
index 7f2e53a..7f2e53a 100644
--- a/monitor/custom-query-dashboard.json
+++ b/monitor/custom_query_dashboard.json
diff --git a/monitor/grafana/dashboards/prometheus-system_rev1.json b/monitor/grafana/dashboards/prometheus_system_rev1.json
index 99e98b4..99e98b4 100644
--- a/monitor/grafana/dashboards/prometheus-system_rev1.json
+++ b/monitor/grafana/dashboards/prometheus_system_rev1.json
diff --git a/monitor/install-collectd-client.sh b/monitor/install_collectd_client.sh
index 00fa4c8..3861f98 100644
--- a/monitor/install-collectd-client.sh
+++ b/monitor/install_collectd_client.sh
@@ -1,4 +1,4 @@
-MONITOR_CONFIG="/etc/collectd-config"
+MONITOR_CONFIG="/etc/collectd_config"
# Collectd
sudo docker run --name bottlenecks-automated-collectd -d \
diff --git a/monitor/monitoring.sh b/monitor/monitoring.sh
index 01c1edc..9abe49d 100644
--- a/monitor/monitoring.sh
+++ b/monitor/monitoring.sh
@@ -64,7 +64,7 @@ sudo docker run \
python client_ip_configure.py barometer_client.conf
# Configure IP Address in barometer server configuration
-python server_ip_configure.py barometer-collectd.conf
+python server_ip_configure.py barometer_collectd.conf
# Automate Collectd Client
python automate_collectd_client.py
@@ -73,10 +73,10 @@ python automate_collectd_client.py
python automate_cadvisor_client.py
# Automate Barometer installation for jump server
-bash ./barometer-install-script.sh
+bash ./barometer_install_script.sh
# Automate Barometer installation for compute/controller nodes
python barometer_automated_client_install.py
# Automate Prometheus Datasource and Grafana Dashboard creation
-python automated-dashboard-datasource.py
+python automated_dashboard_datasource.py
diff --git a/monitor/server_ip_configure.py b/monitor/server_ip_configure.py
index 4e8d630..62aa628 100644
--- a/monitor/server_ip_configure.py
+++ b/monitor/server_ip_configure.py
@@ -10,18 +10,16 @@ import fileinput
import re
import logging
import socket
-import requests
-from oslo_serialization import jsonutils
logger = logging.getLogger(__name__)
ip_address = socket.gethostbyname(socket.gethostname())
for line in fileinput.input(inplace=1):
- ip = " Listen \"" + str(ip_address) +"\" \"25826\""
- line = re.sub(r'.*Listen.*25826.*', r''+str(ip), line.rstrip())
+ ip = " Listen \"" + str(ip_address) + "\" \"25826\""
+ line = re.sub(r'.*Listen.*25826.*', r'' + str(ip), line.rstrip())
print(line)
for line in fileinput.input(inplace=1):
- ip = " URL \"http://"+str(ip_address)+":9103/collectd-post\""
- line = re.sub(r'.*URL.*collectd-post.*', r''+str(ip), line.rstrip())
+ ip = " URL \"http://" + str(ip_address) + ":9103/collectd-post\""
+ line = re.sub(r'.*URL.*collectd-post.*', r'' + str(ip), line.rstrip())
print(line)