summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2011-04-11 12:30:51 -0400
committerMicah Anderson <micah@riseup.net>2011-04-11 12:30:51 -0400
commit7735baa65f0dc37f94d4854fd62c817de94d64f2 (patch)
tree1a4e7a70e27897e08e0e0bb754b4b4d1f2889967 /manifests
parent2f2eb1cb12a57d8a85801086b6fbfce19e9c7a1b (diff)
parentf2df62c9d17d481a3d616a4f2de9496638fadc0a (diff)
Merge commit 'f2df62c9d17d481a3d616a4f2de9496638fadc0a'
Conflicts: manifests/defaults/commands.pp
Diffstat (limited to 'manifests')
-rw-r--r--manifests/apache.pp17
-rw-r--r--manifests/base.pp35
-rw-r--r--manifests/centos.pp2
-rw-r--r--manifests/command/imap_pop3.pp14
-rw-r--r--manifests/command/smtp.pp14
-rw-r--r--manifests/defaults/commands.pp38
-rw-r--r--manifests/defaults/plugins.pp9
-rw-r--r--manifests/irc_bot.pp93
-rw-r--r--manifests/service.pp20
-rw-r--r--manifests/service/http.pp4
-rw-r--r--manifests/service/smtp.pp50
-rw-r--r--manifests/service/ssmtp.pp32
12 files changed, 297 insertions, 31 deletions
diff --git a/manifests/apache.pp b/manifests/apache.pp
index c00b1d9..c560e5b 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,4 +1,21 @@
class nagios::apache inherits ::apache {
$nagios_httpd = 'apache'
include nagios
+
+ case $operatingsystem {
+ 'debian': {
+ file { "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf":
+ ensure => present,
+ source => ["puppet:///site-nagios/configs/${fqdn}/apache2.conf",
+ "puppet:///site-nagios/configs/apache2.conf",
+ "puppet:///nagios/configs/apache2.conf"],
+ }
+
+ apache::config::global { "nagios3.conf":
+ ensure => link,
+ target => "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf"],
+ }
+ }
+ }
}
diff --git a/manifests/base.pp b/manifests/base.pp
index a32edcf..8b96308 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -56,8 +56,8 @@ class nagios::base {
file { 'nagios_private_resource_cfg':
path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg",
- source => [ "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}",
- "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ],
+ source => [ "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}",
+ "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ],
notify => Service['nagios'],
owner => root, group => nagios, mode => '0640';
}
@@ -73,18 +73,19 @@ class nagios::base {
}
Package <<| tag == 'nagios::plugin::deploy::package' |>>
File <<| tag == 'nagios::plugin::deploy::file' |>>
- Nagios_plugin <<||>>
Nagios_command <<||>>
- Nagios_contact <<||>>
Nagios_contactgroup <<||>>
- Nagios_host <<||>>
+ Nagios_contact <<||>>
+ Nagios_hostdependency <<||>>
+ Nagios_hostescalation <<||>>
Nagios_hostextinfo <<||>>
Nagios_hostgroup <<||>>
- Nagios_hostgroupescalation <<||>>
- Nagios_service <<||>>
+ Nagios_host <<||>>
Nagios_servicedependency <<||>>
Nagios_serviceescalation <<||>>
+ Nagios_servicegroup <<||>>
Nagios_serviceextinfo <<||>>
+ Nagios_service <<||>>
Nagios_timeperiod <<||>>
File <<| tag == 'nagios_plugin' |>>
@@ -108,6 +109,14 @@ class nagios::base {
require => File['nagios_confd'],
notify => Service['nagios'],
}
+ Nagios_hostdependency <||> {
+ target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ notify => Service['nagios'],
+ }
+ Nagios_hostescalation <||> {
+ target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ notify => Service['nagios'],
+ }
Nagios_hostextinfo <||> {
target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
require => File['nagios_confd'],
@@ -118,16 +127,15 @@ class nagios::base {
require => File['nagios_confd'],
notify => Service['nagios'],
}
- Nagios_hostgroupescalation <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
- require => File['nagios_confd'],
- notify => Service['nagios'],
- }
Nagios_service <||> {
target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
+ Nagios_servicegroup <||> {
+ target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ notify => Service['nagios'],
+ }
Nagios_servicedependency <||> {
target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
require => File['nagios_confd'],
@@ -153,6 +161,8 @@ class nagios::base {
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg",
+ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
@@ -160,6 +170,7 @@ class nagios::base {
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg",
"${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]:
ensure => file,
replace => false,
diff --git a/manifests/centos.pp b/manifests/centos.pp
index 4d9507b..35379b8 100644
--- a/manifests/centos.pp
+++ b/manifests/centos.pp
@@ -1,6 +1,6 @@
class nagios::centos inherits nagios::base {
- package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http', 'nagios-plugins-ssh', 'nagios-plugins-udp', 'nagios-plugins-tcp', 'nagios-plugins-dig', 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns', 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users', 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap', 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp', 'nagios-plugins-snmp' ]:
+ package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http', 'nagios-plugins-ssh', 'nagios-plugins-tcp', 'nagios-plugins-dig', 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns', 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users', 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap', 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp', 'nagios-plugins-snmp' ]:
ensure => 'present',
notify => Service['nagios'],
}
diff --git a/manifests/command/imap_pop3.pp b/manifests/command/imap_pop3.pp
new file mode 100644
index 0000000..174b09c
--- /dev/null
+++ b/manifests/command/imap_pop3.pp
@@ -0,0 +1,14 @@
+class nagios::command::imap_pop3 {
+ nagios_command{
+ 'check_imap':
+ command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$';
+ 'check_imap_ssl':
+ command_line => '$USER1$/check_imap -H $ARG1$ -p $ARG2$ -S';
+ 'check_pop3':
+ command_line => '$USER1$/check_pop -H $ARG1$ -p $ARG2$';
+ 'check_pop3_ssl':
+ command_line => '$USER1$/check_pop -H $ARG1$ -p $ARG2$ -S';
+ 'check_managesieve':
+ command_line => '$USER1$/check_tcp -H $ARG1$ -p 2000';
+ }
+}
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/defaults/commands.pp b/manifests/defaults/commands.pp
index 20e0d7b..0a7ad4f 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -1,7 +1,9 @@
class nagios::defaults::commands {
- # common service commands
+ include nagios::command::smtp
+ include nagios::command::imap_pop3
+ # common service commands
case $operatingsystem {
debian,ubuntu: {
nagios_command {
@@ -49,8 +51,10 @@ class nagios::defaults::commands {
command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e';
check_ssh:
command_line => '$USER1$/check_ssh $HOSTADDRESS$';
- ssh_port:
+ check_ssh_port:
command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$';
+ check_ssh_port_host:
+ command_line => '$USER1$/check_ssh -p $ARG1$ $ARG2$';
check_http:
command_line => '$USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$';
check_https:
@@ -77,6 +81,8 @@ class nagios::defaults::commands {
command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$';
check_jabber:
command_line => '$USER1$/check_jabber -H $ARG1$';
+ check_git:
+ command_line => '$USER1$/check_tcp -H $ARG1$ -p 9418';
}
}
}
@@ -87,6 +93,16 @@ class nagios::defaults::commands {
# from apache module
http_port:
command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$';
+
+ check_http_port_url_content:
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ check_https_port_url_content:
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -p $ARG2$ -u $ARG3$ -s $ARG4$';
+ check_http_url_content:
+ command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -s $ARG3$';
+ check_https_url_content:
+ command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$';
+
# from bind module
check_dig2:
command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$';
@@ -94,16 +110,28 @@ class nagios::defaults::commands {
# from mysql module
check_mysql_health:
command_line => '$USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$ --database $ARG6$ $ARG7$ $ARG8$';
+
+ # better check_dns
+ check_dns2:
+ command_line => '$USER1$/check_dns2 -c $ARG1$ A $ARG2$';
+
+ # dnsbl checking
+ check_dnsbl:
+ command_line => '$USER1$/check_dnsbl -H $ARG1$';
}
# notification commands
+ $mail_cmd_location = $operatingsystem ? {
+ centos => '/bin/mail',
+ default => '/usr/bin/mail'
+ }
+
nagios_command {
'notify-host-by-email':
- command_line => '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$';
+ command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \\$HOSTNAME\\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$";
'notify-service-by-email':
- command_line => '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$'
-
+ command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$";
}
}
diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp
index 1df8064..18f8161 100644
--- a/manifests/defaults/plugins.pp
+++ b/manifests/defaults/plugins.pp
@@ -1,5 +1,12 @@
class nagios::defaults::plugins {
- nagios::plugin { 'check_mysql_health': source => 'nagios/plugins/check_mysql_health'; }
+ nagios::plugin {
+ 'check_mysql_health':
+ source => 'nagios/plugins/check_mysql_health';
+ 'check_dns2':
+ source => 'nagios/plugins/check_dns2';
+ 'check_dnsbl':
+ source => 'nagios/plugins/check_dnsbl';
+ }
}
diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp
new file mode 100644
index 0000000..961755a
--- /dev/null
+++ b/manifests/irc_bot.pp
@@ -0,0 +1,93 @@
+class nagios::irc_bot {
+ if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) {
+ fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel")
+ }
+
+ $nagios_nsa_socket = $nagios_nsa_socket ? {
+ '' => $operatingsystem ? {
+ centos => '/var/run/nagios-nsa/nsa.socket',
+ default => '/var/run/nagios3/nsa.socket'
+ },
+ default => $nagios_nsa_socket,
+ }
+ $nagios_nsa_pidfile = $nagios_nsa_pidfile ? {
+ '' => $operatingsystem ? {
+ centos => '/var/run/nagios-nsa/nsa.pid',
+ default => '/var/run/nagios3/nsa.pid'
+ },
+ default => $nagios_nsa_pidfile,
+ }
+ $nagios_nsa_port = $nagios_nsa_port ? {
+ '' => '6667',
+ default => $nagios_nsa_port,
+ }
+ $nagios_nsa_realname = $nagios_nsa_realname ? {
+ '' => 'Nagios',
+ default => $nagios_nsa_realname,
+ }
+
+ if (! $nagios_nsa_password) {
+ $nagios_nsa_password = ''
+ }
+
+ file { "/usr/local/bin/riseup-nagios-client.pl":
+ owner => root, group => root, mode => 0755,
+ source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl",
+ }
+ file { "/usr/local/bin/riseup-nagios-server.pl":
+ owner => root, group => root, mode => 0755,
+ source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl",
+ }
+ file { "/etc/init.d/nagios-nsa":
+ owner => root, group => root, mode => 0755,
+ content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"),
+ require => File["/usr/local/bin/riseup-nagios-server.pl"],
+ }
+ file { "/etc/nagios_nsa.cfg":
+ ensure => present,
+ owner => nagios, group => root, mode => 0400,
+ content => template('nagios/irc_bot/nsa.cfg.erb'),
+ }
+
+ package { "libnet-irc-perl":
+ ensure => present,
+ }
+
+ service { "nagios-nsa":
+ ensure => "running",
+ hasstatus => true,
+ require => [File["/etc/nagios_nsa.cfg"],
+ Package["libnet-irc-perl"],
+ Service['nagios'] ],
+ }
+
+ case $operatingsystem {
+ centos: {
+ Package['libnet-irc-perl']{
+ name => 'perl-Net-IRC',
+ }
+ Service['nagios-nsa']{
+ enable => true,
+ }
+ }
+ debian,ubuntu: {
+ exec { "nagios_nsa_init_script":
+ command => "/usr/sbin/update-rc.d nagios-nsa defaults",
+ unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa",
+ require => File["/etc/init.d/nagios-nsa"],
+ before => Service['nagios-nsa'],
+ }
+ }
+ }
+
+ nagios_command {
+ "notify-by-irc":
+ command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"';
+ "host-notify-by-irc":
+ command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"';
+ }
+
+ if $use_shorewall {
+ include shorewall::rules::out::irc
+ }
+}
diff --git a/manifests/service.pp b/manifests/service.pp
index 3e732b7..afc8650 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -10,7 +10,7 @@ define nagios::service (
$notification_period = '',
$notification_options = '',
$contact_groups = '',
- $use = 'absent',
+ $use = 'generic-service',
$service_description = 'absent' )
{
@@ -22,7 +22,12 @@ define nagios::service (
ensure => $ensure,
check_command => $check_command,
host_name => $host_name,
+ use => $use,
notify => Service[nagios],
+ service_description => $service_description ?{
+ 'absent' => $name,
+ default => $service_description
+ }
}
if ($check_period != '') {
@@ -53,17 +58,8 @@ define nagios::service (
Nagios_service["${real_name}"] { notification_options => $notification_options }
}
- if ($use == 'absent') {
- Nagios_service["${real_name}"] { use => 'generic-service' }
- } else {
- Nagios_service["${real_name}"] { use => $use }
+ if ($contact_groups != '') {
+ Nagios_service["${real_name}"] { contact_groups => $contact_groups }
}
-
- if ($service_description == 'absent') {
- Nagios_service["${real_name}"] { service_description => $name }
- } else {
- Nagios_service["${real_name}"] { service_description => $service_description }
- }
-
}
diff --git a/manifests/service/http.pp b/manifests/service/http.pp
index 5fd9890..8fd5059 100644
--- a/manifests/service/http.pp
+++ b/manifests/service/http.pp
@@ -8,6 +8,7 @@ define nagios::service::http(
$check_domain = 'absent',
$check_url = '/',
$check_code = 'OK',
+ $use = 'generic-service',
$ssl_mode = false
){
$real_check_domain = $check_domain ? {
@@ -18,12 +19,14 @@ define nagios::service::http(
'force',true,'only': {
nagios::service{"https_${name}_${check_code}":
ensure => $ensure,
+ use => $use,
check_command => "check_https_url_regex!${real_check_domain}!${check_url}!'${check_code}'",
}
case $ssl_mode {
'force': {
nagios::service{"httprd_${name}":
ensure => $ensure,
+ use => $use,
check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'",
}
}
@@ -34,6 +37,7 @@ define nagios::service::http(
false,true: {
nagios::service{"http_${name}_${check_code}":
ensure => $ensure,
+ use => $use,
check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'",
}
}
diff --git a/manifests/service/smtp.pp b/manifests/service/smtp.pp
new file mode 100644
index 0000000..14237a9
--- /dev/null
+++ b/manifests/service/smtp.pp
@@ -0,0 +1,50 @@
+# 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
+ }
+
+ 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..b05678a
--- /dev/null
+++ b/manifests/service/ssmtp.pp
@@ -0,0 +1,32 @@
+define nagios::service::ssmtp(
+ $ensure = 'present',
+ $host = 'absent',
+ $port = '465',
+ $cert_days = 10
+){
+ $real_host = $host ? {
+ 'absent' => $name,
+ default => $host
+ }
+
+ 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}",
+ }
+ }
+ }
+}