summaryrefslogtreecommitdiff
path: root/manifests/service
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/service')
-rw-r--r--manifests/service/mysql.pp83
-rw-r--r--manifests/service/smtp.pp50
-rw-r--r--manifests/service/ssmtp.pp32
3 files changed, 123 insertions, 42 deletions
diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp
index ca2ae15..d501f06 100644
--- a/manifests/service/mysql.pp
+++ b/manifests/service/mysql.pp
@@ -1,48 +1,47 @@
-# Checks a mysql instance via tcp or socket
+# Checks a mysql instance via tcp or socket
define nagios::service::mysql(
- $ensure = present,
- $check_hostname = 'absent',
- $check_port = '3306',
- $check_username = 'nagios',
- $check_password = '',
- $check_database = 'absent',
- $check_mode = 'tcp'
-){
- if ($check_hostname == 'absent') {
- fail("Please specify a hostname, ip address or socket to check a mysql instance.")
- }
-
- case $check_mode {
- 'tcp': {
- if ($check_hostname == 'localhost') {
- $real_check_hostname = '127.0.0.1'
- }
- else {
- $real_check_hostname = $check_hostname
- }
- }
- default: {
- if ($check_hostname == '127.0.0.1') {
- $real_check_hostname = 'localhost'
- }
- else {
- $real_check_hostname = $check_hostname
- }
- }
- }
+ $ensure = present,
+ $check_host = 'absent',
+ $check_port = '3306',
+ $check_username = 'nagios',
+ $check_password = $nagios_mysql_password,
+ $check_database = 'information_schema',
+ $check_warning = undef,
+ $check_critical = undef,
+ $check_health_mode = $name,
+ $check_name = undef,
+ $check_name2 = undef,
+ $check_regexp = undef,
+ $check_units = undef,
+ $check_mode = 'tcp' )
+{
- if ($check_database == 'absent') {
- nagios::service { 'mysql':
- ensure => $ensure,
- check_command => "check_mysql!${real_check_hostname}!${check_port}!${check_username}!${check_password}",
- }
+ if ($check_host == 'absent') {
+ fail("Please specify a hostname, ip address or socket to check a mysql instance.")
+ }
+
+ case $check_mode {
+ 'tcp': {
+ if ($check_host == 'localhost') {
+ $real_check_host = '127.0.0.1'
+ }
+ else {
+ $real_check_host = $check_host
+ }
}
- else {
- nagios::service { "mysql_${check_database}":
- ensure => $ensure,
- check_command => "check_mysql_db!${real_check_hostname}!${check_port}!${check_username}!${check_password}!${check_database}",
- }
+ default: {
+ if ($check_host == '127.0.0.1') {
+ $real_check_host = 'localhost'
+ }
+ else {
+ $real_check_host = $check_host
+ }
}
-
+ }
+
+ nagios::service { "mysql_health_${name}":
+ ensure => $ensure,
+ check_command => "check_mysql_health!${check_host}!${check_port}!${check_username}!${check_password}!${name}!${check_database}",
+ }
}
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}",
+ }
+ }
+ }
+}