Skip to content

Commit

Permalink
Restructured sensu stuff somewhat
Browse files Browse the repository at this point in the history
This is the exact same code as I submitted here:
    https://github.com/sonian/sensu/pull/249
  • Loading branch information
blast-hardcheese committed Mar 19, 2012
1 parent d50db41 commit 5c9ff6f
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 21 deletions.
2 changes: 2 additions & 0 deletions sensu/common.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
{% set sensu_parts = ["sensu-server", "sensu-dashboard", "sensu-api", "sensu-client"] %}

{% macro init_script_path(part) %}{{ init_prefix }}/{{ part }}{% endmacro %}
{% macro config_filename(hostname, part) %}{{ part }}-{{ hostname }}.conf{% endmacro %}
{% macro config_path(hostname, part) %}/etc/sensu/{{ config_filename(hostname, part) }}{% endmacro %}
11 changes: 9 additions & 2 deletions sensu/config.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% import "sensu/common.jinja" as common %}
{% set hostname = salt['cmd.run']('hostname -s') %}
/var/log/sensu/:
file:
- directory
Expand All @@ -14,12 +17,16 @@
- mode: 755
- makedirs: true
/etc/sensu/config.json:
{%- for part in common.sensu_parts %}
{%- if pillar[part] %}
{{ common.config_path(hostname, part) }}:
file:
- managed
- source: salt://sensu/etc/sensu/config.json
- source: salt://sensu/etc/sensu/{{ common.config_filename(hostname, part) }}
- template: jinja
- mode: 755
- require:
- file: /etc/sensu/
- file: /var/log/sensu/
{%- endif %}
{%- endfor %}
7 changes: 4 additions & 3 deletions sensu/etc/init.d/init-template
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
+ " | grep bin/" + part ) %}

DAEMON={{ daemon_path }}
NAME=sensu-{{ part }}
NAME={{ part }}
DESC="sensu {{ part }}"
HOST=$(hostname -s)

test -x $DAEMON || exit 0

LOGFILE=/var/log/sensu/$NAME.log
PIDFILE=/var/run/$NAME.pid
DODTIME=4

DAEMON_OPTS="-b -p $PIDFILE -l $LOGFILE"
DAEMON_OPTS="-b -p $PIDFILE -l $LOGFILE -c /etc/sensu/$NAME-$HOST.conf"

set -e

Expand Down Expand Up @@ -80,7 +81,7 @@ case "$1" in
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --retry $DODTIME --quiet --oknodo --pidfile $PIDFILE
start-stop-daemon --stop --retry $DODTIME --quiet --oknodo --pidfile $PIDFILE
echo "$NAME."
;;
force-stop)
Expand Down
28 changes: 28 additions & 0 deletions sensu/etc/sensu/sensu-api-sensu02.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"rabbitmq": {
"host": "localhost",
"user": "sensu",
"password": "sensupasswd",
"vhost": "/sensu"
},

"redis": {
"host": "localhost",
"port": 6379
},

"api": {
"host": "localhost",
"port": 4567
},

"checks": {
"disk-free": {
"command": "df -h /",
"subscribers": [
"fileservers"
],
"interval": 30
}
}
}
25 changes: 25 additions & 0 deletions sensu/etc/sensu/sensu-client-sensu02.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"rabbitmq": {
"host": "localhost",
"user": "sensu",
"password": "sensupasswd",
"vhost": "/sensu"
},

"checks": {
"disk-free": {
"command": "df -h /",
"subscribers": [
"fileservers"
],
"interval": 30
}
},

"client": {
"name": "sensu02",
"address": "127.0.0.1",
"subscriptions": [ "fileservers" ]
}
}

26 changes: 26 additions & 0 deletions sensu/etc/sensu/sensu-dashboard-sensu02.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"rabbitmq": {
"host": "localhost",
"user": "sensu",
"password": "sensupasswd",
"vhost": "/sensu"
},

"dashboard": {
"host": "0.0.0.0",
"port": 8080,
"user": "admin",
"password": "secret"
},

"checks": {
"disk-free": {
"command": "df -h /",
"subscribers": [
"fileservers"
],
"interval": 30
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
"port": 4567
},

"dashboard": {
"host": "0.0.0.0",
"port": 8080,
"user": "admin",
"password": "secret"
},

"handlers": {
"default": {
"type": "pipe",
Expand All @@ -38,12 +31,6 @@
],
"interval": 30
}
},

"client": {
"name": "{{ name }}",
"address": "127.0.0.1",
"subscriptions": [ "fileservers" ]
}
}
}

1 change: 0 additions & 1 deletion sensu/initscripts.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- template: jinja
- mode: 755
- defaults:
daemon_path: "{{ salt['cmd.run'](cmd) }}"
part: "{{ part }}"
- require:
Expand Down
3 changes: 2 additions & 1 deletion sensu/services.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% import "sensu/common.jinja" as common %}
{% set hostname = salt['cmd.run']('hostname -s') %}
{%- for part in common.sensu_parts %}
{%- if pillar[part] %}
Expand All @@ -8,6 +9,6 @@
- require:
- file: {{ common.init_script_path( part ) }}
- watch:
- file: /etc/sensu/config.json
- file: {{ common.config_path(hostname, part) }}
{%- endif %}
{%- endfor %}

0 comments on commit 5c9ff6f

Please sign in to comment.