From 55b54a537be1209b42db036e10b3be43e80f88fd Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 7 Jun 2013 19:36:29 +0000 Subject: [PATCH] add all the collectd basics. --- files/collectd/README | 5 +++ files/collectd/apache.conf | 6 +++ files/collectd/bind.conf | 21 ++++++++++ files/collectd/collectd_haproxy.sh | 25 ++++++++++++ files/collectd/collectd_mailq.sh | 26 ++++++++++++ files/collectd/collected.conf.j2 | 46 ++++++++++++++++++++++ files/collectd/fedmsg-types.db | 2 + files/collectd/fedmsg.conf | 6 +++ files/collectd/haproxy-types.db | 2 + files/collectd/haproxy.conf | 3 ++ files/collectd/mailq.conf | 3 ++ files/collectd/network-client.conf | 5 +++ files/collectd/nfs.conf | 1 + files/collectd/pgconns-types.db | 2 + files/collectd/rrdtool.conf | 8 ++++ tasks/collectd/client.yml | 63 ++++++++++++++++++++++++++++++ 16 files changed, 224 insertions(+) create mode 100644 files/collectd/README create mode 100644 files/collectd/apache.conf create mode 100644 files/collectd/bind.conf create mode 100644 files/collectd/collectd_haproxy.sh create mode 100755 files/collectd/collectd_mailq.sh create mode 100644 files/collectd/collected.conf.j2 create mode 100644 files/collectd/fedmsg-types.db create mode 100644 files/collectd/fedmsg.conf create mode 100644 files/collectd/haproxy-types.db create mode 100644 files/collectd/haproxy.conf create mode 100644 files/collectd/mailq.conf create mode 100644 files/collectd/network-client.conf create mode 100644 files/collectd/nfs.conf create mode 100644 files/collectd/pgconns-types.db create mode 100644 files/collectd/rrdtool.conf create mode 100644 tasks/collectd/client.yml diff --git a/files/collectd/README b/files/collectd/README new file mode 100644 index 0000000000..450f2fb80b --- /dev/null +++ b/files/collectd/README @@ -0,0 +1,5 @@ +collectd takes conf files in /etc/collect.d/somefile.conf + +and if you add a type you will need to add it to a types.db for that file + +see any of the examples diff --git a/files/collectd/apache.conf b/files/collectd/apache.conf new file mode 100644 index 0000000000..dacd82a7d9 --- /dev/null +++ b/files/collectd/apache.conf @@ -0,0 +1,6 @@ +LoadPlugin apache + + + URL "http://localhost/apache-status?auto" + + diff --git a/files/collectd/bind.conf b/files/collectd/bind.conf new file mode 100644 index 0000000000..bdb4caafbd --- /dev/null +++ b/files/collectd/bind.conf @@ -0,0 +1,21 @@ +LoadPlugin bind + + + URL "http://localhost:8053/" + OpCodes true + QTypes true + + ServerStats true + ZoneMaintStats true + ResolverStats false + MemoryStats true + + + QTypes true + ResolverStats true + CacheRRSets true + + Zone "127.in-addr.arpa/IN" + + + diff --git a/files/collectd/collectd_haproxy.sh b/files/collectd/collectd_haproxy.sh new file mode 100644 index 0000000000..c265ac616f --- /dev/null +++ b/files/collectd/collectd_haproxy.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +sock='/var/run/haproxy-stat' +host="$(hostname -s)" +pause=10 + +while getopts "h:p:s:" c; do + case $c in + h) host=$OPTARG;; + p) pause=$OPTARG;; + s) sock=$OPTARG;; + *) echo "Usage: $0 [-h ] [-p ] [-s ]";; + esac +done + +while [ $? -eq 0 ]; do + time="$(date +%s)" + echo 'show stat' | socat - UNIX-CLIENT:$sock \ + |while IFS=',' read pxname svname qcur qmax scur smax slim stot bin bout dreq dresp ereq econ eresp wretr wredis status weight act bck chkfail chdown lastchg downtime qlimit pid iid sid throttle lbtot tracked type; do + [ "$svname" != 'BACKEND' ] && continue + echo "PUTVAL $host/haproxy/haproxy_backend-$pxname $time:$stot:$econ:$eresp" + done + sleep $pause +done + diff --git a/files/collectd/collectd_mailq.sh b/files/collectd/collectd_mailq.sh new file mode 100755 index 0000000000..a9deb20e02 --- /dev/null +++ b/files/collectd/collectd_mailq.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +host=$(hostname -s) +pause=10 + +while getopts "h:p:s:" opt; do + case "$opt" in + h) + host=$OPTARG + ;; + p) + pause=$OPTARG + ;; + *) + echo "Usage: $0 [-h ] [-p ]" >&2; + exit 1 + ;; + esac +done + +while [ $? -eq 0 ]; do + ts=$(date +%s) + queue_size=$(mailq | awk 'END { print (/Mail queue is empty/ ? 0 : $5) }') + echo "PUTVAL \"$host/mail_queue/email_count\" $ts:$queue_size"; + sleep $pause +done diff --git a/files/collectd/collected.conf.j2 b/files/collectd/collected.conf.j2 new file mode 100644 index 0000000000..91f5a6343b --- /dev/null +++ b/files/collectd/collected.conf.j2 @@ -0,0 +1,46 @@ +# +# Config file for collectd(1). +# Please read collectd.conf(5) for a list of options. +# http://collectd.org/ +# + +Hostname "{{ inventory_hostname }}" +FQDNLookup true +#BaseDir "/usr/var/lib/collectd" +#PIDFile "/usr/var/run/collectd.pid" +#PluginDir "/usr/lib/collectd" +#TypesDB "/usr/lib/collectd/types.db" +#Interval 10 +#ReadThreads 5 + +LoadPlugin syslog + + + LogLevel err + + +LoadPlugin cpu +LoadPlugin df +LoadPlugin disk +LoadPlugin exec +LoadPlugin interface +LoadPlugin load +LoadPlugin memory +LoadPlugin processes +LoadPlugin swap +LoadPlugin tail +LoadPlugin users +LoadPlugin vmem + + + Disk "/^[hs]d[a-f]?$/" + Disk "/^xvd[a-f]?$/" + Disk "/dev/xvdb1" + IgnoreSelected false + + + + TranslateDevicename false + + +Include "/etc/collectd.d" diff --git a/files/collectd/fedmsg-types.db b/files/collectd/fedmsg-types.db new file mode 100644 index 0000000000..9471315774 --- /dev/null +++ b/files/collectd/fedmsg-types.db @@ -0,0 +1,2 @@ +fedmsg_wallboard count:GAUGE:0:U + diff --git a/files/collectd/fedmsg.conf b/files/collectd/fedmsg.conf new file mode 100644 index 0000000000..d9b2deb618 --- /dev/null +++ b/files/collectd/fedmsg.conf @@ -0,0 +1,6 @@ +LoadPlugin exec +TypesDB "/usr/share/collectd/fedmsg-types.db" + + + Exec "fedmsg" "/usr/bin/fedmsg-collectd" "--collectd-interval" "10" + diff --git a/files/collectd/haproxy-types.db b/files/collectd/haproxy-types.db new file mode 100644 index 0000000000..d85f18f9ba --- /dev/null +++ b/files/collectd/haproxy-types.db @@ -0,0 +1,2 @@ +haproxy_backend stot:COUNTER:0:U econ:COUNTER:0:U eresp:COUNTER:0:U + diff --git a/files/collectd/haproxy.conf b/files/collectd/haproxy.conf new file mode 100644 index 0000000000..7631d61ad2 --- /dev/null +++ b/files/collectd/haproxy.conf @@ -0,0 +1,3 @@ + + Exec "haproxy" "/usr/local/bin/collectd_haproxy.sh" "-h" "haproxy" "-s" "/var/run/haproxy-stat" "-p" "10" + diff --git a/files/collectd/mailq.conf b/files/collectd/mailq.conf new file mode 100644 index 0000000000..18069de17f --- /dev/null +++ b/files/collectd/mailq.conf @@ -0,0 +1,3 @@ + + Exec "nobody" "/usr/local/bin/collectd_mailq.sh" + diff --git a/files/collectd/network-client.conf b/files/collectd/network-client.conf new file mode 100644 index 0000000000..c2b0030c9e --- /dev/null +++ b/files/collectd/network-client.conf @@ -0,0 +1,5 @@ +LoadPlugin network + + + Server "log02" + diff --git a/files/collectd/nfs.conf b/files/collectd/nfs.conf new file mode 100644 index 0000000000..fccd08299c --- /dev/null +++ b/files/collectd/nfs.conf @@ -0,0 +1 @@ +LoadPlugin nfs diff --git a/files/collectd/pgconns-types.db b/files/collectd/pgconns-types.db new file mode 100644 index 0000000000..a4c57eff2d --- /dev/null +++ b/files/collectd/pgconns-types.db @@ -0,0 +1,2 @@ +pg_conns value:GAUGE:0:U + diff --git a/files/collectd/rrdtool.conf b/files/collectd/rrdtool.conf new file mode 100644 index 0000000000..869d8de53a --- /dev/null +++ b/files/collectd/rrdtool.conf @@ -0,0 +1,8 @@ +LoadPlugin rrdtool + + + CacheTimeout 160 + CacheFlush 1200 + WritesPerSecond 50 + + diff --git a/tasks/collectd/client.yml b/tasks/collectd/client.yml new file mode 100644 index 0000000000..7fe2b831fe --- /dev/null +++ b/tasks/collectd/client.yml @@ -0,0 +1,63 @@ +--- +# collectd client setup + +# install pkg +- name: install collectd + yum: name=collectd state=installed + +# enable collectd +- name: enable collectd svc + service: state=running enabled=true name=collectd + +# install collected.conf +- name: /etc/collectd.conf + template: src=$files/collectd/collectd.conf dest=/etc/collectd.conf state=present + notify: + - restart collectd + +# install collectd-network config +- name: /etc/collectd.d/nework.conf + copy: src=$files/collectd/network-client.conf dest=/etc/collectd/network.conf state=present + notify: + - restart collectd + +# apache - localhost only - pretty much any apache server +- name: install collectd-apache + yum: state=installed name=collectd-apache + notify: + - restart collectd + when_set: $collectd_apache + +- name: /etc/collectd/apache.conf + copy: src=$files/collectd/apache.conf dest=/etc/collectd/apache.conf state=present + notify: + - restart collectd + when_set: $collectd_apache + + +# each of the below should move to a separate task list +# since they are odd-balls and one-offs + +# bind - localhost only - ns servers only + +# fedmsg - busgateway## only + # add /usr/share/collectd/fedmsg-types.db + +# memcached - memcached only + +# postgres - this is a conn check +## add /usr/share/collectd/pgconn-types.db + +# openvpn - for bastion/openvpn gateways only + +# mysql +## collectd-mysql + +# haproxy +## add /usr/share/collectd/haproxy-types.db +## add socat pkg +## + +# webproxy + + \ No newline at end of file