Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json filters and daemon check configuration added. #1

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions monit/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
- source: salt://monit/files/monitrc
- template: jinja
- makedirs: True
- mode: '0700'
- context:
config_includes: {{ monit.config_includes }}
http_access: {{ monit.http_access }}
config_includes: {{ monit.config_includes | json }}
http_access: {{ monit.http_access | json }}
daemon_check: {{ monit.daemon_check }}

{#- This is the mail alert configuration #}
{% if monit.mail_alert is defined %}
Expand All @@ -18,7 +20,7 @@
- template: jinja
- makedirs: True
- context:
mail_alert: {{ monit.mail_alert }}
mail_alert: {{ monit.mail_alert | json }}
{% endif %}

{#- This is populated by modules configuration
Expand All @@ -28,4 +30,4 @@
- source: salt://monit/files/modules
- template: jinja
- context:
modules: {{ monit.modules }}
modules: {{ monit.modules | json }}
1 change: 1 addition & 0 deletions monit/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ monit:
pkg: monit
config: '/etc/monit/monitrc'
config_includes: '/etc/monit/conf.d'
daemon_check: 10
service:
name: monit
http_access:
Expand Down
6 changes: 3 additions & 3 deletions monit/files/mail
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
set alert {{email}} ON { invalid, timeout, resource, size, timestamp }
{% endfor %}

{%- if mail_alert.account.email and mail_alert.account.password -%}
set mail-format { from: {{mail_alert.account.email}} }
{%- if mail_alert.account.email is defined and mail_alert.account.password is defined -%}
set mail-format { from: {{mail_alert.get('send_as', mail_alert.account.email)}} }
{%- endif -%}

{%- if mail_alert.account.server and mail_alert.account.port %}
set mailserver {{mail_alert.account.server}} port {{mail_alert.account.port}}
{%- if mail_alert.account.email and mail_alert.account.password %}
{%- if mail_alert.account.email is defined and mail_alert.account.password is defined %}
username "{{mail_alert.account.email}}" password "{{mail_alert.account.password}}"
using tlsv1
{%- endif %}
Expand Down
12 changes: 8 additions & 4 deletions monit/files/modules
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
-#}
{#- module = nginx_init,
module_v = {'process': {'with': {'pidfile':... #}
{%- for module, module_v in modules.iteritems() -%}
{%- for module, module_v in modules.items() -%}

{#- mod_name = process
mod_name_v = {'custom': {'name': 'nginx'}, 'with': {'pidfile':... #}
{%- for mod_name, mod_name_v in module_v.iteritems() -%}
{%- for mod_name, mod_name_v in module_v.items() -%}

{#- if {'custom': {'name':... exist, this is our 'name'.
otherwise 'name' is the value of 'module' #}
Expand All @@ -38,16 +38,20 @@

{#- kind = with, config and if
kind_v = {'pidfile':'/var/run/pid'}, {'group': 'www', etc. #}
{%- for kind, kind_v in mod_name_v.iteritems() -%}
{%- for kind, kind_v in mod_name_v.items() -%}

{#- element = pidfile, group, start, stop, etc.
element_v = /var/run/nginx.pid, www, "/etc/init.d/nginx start", etc. #}
{%- for element, element_v in kind_v.iteritems() -%}
{%- for element, element_v in kind_v.items() -%}

{#- if it has 'pidfile' or 'path' then this is the 'check' line #}
{%- if 'pidfile' in kind_v or 'path' in kind_v %}
check {{ mod_name }} {{ name }} with {{ element }} {{ element_v }}
{%- endif -%}
{% endfor %}
{% endfor %}
{%- for kind, kind_v in mod_name_v.items() -%}
{%- for element, element_v in kind_v.items() -%}

{#- 'config' is the lines containing 'group', 'start program', etc #}
{%- if 'config' in kind -%}
Expand Down
2 changes: 1 addition & 1 deletion monit/files/monitrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set daemon 10
set daemon {{ daemon_check }}

set httpd port {{ http_access.port }} and
use address {{ http_access.bind }}
Expand Down
1 change: 1 addition & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ monit:
port: 587
email: [email protected]
password: p@ssw0rd;)
send_as: [email protected]
users:
- [email protected]
- [email protected]
Expand Down