---
scripts/collectd.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
create mode 100755 scripts/collectd.py
diff --git a/scripts/collectd.py b/scripts/collectd.py
new file mode 100755
index 0000000..729f3a9
--- /dev/null
+++ b/scripts/collectd.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+#
+# Configures the collectd daemon.
+
+import os
+import sys
+from ovirtfunctions import *
+from subprocess import Popen, PIPE, STDOUT
+
+collectd_conf="/etc/collectd.conf"
+
+def ovirt_collectd(server, port):
+ if os.path.exists(collectd_conf + ".in"):
+ sed_cmd = "sed -e \"s/@COLLECTD_SERVER@/%s/\" \
+ -e \"s/@COLLECTD_PORT@/%s/\" %s.in \
+ > %s" % (server, port, collectd_conf, collectd_conf)
+ sed = subprocess.Popen(sed_cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ sed.poll()
+ rc = sed.returncode()
+ if rc != 0:
+ log("Failed to write $collectd_conf")
+ sys.exit(1)
+
+ os.system("chkconfig collectd on")
+ os.system("service collectd restart")
+
+# AUTO for auto-install
+if len(sys.argv) > 1:
+ if sys.argv[1] == "AUTO":
+ if not OVIRT_VARS.has_key("OVIRT_COLLECTD_SERVER") or not
OVIRT_VARS.has_key["OVIRT_COLLECTD_PORT"]:
+ log("\nAttempting to locate remote collectd server...")
+ host, port = find_srv("collectd", "udp")
+ if not host is None and not port is None:
+ log("found! Using collectd server " + host +
":" + port)
+ ovirt_collectd(host, port)
+ else:
+ log("collectd server not found!\n")
+ else:
+ log("\nUsing default collectd server
'$OVIRT_COLLECTD_SERVER:$OVIRT_COLLECTD_PORT'.\n")
+ ovirt_collectd(OVIRT_VARS["OVIRT_COLLECTD_SERVER"],
OVIRT_VARS["OVIRT_COLLECTD_PORT"])
--
1.7.2.3