I'm fed up so I thought I'd turn to you guys and see if you can stop
me from setting fire to my office.  I'm trying to add
nagios::service{} statements to various modules throughout my
configuration, but ONLY if the node in question uses a define of
nagios::target.  This is so I don't break nagios constantly by adding
apache on unmonitored hosts.

In nodes.pp: (this is hlslinutil1, the nagios server itself)

    # Must be before other modules!
    nagios::target{ "": notification_period => "24x7" }
    include nagios

    defaultclass{$environment:}
    include commvault
    include puppetmaster
    include splunk::client
    include cobbler

nagios/manifests/defines.pp:

define nagios::target(
    $notification_period = "24x7"
){
    nagios::host {$fqdn: notification_period => "$notification_period"}

    nagios::service::ping{$fqdn:}

    nagios::service { "ssh-$hostname":
        host_name => "$fqdn",
        check_command => 'check_ssh',
        service_description => "ssh-$hostname",
    }
}

apache/manifests/init.pp:

    if defined(Nagios::Target[""]) {
           if $apachelistening80 == "true" {
                nagios::service { "http-$hostname":
                        host_name => "$fqdn",
                        service_description => "http on $hostname",
                        check_command =>
"check_http_url!$fqdn!/serveralive.html";
                }
           }

           if $apachelistening443 == "true" {
                nagios::service { "https-$hostname":
                        host_name => "$fqdn",
                        service_description => "https on $hostname",
                        check_command =>
"check_https_url!$fqdn!/serveralive.html";
                }
           }
        }

-------------

The nagios module includes apache, so what I wanted to see was:

nagios::target is called.
nagios is included.
apache is included -> does the check, sees nagios::target already
called, adds the two nagios::service statements.

What I see is:

no monitoring on apache at all.

I have tried dozens of ways around this but I just cannot work out
what the hell is wrong.  I can't do defined(Nagios_host) (adds apache
monitoring for all hosts), I can't do defined(Nagios_host["$fqdn"])
(doesn't work at all again) and I'm out of clever ideas.  It's almost
as if it checks the defined() against the puppetmaster rather than the
client.  Someone rescue me?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to