summaryrefslogtreecommitdiffstats
path: root/doctor_tests/monitor/collectd.py
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2017-09-15 14:37:32 +0800
committerwenjuan dong <dong.wenjuan@zte.com.cn>2017-09-15 06:45:14 +0000
commita321477d00ccb84b0d99e7476e4306605498409d (patch)
treeb3e657341a92b66fb35d511b033a6f69ee04c40a /doctor_tests/monitor/collectd.py
parent54b4b3418aae6d649411b531f0aa8bc4d9fd6b2c (diff)
fix collectd's bug
After we move files under doctor_tests and install doctor package, the tests/lib/monitors/collectd/collectd_plugin.py file will not be in the doctor_tests package. Change-Id: I24a098e26ea3cd257f2376458d5c31ecc87aac68 Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'doctor_tests/monitor/collectd.py')
-rw-r--r--doctor_tests/monitor/collectd.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/doctor_tests/monitor/collectd.py b/doctor_tests/monitor/collectd.py
index a22d7edc..4e9329c2 100644
--- a/doctor_tests/monitor/collectd.py
+++ b/doctor_tests/monitor/collectd.py
@@ -17,7 +17,8 @@ from doctor_tests.monitor.base import BaseMonitor
class CollectdMonitor(BaseMonitor):
def __init__(self, conf, inspector_url, log):
super(CollectdMonitor, self).__init__(conf, inspector_url, log)
- self.top_dir = os.path.dirname(sys.path[0])
+ monitor_dir = os.path.split(os.path.realpath(__file__))[0]
+ self.top_dir = os.path.dirname(monitor_dir)
tmp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
tmp_sock.connect(("8.8.8.8", 80))
@@ -44,7 +45,7 @@ class CollectdMonitor(BaseMonitor):
self.log.info("Collectd monitor start.........")
self.compute_host = host.name
self.compute_ip = host.ip
- f = open("%s/tests/collectd.conf" % self.top_dir, 'w')
+ f = open("%s/collectd.conf" % self.top_dir, 'w')
collectd_conf_file = """
Hostname %s
FQDNLookup false
@@ -98,7 +99,7 @@ LoadPlugin logfile
f.write(collectd_conf_file)
f.close()
- os.system(" scp %s %s/tests/collectd.conf %s@%s: " % (self.ssh_opts_cpu, self.top_dir, self.compute_user, self.compute_ip))
+ os.system(" scp %s %s/collectd.conf %s@%s: " % (self.ssh_opts_cpu, self.top_dir, self.compute_user, self.compute_ip))
self.log.info("after first scp")
## @TODO (umar) Always assuming that the interface is assigned an IP if
## interface name is not provided. See if there is a better approach
@@ -116,7 +117,7 @@ LoadPlugin logfile
fi
sudo mv collectd.conf /opt/collectd/etc/collectd.conf\" """ % (self.ssh_opts_cpu, self.compute_user, self.compute_ip, self.interface_name, self.interface_name, self.compute_ip))
self.log.info("after first ssh")
- os.system(" scp %s %s/tests/lib/monitors/collectd/collectd_plugin.py %s@%s:collectd_plugin.py " % (self.ssh_opts_cpu, self.top_dir, self.compute_user, self.compute_ip))
+ os.system(" scp %s %s/monitor/collectd_plugin.py %s@%s:collectd_plugin.py " % (self.ssh_opts_cpu, self.top_dir, self.compute_user, self.compute_ip))
self.log.info("after sec scp")
os.system(" ssh %s %s@%s \"sudo pkill collectd; sudo /opt/collectd/sbin/collectd\" " % (self.ssh_opts_cpu, self.compute_user, self.compute_ip))
self.log.info("after sec ssh")
@@ -134,4 +135,4 @@ LoadPlugin logfile
sudo cp -f \"\${collectd_conf}-doctor-saved\" \$collectd_conf
sudo rm \"\${collectd_conf}-doctor-saved\"
fi\" """ % (self.ssh_opts_cpu, self.compute_user, self.compute_ip))
- os.remove("%s/tests/collectd.conf" % self.top_dir)
+ os.remove("%s/collectd.conf" % self.top_dir)