diff --git a/manifests/init.pp b/manifests/init.pp index 298150f..0661be7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -91,3 +91,14 @@ require => File['/etc/monit/conf.d'], } } + +define monit::sshdcheck ($sshd_port=22, $sshd_ips=[]) { + file { "/etc/monit/conf.d/$name": + mode => 600, + owner => root, + group => root, + content => template("/etc/puppet/modules/monit/templates/sshd.erb"), + notify => Service['monit'], + require => File['/etc/monit/conf.d'], + } +} diff --git a/templates/sshd.erb b/templates/sshd.erb new file mode 100644 index 0000000..2db9201 --- /dev/null +++ b/templates/sshd.erb @@ -0,0 +1,10 @@ +# +# automatically generated by puppet for <%= fqdn %>, DO NOT MODIFY! +# +check process sshd with pidfile /var/run/sshd.pid + start program = "/etc/init.d/ssh start" + stop program = "/etc/init.d/ssh stop" + if failed port <%= sshd_port %> protocol ssh then restart + <% sshd_ips.each do |sshd_ip| -%> + if failed host <%= sshd_ip %> port <%= sshd_port %> protocol ssh for 5 cycle then restart + <%- end %>