Skip to content

Commit

Permalink
EXEC action: add support for UID, GID and REPEAT EVERY N CYCLES.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhattan committed May 28, 2020
1 parent fa66d25 commit 5481c61
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,22 @@ monit::checks :
http headers: '[host: www.example.com]'
action: restart

custom-script :
type : program
config :
path : /path/to/custom/pingcheck.sh
tests :
- type : status
operator : '!='
value : 0
tolerance :
cycles : 2
action : exec
exec : sudo /sbin/reboot
custom-script:
type: program
config:
path: /path/to/custom/pingcheck.sh
tests:
- type: status
operator: '!='
value: 0
tolerance:
cycles: 2
action: exec
exec: sudo /sbin/reboot
# uid, git and repeat_every are optional.
uid: root
gid: root
repeat_every: 1
```
There's a bunch of examples for configuring real services across Debian and
Expand Down
9 changes: 9 additions & 0 deletions lib/puppet/functions/monit_validate_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def validate(check_type, tests)
if test['action'] == 'EXEC'
raise Puppet::ParseError, exception_prefix + 'missing command for exec action' unless test.key? 'exec'
test['action'] = "EXEC \"#{test['exec']}\""
if test.key? 'uid'
test['action'] += " AS UID #{test['uid']}"
end
if test.key? 'gid'
test['action'] += " AS GID #{test['gid']}"
end
if test.key? 'repeat_every'
test['action'] += " REPEAT EVERY #{test['repeat_every']} CYCLES"
end
end
else
test['action'] = 'ALERT'
Expand Down

0 comments on commit 5481c61

Please sign in to comment.