Hi Gautam,
Comments inline…
Thankyou very Joel and Shankarbalan.
I am using both subscription and token substitution right now. But I have separate check definition file for all checks which i think should be a wrong way , cause i would end up creating thousands of check + handler files under my conf.d folder
Yeah, create groups of check definition JSON files so you can
hand manage them more efficiently.
Are you guys suggesting to use a single json file with subscription as name ? e.g if i have a subscription for let say webservers which has 10 checks , should i just create a webservers.json file and define all 10 checks in it ?
Its up to you on which approach suits you best. Since you previously mentioned
that you have a reasonably large inventory list + checks, I would resort to automation
to manage even a single checks.json file. In my multi environment deployments, I
group check definitions into two files - one for subscription checks and the other
for standalone checks. The reason is that standalone checks are specific to the
local sensu master and does not need to be globally deployed.
For example, I have a Ansible vars defined as below:
sensu_check_list:
# Begin os:Ubuntu
- { name: "Load",
command: "/usr/lib/nagios/plugins/check_load -w :::load.wload1|8:::,:::load.wload5|8:::,:::load.wload15|6::: -c :::load.cload1|9:::,:::load.cload5|9:::,:::load.cload15|8:::",
subscribers: "os:Ubuntu",
handlers: "logstash,mailer,sms"
}
- { name: "NTP",
command: "/usr/lib/nagios/plugins/check_ntp_time -H 127.0.0.1 -4 -q -w 3 -c 5",
subscribers: "os:Ubuntu",
dependencies: "Load",
occurrences: 30,
interval: 60,
refresh: 3600,
handlers: "logstash,mailer"
}
- { name: "Swap",
command: "/usr/lib/nagios/plugins/check_swap -w :::swap.warn|10%::: -c :::swap.crit|5%:::",
subscribers: "os:swap",
refresh: 1800,
handlers: "logstash,mailer,sms"
}
- { name: "Disk",
command: "/usr/lib/nagios/plugins/check_disk -w 7% -c 5% -e -l -N ext3 -N ext4 -N xfs",
subscribers: "os:Ubuntu",
refresh: 3600,
handlers: "logstash,mailer,sms"
}
And then I use the Ansible Sensu module to manage the service check definition file. All
the checks end up in /etc/sensu/conf.d/checks.json file.
- name: Updating checks in - {{sensu_check_filename | default('/etc/sensu/conf.d/checks.json') }}
sensu_check:
path: "{{ sensu_check_filename | default(‘/etc/sensu/conf.d/checks.json’) }}"
name: "{{ item.name }}"
command: "{{ item.command }}"
interval: "{{ item.interval|default('60') }}"
metric: "{{ item.metric | default('no') }}"
handle: "{{ item.handle | default('yes') }}"
occurrences: "{{ item.occurrences | default(5) }}"
timeout: "{{ item.timeout | default(15) }}"
dependencies: "{{ item.dependencies | default(omit) }}"
subscribers: "admins,{{ item.subscribers|default('none') }}"
handlers: "{{ item.handlers | default(omit) }}"
refresh: "{{ item.refresh | default(1800) }}"
state: "{{ item.state | default('present') }}"
standalone: "{{ item.standalone | default('no') }}"
custom: { ttl: 300 }
aggregate: "{{ item.aggregate | default('no') }}"
subdue_begin: "{{ item.subdue_begin | default(omit) }}"
subdue_end: "{{ item.subdue_end | default(omit) }}"
source: "{{ item.source | default(omit) }}"
low_flap_threshold: "{{ item.low_flap_threshold | default('20') }}"
high_flap_threshold: "{{ item.high_flap_threshold | default('60') }}"
notify:
- restart_sensu_server
with_items: "{{ sensu_check_list|sort }}"
tags:
- sensu_checks
···
On 21-Jan-2017, at 11:49 AM, GautumAni <hi2anirudh@gmail.com> wrote:
—
@shankerbalan
DevOps Consultant