Created
November 22, 2014 20:46
-
-
Save tzz/bf05e2805fdaea6d466b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body common control | |
{ | |
bundlesequence => { holder, test_monit_mustache("ssh") }; | |
} | |
bundle common holder | |
{ | |
classes: | |
"holderclass" expression => "any"; # will be global | |
vars: | |
"monit_rules_ssh" data => parsejson('{ | |
"method": "process", | |
"name": "sshd", | |
"toprule": "pidfile /var/run/sshd.pid", | |
"start": "service sshd start", | |
"stop": "service sshd stop", | |
"rules": [ | |
"if failed port 22 protocol ssh then restart", | |
"if 2 restarts within 10 cycles then alert", | |
"if 5 restarts within 10 cycles then timeout" | |
] | |
}'); | |
} | |
bundle agent test_monit_mustache(service) | |
{ | |
files: | |
"/tmp/monit.$(service).txt" | |
create => "true", | |
edit_template => "$(this.promise_filename).mustache", | |
template_data => mergedata("holder.monit_rules_$(service)"), | |
template_method => "mustache"; | |
} | |
--------------- | |
Mustache template: | |
## Template for a monit service | |
check {{method}} {{name}} with {{toprule}} | |
start program = {{start}} | |
stop program = {{stop}} | |
{{#rules}} | |
{{.}} | |
{{/rules}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment