diff --git a/Vagrantfile b/Vagrantfile index b7a93bd22..49b5b4b77 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -75,4 +75,47 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| c.vm.provision "shell", inline: "sudo yum install -y git rpm-build python-configobj python-test python-mock tree vim-enhanced MySQL-python" end + config.vm.define "centos7-test" do |c| + c.vm.hostname = "centos7-test" + c.vm.box = "opscode_centos-7.2" + c.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box" + + c.vm.provider "virtualbox" do |v| + v.memory = 1024 + v.cpus = 2 + end + + c.vm.provision "shell", inline: "sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm" + c.vm.provision "shell", inline: "sudo yum install -y git rpm-build python-configobj python-test python-mock tree vim-enhanced MySQL-python htop" + + # Install python libraries needed by specific collectors + c.vm.provision "shell", inline: "sudo yum install -y postgresql-devel" # req for psycopg2 + c.vm.provision "shell", inline: "sudo yum install -y Cython" # req for pyutmp + c.vm.provision "shell", inline: "sudo yum install -y lm_sensors-devel lm_sensors python-devel" # req for pyutmp + c.vm.provision "shell", inline: "sudo yum install -y python-pip" + c.vm.provision "shell", inline: "sudo pip install -r /vagrant/.travis.requirements.txt" + + # Setup Diamond to run as a service + c.vm.provision "shell", inline: "sudo yum install -y python-setuptools" + c.vm.provision "shell", inline: "sudo mkdir /var/log/diamond" + c.vm.provision "shell", inline: "sudo ln -s /vagrant/conf/vagrant /etc/diamond" + c.vm.provision "shell", inline: "sudo ln -s /vagrant/bin/diamond /usr/bin/diamond" + c.vm.provision "shell", inline: "sudo ln -s /vagrant/src/diamond /usr/lib/python2.7/site-packages/diamond" + c.vm.provision "shell", inline: "sudo ln -s /vagrant/rpm/systemd/diamond.service /usr/lib/systemd/system/diamond.service" + + # Install other components to test with + + ## Redis + c.vm.provision "shell", inline: "sudo yum install -y redis" + c.vm.provision "shell", inline: "sudo systemctl start redis.service" + + # Build Diamond docs and run tests + c.vm.provision "shell", inline: "sudo pip install pep8==1.5.7" + c.vm.provision "shell", inline: "echo 'Build docs...' && python /vagrant/build_doc.py" + c.vm.provision "shell", inline: "echo 'Running tests...' && python /vagrant/test.py" + c.vm.provision "shell", inline: "echo 'Running pep8...' && pep8 --config=/vagrant/.pep8 /vagrant/src /vagrant/bin/diamond /vagrant/bin/diamond-setup /vagrant/build_doc.py /vagrant/setup.py /vagrant/test.py" + + # Start diamond + c.vm.provision "shell", inline: "sudo systemctl start diamond.service" + end end diff --git a/conf/vagrant/collectors/RedisCollector.conf b/conf/vagrant/collectors/RedisCollector.conf new file mode 100644 index 000000000..943caeacb --- /dev/null +++ b/conf/vagrant/collectors/RedisCollector.conf @@ -0,0 +1,2 @@ +enabled=true +instances=localhost:6379 diff --git a/conf/vagrant/diamond.conf b/conf/vagrant/diamond.conf new file mode 100644 index 000000000..35b4feda9 --- /dev/null +++ b/conf/vagrant/diamond.conf @@ -0,0 +1,259 @@ +################################################################################ +# Diamond Configuration File +################################################################################ + +################################################################################ +### Options for the server +[server] + +# Handlers for published metrics. +#handlers = diamond.handler.graphite.GraphiteHandler, diamond.handler.archive.ArchiveHandler +handlers = diamond.handler.archive.ArchiveHandler + +# User diamond will run as +# Leave empty to use the current user +user = + +# Group diamond will run as +# Leave empty to use the current group +group = + +# Pid file +pid_file = /var/run/diamond.pid + +# Directory to load collector modules from +collectors_path = /vagrant/src/collectors/ + +# Directory to load collector configs from +collectors_config_path = /etc/diamond/collectors/ + +# Number of seconds between each collector load +# collectors_load_delay = 1.0 + +# Directory to load handler configs from +handlers_config_path = /etc/diamond/handlers/ + +# Directory to load handler modules from +handlers_path = /vagrant/src/diamond/handler/ + +# Maximum number of metrics waiting to be processed by handlers. +# When metric queue is full, new metrics are dropped. +metric_queue_size = 16384 + + +################################################################################ +### Options for handlers +[handlers] + +# daemon logging handler(s) +keys = rotated_file + +### Defaults options for all Handlers +[[default]] + +[[ArchiveHandler]] + +# File to write archive log files +log_file = /var/log/diamond/archive.log + +# Number of days to keep archive log files +days = 1 + +[[GraphiteHandler]] +### Options for GraphiteHandler + +# Graphite server host +host = 127.0.0.1 + +# Port to send metrics to +port = 2003 + +# Socket timeout (seconds) +timeout = 15 + +# Batch size for metrics +batch = 1 + +[[GraphitePickleHandler]] +### Options for GraphitePickleHandler + +# Graphite server host +host = 127.0.0.1 + +# Port to send metrics to +port = 2004 + +# Socket timeout (seconds) +timeout = 15 + +# Batch size for pickled metrics +batch = 256 + +[[MySQLHandler]] +### Options for MySQLHandler + +# MySQL Connection Info +hostname = 127.0.0.1 +port = 3306 +username = root +password = +database = diamond +table = metrics +# INT UNSIGNED NOT NULL +col_time = timestamp +# VARCHAR(255) NOT NULL +col_metric = metric +# VARCHAR(255) NOT NULL +col_value = value + +[[StatsdHandler]] +host = 127.0.0.1 +port = 8125 + +[[TSDBHandler]] +host = 127.0.0.1 +port = 4242 +timeout = 15 + +[[LibratoHandler]] +user = user@example.com +apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 + +[[HostedGraphiteHandler]] +apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01 +timeout = 15 +batch = 1 + +[[SignalfxHandler]] +auth_token = abcdefghijklmnopqrstuvwxyz + +# And any other config settings from GraphiteHandler are valid here + +[[HttpPostHandler]] + +### Urp to post the metrics +url = http://localhost:8888/ +### Metrics batch size +batch = 100 + + +################################################################################ +### Options for collectors +[collectors] + +[[default]] +### Defaults options for all Collectors + +# Uncomment and set to hardcode a hostname for the collector path +# Keep in mind, periods are seperators in graphite +# hostname = my_custom_hostname + +# If you prefer to just use a different way of calculating the hostname +# Uncomment and set this to one of these values: + +# smart = Default. Tries fqdn_short. If that's localhost, uses hostname_short + +# fqdn_short = Default. Similar to hostname -s +# fqdn = hostname output +# fqdn_rev = hostname in reverse (com.example.www) + +# uname_short = Similar to uname -n, but only the first part +# uname_rev = uname -r in reverse (com.example.www) + +# hostname_short = `hostname -s` +# hostname = `hostname` +# hostname_rev = `hostname` in reverse (com.example.www) + +# shell = Run the string set in hostname as a shell command and use its +# output(with spaces trimmed off from both ends) as the hostname. + +# hostname_method = smart + +# Path Prefix and Suffix +# you can use one or both to craft the path where you want to put metrics +# such as: %(path_prefix)s.$(hostname)s.$(path_suffix)s.$(metric)s +# path_prefix = servers +# path_suffix = + +# Path Prefix for Virtual Machines +# If the host supports virtual machines, collectors may report per +# VM metrics. Following OpenStack nomenclature, the prefix for +# reporting per VM metrics is "instances", and metric foo for VM +# bar will be reported as: instances.bar.foo... +# instance_prefix = instances + +# Default Poll Interval (seconds) +interval = 15 + +################################################################################ +# Default enabled collectors +################################################################################ + +[[CPUCollector]] +enabled = True + +[[DiskSpaceCollector]] +enabled = True + +[[DiskUsageCollector]] +enabled = True + +[[LoadAverageCollector]] +enabled = True + +[[MemoryCollector]] +enabled = True + +[[VMStatCollector]] +enabled = True + +################################################################################ +### Options for logging +# for more information on file format syntax: +# http://docs.python.org/library/logging.config.html#configuration-file-format + +[loggers] + +keys = root + +# handlers are higher in this config file, in: +# [handlers] +# keys = ... + +[formatters] + +keys = default + +[logger_root] + +# to increase verbosity, set DEBUG +level = DEBUG +handlers = rotated_file +propagate = 1 + +[handler_rotated_file] + +class = handlers.TimedRotatingFileHandler +level = DEBUG +formatter = default +# rotate at midnight, each day and keep 7 days +args = ('/var/log/diamond/diamond.log', 'midnight', 1, 7) + +[formatter_default] + +format = [%(asctime)s] [%(threadName)s] %(message)s +datefmt = + +################################################################################ +### Options for config merging +# [configs] +# path = "/etc/diamond/configs/" +# extension = ".conf" +#------------------------------------------------------------------------------- +# Example: +# /etc/diamond/configs/net.conf +# [collectors] +# +# [[NetworkCollector]] +# enabled = True +