Re: [Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-22 Thread Felix Frank
If it's an acceptable compromise, you could do this:

@@my_nagios_host { "host1": hostrgoup => "cloud-app", ... }

@@my_nagios_host { "host2": hostrgoup => "cloud-app", ... }

define my_nagios_host($hostgroup, ...) {
  nagios_host { $name: ... }
  realize(Nagios_hostgroup[$hostgroup])
}

All your hostgroups must be declared in the nagios host manifest like

@nagios_hostgroup { 'cloud-app':
alias => "Application Servers",
}

HTH,
Felix

On 02/20/2013 02:27 AM, Sans wrote:
> @@nagios_hostgroup { 'cloud-app':
> alias => "Application Servers",
> }

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




Re: [Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-20 Thread Peter Brown
On 20 February 2013 21:39, Sans  wrote:

> Hi Pete, how you doing?
>
>
>
>> You will get duplication if you declare a nagioshost_group with the same
>> name on more than one node...
>> I think you may be missing the point of nagios_hostgroup. It is for
>> declaring a hostgroup in nagios not setting the nagios hostgroup for a node.
>>
>
> Yes, I know that I'll get duplication error for obvious reason and that's
> the whole reason for asking this Q. I know what the "hostgroup" is for
> (using Nagios for a while now) and I'm not trying to setting up hostgroup
> for a node. Perhaps I wasn't clear with my question.
>

Ok sorry for my confusion.


>> I am guessing you are trying to add a node to a hostgroup?
>> You will need to add a hostgroups parameter to your nagios_host
>> declaration and set the hostgroup for the node there.
>>
>
> No - I'm not trying to "add a  node to hostgroup" but I was trying to
> figure out a way to declare a "hostgroup" only after at least one  member
> of that particular comes online.  Suppose, I've three nodes - N1, N2, N3
> and two  hostgroups - HG1 and HG2. N1 (which is Nagios-server) is being in
> HG1 and N2 & N3 in HG2.
>

Yep I get you now.
You could possibly check if it's defined before re defining it.
If it wasn't an exported resource it might be easier but not sure how to
achieve that when realizing exported resources. Tags may help.

I just put my hostgroup definitons in a separate class and then set the
hostgroups on each host.
I do end up with empty ones that way though.


>
>
>> I am also reasonably sure you can have empty hostgroups in nagios...
>>
>
> Yes you can (overlooked that point, really) until a service
> (nagios_service type) is defined. I think, my actual question would be, how
> can I query if a host with certain name (property) is up and only include
> that service if the node count is at least one or more. I think I can
> export some sort of resource from a given host and collect it on the master
> (my Nagios server is co-located with Puppet master)? Any idea what might be
> the best possible way of doing that? cheers!!
>

You may have to resort to querying puppetdb if you use it or your config
store database (puppetdb is easier to query from what I have seen).
I haven't needed to do anything like that but I have seen mention of at
least one tool for doing puppetdb queries posted on the list.

Good luck!

Pete.

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

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




Re: [Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-20 Thread Sirtaj Singh Kang

On 2/20/2013 5:09 PM, Sans wrote:
[snip]

Yes you can (overlooked that point, really) until a service
(nagios_service type) is defined. I think, my actual question would be,
how can I query if a host with certain name (property) is up and only
include that service if the node count is at least one or more.


I use a very bad hack to do this. I have a define that looks like this 
(simplified):


define nagios::server::plugin ($inject_class) {
include $inject_class
}


The nagios server listens for exported resources of this type:

Nagios::Server::Plugin<<| |>>


If a class needs to be defined on the nagios server by a node, it simply
calls

@@nagios::server::plugin { ...:
inject_class => ""
}

and the server will pick it up and realize it. As long as the plugin is 
a class and not a define (and requires no params), there will be no harm 
with multiple nodes broadcasting the same plugin; it will still be 
realized only once.


-Taj.

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




Re: [Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-20 Thread Sans
Hi Pete, how you doing?


> You will get duplication if you declare a nagioshost_group with the same 
> name on more than one node...
> I think you may be missing the point of nagios_hostgroup. It is for 
> declaring a hostgroup in nagios not setting the nagios hostgroup for a node.
>

Yes, I know that I'll get duplication error for obvious reason and that's 
the whole reason for asking this Q. I know what the "hostgroup" is for 
(using Nagios for a while now) and I'm not trying to setting up hostgroup 
for a node. Perhaps I wasn't clear with my question.
 


> I am guessing you are trying to add a node to a hostgroup?
> You will need to add a hostgroups parameter to your nagios_host 
> declaration and set the hostgroup for the node there.
>

No - I'm not trying to "add a  node to hostgroup" but I was trying to 
figure out a way to declare a "hostgroup" only after at least one  member 
of that particular comes online.  Suppose, I've three nodes - N1, N2, N3 
and two  hostgroups - HG1 and HG2. N1 (which is Nagios-server) is being in 
HG1 and N2 & N3 in HG2.  


> I am also reasonably sure you can have empty hostgroups in nagios...
>

Yes you can (overlooked that point, really) until a service (nagios_service 
type) is defined. I think, my actual question would be, how can I query if 
a host with certain name (property) is up and only include that service if 
the node count is at least one or more. I think I can export some sort of 
resource from a given host and collect it on the master (my Nagios server 
is co-located with Puppet master)? Any idea what might be the best possible 
way of doing that? cheers!!


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




Re: [Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-19 Thread Peter Brown
Hi,

You will get duplication if you declare a nagioshost_group with the same
name on more than one node...
I think you may be missing the point of nagios_hostgroup. It is for
declaring a hostgroup in nagios not setting the nagios hostgroup for a node.

I am guessing you are trying to add a node to a hostgroup?
You will need to add a hostgroups parameter to your nagios_host declaration
and set the hostgroup for the node there.

I am also reasonably sure you can have empty hostgroups in nagios...

if you want a kickstart there are a few monitoring modules on puppet forge.
(I wrote some that may help)


On 20 February 2013 11:27, Sans  wrote:

> Is there any way to create the Nagios hostgroup only when the first (or
> at least one) member of that hostgroup comes on line?
>
> I tried with Puppet Storeconfigs: The client node exports the
> nagios_hostgroup resource:
>
>> @@nagios_hostgroup { 'cloud-app':
>> alias => "Application Servers",}
>>
>>
>
> and the server node collects it:
>
>> Nagios_hostgroup <<| |>> { notify => Service['nagios'] }
>>
>>
>
> It works for the first node but get "duplicate definition" error as soon
> as the second node of that hostgroup comes online and try to export the
> very same resource.
>
> Specifying hostgroup in the Nagios server manifest (and exporting the
> nagios_host instead) initially solve this issue but the biggest problem
> with this approach is: in a multi hostgroup configuration, Nagios won't
> start until atleast one member from the each hostgroup comes on-line. This
> leaves us with a huge inconvenience. As all the hostgroups are created
> during the Nagios server configuration, Nagios refuses to start until the
> first member of the last hostgroup is configured. For us, it takes up to 30
> mins. Is there any workaround/fix for this issue? Any pointer would be
> greatly appreciated. Cheers!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To post to this group, send email to puppet-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




[Puppet Users] autometically create nagios_hostgroup only when a member of a group comes up

2013-02-19 Thread Sans
 

Is there any way to create the Nagios hostgroup only when the first (or at 
least one) member of that hostgroup comes on line?

I tried with Puppet Storeconfigs: The client node exports the 
nagios_hostgroup resource:

> @@nagios_hostgroup { 'cloud-app':
> alias => "Application Servers",} 
>
>  

and the server node collects it:

> Nagios_hostgroup <<| |>> { notify => Service['nagios'] }
>
>  

It works for the first node but get "duplicate definition" error as soon as 
the second node of that hostgroup comes online and try to export the very 
same resource. 

Specifying hostgroup in the Nagios server manifest (and exporting the 
nagios_host instead) initially solve this issue but the biggest problem 
with this approach is: in a multi hostgroup configuration, Nagios won't 
start until atleast one member from the each hostgroup comes on-line. This 
leaves us with a huge inconvenience. As all the hostgroups are created 
during the Nagios server configuration, Nagios refuses to start until the 
first member of the last hostgroup is configured. For us, it takes up to 30 
mins. Is there any workaround/fix for this issue? Any pointer would be 
greatly appreciated. Cheers!! 

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