summaryrefslogtreecommitdiff
path: root/manifests/service
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/service')
-rw-r--r--manifests/service/gpgkey.pp47
-rw-r--r--manifests/service/horde_login.pp18
-rw-r--r--manifests/service/http.pp76
3 files changed, 107 insertions, 34 deletions
diff --git a/manifests/service/gpgkey.pp b/manifests/service/gpgkey.pp
new file mode 100644
index 0000000..f04352a
--- /dev/null
+++ b/manifests/service/gpgkey.pp
@@ -0,0 +1,47 @@
+# define a gpgkey to be watched
+define nagios::service::gpgkey(
+ $ensure = 'present',
+ $warning = '14',
+ $key_info = undef,
+){
+ validate_slength($name,40,40)
+ require ::nagios::plugins::gpg
+ $gpg_home = $nagios::plugins::gpg::gpg_home
+ $gpg_cmd = "gpg --homedir ${gpg_home}"
+
+ exec{"manage_key_${name}":
+ user => nagios,
+ group => nagios,
+ }
+ nagios::service{
+ "check_gpg_${name}":
+ ensure => $ensure;
+ }
+
+ if $ensure == 'present' {
+ Exec["manage_key_${name}"]{
+ command => "${gpg_cmd} --keyserver hkps://hkps.pool.sks-keyservers.net --keyserver-options ca-cert-file=${gpg_home}/sks-keyservers.netCA.pem --recv-keys ${name}",
+ unless => "${gpg_cmd} --list-keys ${name}",
+ before => Nagios::Service["check_gpg_${name}"],
+ }
+
+ Nagios::Service["check_gpg_${name}"]{
+ check_command => "check_gpg!${warning}!${name}",
+ }
+ if $key_info {
+ Nagios::Service["check_gpg_${name}"]{
+ service_description => "Keyfingerprint: ${name} - Info: ${key_info}",
+ }
+ } else {
+ Nagios::Service["check_gpg_${name}"]{
+ service_description => "Keyfingerprint: ${name}",
+ }
+ }
+ } else {
+ Exec["manage_key_${name}"]{
+ command => "${gpg_cmd} --batch --delete-key ${name}",
+ onlyif => "${gpg_cmd} --list-keys ${name}",
+ require => Nagios::Service["check_gpg_${name}"],
+ }
+ }
+}
diff --git a/manifests/service/horde_login.pp b/manifests/service/horde_login.pp
new file mode 100644
index 0000000..6cab59e
--- /dev/null
+++ b/manifests/service/horde_login.pp
@@ -0,0 +1,18 @@
+# a horde login check
+define nagios::service::horde_login(
+ $password,
+ $url,
+ $username = $name,
+ $ensure = 'present',
+){
+ nagios::service{
+ "horde_${name}":
+ ensure => $ensure;
+ }
+
+ if $ensure != 'absent' {
+ Nagios::Service["horde_${name}"]{
+ check_command => "check_horde_login!${url}!${username}!${password}",
+ }
+ }
+}
diff --git a/manifests/service/http.pp b/manifests/service/http.pp
index ef63abb..b80c140 100644
--- a/manifests/service/http.pp
+++ b/manifests/service/http.pp
@@ -4,43 +4,51 @@
# - force: http is permanent redirect to https
# - only: check only https
define nagios::service::http(
- $ensure = present,
- $check_domain = 'absent',
- $port = '80',
- $check_url = '/',
- $check_code = 'OK',
- $use = 'generic-service',
- $ssl_mode = false
+ $ensure = present,
+ $check_domain = 'absent',
+ $port = '80',
+ $check_url = '/',
+ $check_code = '200,301,302',
+ $use = 'generic-service',
+ $ssl_mode = false
){
- $real_check_domain = $check_domain ? {
- 'absent' => $name,
- default => $check_domain
+ $real_check_domain = $check_domain ? {
+ 'absent' => $name,
+ default => $check_domain
+ }
+ if is_hash($check_code) {
+ $check_code_hash = $check_code
+ } else {
+ $check_code_hash = {
+ http => $check_code,
+ https => $check_code,
}
- case $ssl_mode {
- '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}!${port}!${check_url}!'301'",
- }
- }
- }
+ }
+ case $ssl_mode {
+ 'force',true,'only': {
+ nagios::service{"https_${name}":
+ ensure => $ensure,
+ use => $use,
+ check_command => "check_https_url_regex!${real_check_domain}!${check_url}!'${check_code_hash[https]}'",
+ }
+ case $ssl_mode {
+ 'force': {
+ nagios::service{"http_${name}":
+ ensure => $ensure,
+ use => $use,
+ check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'301'",
+ }
}
+ }
}
- case $ssl_mode {
- false,true: {
- nagios::service{"http_${name}_${check_code}":
- ensure => $ensure,
- use => $use,
- check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'${check_code}'",
- }
- }
+ }
+ case $ssl_mode {
+ false,true: {
+ nagios::service{"http_${name}":
+ ensure => $ensure,
+ use => $use,
+ check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'${check_code_hash[http]}'",
+ }
}
+ }
}