Skip to content

Instantly share code, notes, and snippets.

@tzz
Created November 22, 2014 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzz/bf05e2805fdaea6d466b to your computer and use it in GitHub Desktop.
Save tzz/bf05e2805fdaea6d466b to your computer and use it in GitHub Desktop.
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