##############################################################################
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")
##############################################################################
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")
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
_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')
##############################################################################
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")
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
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
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)
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']
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")
-MONITOR_CONFIG="/etc/collectd-config"
+MONITOR_CONFIG="/etc/collectd_config"
# Collectd
sudo docker run --name bottlenecks-automated-collectd -d \
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
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
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)