diff options
author | mh <mh@immerda.ch> | 2010-12-12 12:44:01 +0100 |
---|---|---|
committer | mh <mh@immerda.ch> | 2010-12-12 12:44:01 +0100 |
commit | c9c4f5bb895e98e31d84c751a7fcbdae9bf57008 (patch) | |
tree | 662c87ca89e1e7e3905d30160cfaaa13d985fc79 /manifests | |
parent | 2214b80b579e68fcbe329b7a626944af0b3834ad (diff) |
add smtp checks
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/command/smtp.pp | 14 | ||||
-rw-r--r-- | manifests/service/smtp.pp | 52 | ||||
-rw-r--r-- | manifests/service/ssmtp.pp | 34 |
3 files changed, 100 insertions, 0 deletions
diff --git a/manifests/command/smtp.pp b/manifests/command/smtp.pp new file mode 100644 index 0000000..04f8543 --- /dev/null +++ b/manifests/command/smtp.pp @@ -0,0 +1,14 @@ +class nagios::command::smtp { + nagios_command{ + 'check_smtp': + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$'; + 'check_smtp_tls': + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S'; + 'check_smtp_cert': + command_line => '$USER1$/check_smtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; + 'check_ssmtp': + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S'; + 'check_ssmtp_cert': + command_line => '$USER1$/check_ssmtp -H $ARG1$ -p $ARG2$ -S -D $ARG3$'; + } +} diff --git a/manifests/service/smtp.pp b/manifests/service/smtp.pp new file mode 100644 index 0000000..0175bf7 --- /dev/null +++ b/manifests/service/smtp.pp @@ -0,0 +1,52 @@ +# true: +# - true : check tls and plain connect *defualt* +# - false : check plain connection only +# cert_days: +# If tls is used add an additionl check +# to check for validity for cert. +# - 'absent' : do not execute that check +# - INTEGER : Minimum number of days a certificate +# has to be valid. Default: 10 +define nagios::service::smtp( + $ensure = 'present', + $host = 'absent', + $port = '25', + $tls = true, + $cert_days = 10 +){ + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + include nagios::command::smtp + + nagios::service{ + "smtp_${name}_${port}": + ensure => $ensure; + "smtp_tls_${name}_${port}": + ensure => $tls ? { + true => $ensure, + default => 'absent' + }; + "smtp_tls_cert_${name}_${port}": + ensure => $cert_days ? { + 'absent' => 'absent', + default => $ensure + }; + } + + if $ensure != 'absent' { + Nagios::Service["smtp_${name}_${port}"]{ + check_command => "check_smtp!${real_host}!${port}", + } + Nagios::Service["smtp_tls_${name}_${port}"]{ + check_command => "check_smtp_tls!${real_host}!${port}", + } + if $cert_days != 'absent' { + Nagios::Service["smtp_tls_cert_${name}_${port}"]{ + check_command => "check_smtp_cert!${real_host}!${port}!${cert_days}", + } + } + } +} diff --git a/manifests/service/ssmtp.pp b/manifests/service/ssmtp.pp new file mode 100644 index 0000000..2467fe0 --- /dev/null +++ b/manifests/service/ssmtp.pp @@ -0,0 +1,34 @@ +define nagios::service::ssmtp( + $ensure = 'present', + $host = 'absent', + $port = '465', + $cert_days = 10 +){ + $real_host = $host ? { + 'absent' => $name, + default => $host + } + + include nagios::command::smtp + + nagios::service{ + "ssmtp_${name}_${port}": + ensure => $ensure; + "ssmtp_cert_${name}_${port}": + ensure => $cert_days ? { + 'absent' => 'absent', + default => $ensure + }; + } + + if $ensure != 'absent' { + Nagios::Service["ssmtp_${name}_${port}"]{ + check_command => "check_ssmtp!${real_host}!${port}", + } + if $cert_days != 'absent' { + Nagios::Service["ssmtp_cert_${name}_${port}"]{ + check_command => "check_ssmtp_cert!${real_host}!${port}!${cert_days}", + } + } + } +} |