[PATCH 1/1] types like nagios_service need to be non-unique in puppet as they are in nagios

5 views
Skip to first unread message

John Ferlito

unread,
Nov 21, 2008, 9:33:10 PM11/21/08
to puppe...@googlegroups.com
In Nagios it is possible to have multiple service checks with the same
service_description. eg I could have an check with a service_description
of 'SSH' for multiple hosts. So in puppet we can't use it as a unique
name for the resource. This patch modifies the code to use $name as the
unique name. For some types eg command_name $name ends up in the config
and thus we can tell which puppet resources match to which nagios ones.
For other types like service there is no direct mapping from $name to a
nagios attibute. So we use a custom attribute called _puppet_name.

Signed-off-by: John Ferlito <jo...@inodes.org>
---
CHANGELOG | 4 +++
lib/puppet/external/nagios/base.rb | 41 +++++++++++++++++++++---------------
2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 4cf39b4..6e73d7a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,8 @@
0.24.x
+ Fixed #1496 - nagios_servicedependency needs a unique host_name?
+
+ Fixed #1420 - nagios_serviceescalation not allowing host_name more than one type
+
Fixed #1711 - fileserver test fails due to incorrect mocking

Fixed #1751 - Mac OS X DirectoryService nameservice provider support for
diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb
index 25c6895..bc3f9e1 100755
--- a/lib/puppet/external/nagios/base.rb
+++ b/lib/puppet/external/nagios/base.rb
@@ -196,6 +196,9 @@ class Nagios::Base
args.each { |param,value|
self[param] = value
}
+ if @namevar == :_puppet_name
+ self['_puppet_name'] = self['name']
+ end
end

# Handle parameters like attributes.
@@ -363,23 +366,26 @@ class Nagios::Base
end

newtype :hostescalation do
- setparameters :name, :first_notification, :last_notification,
+ setparameters :first_notification, :last_notification,
:notification_interval, :contact_groups,
- :escalation_options, :register, :hostgroup_name
- setnamevar :name
+ :escalation_options, :register, :hostgroup_name,
+ :_puppet_name
+
+ setnamevar :_puppet_name
end

newtype :hostgroupescalation do
auxiliary = true
- setparameters :hostgroup_name, :first_notification, :last_notification,
- :contact_groups, :notification_interval
+ setparameters :first_notification, :last_notification,
+ :contact_groups, :notification_interval,
+ :_puppet_name

- setnamevar :hostgroup_name
+ setnamevar :_puppet_name
end

newtype :service do
attach :host => :host_name
- setparameters :name, :active_checks_enabled, :passive_checks_enabled,
+ setparameters :active_checks_enabled, :passive_checks_enabled,
:parallelize_check, :obsess_over_service, :check_freshness,
:notifications_enabled, :event_handler_enabled,
:flap_detection_enabled, :process_perf_data,
@@ -388,11 +394,12 @@ class Nagios::Base
:normal_check_interval, :retry_check_interval, :contact_groups,
:notification_interval, :notification_period, :notification_options,
:service_description, :host_name, :freshness_threshold,
- :check_command, :hostgroup_name, :event_handler, :servicegroups, :host
+ :check_command, :hostgroup_name, :event_handler, :servicegroups, :host,
+ :_puppet_name

suppress :host_name

- setnamevar :service_description
+ setnamevar :_puppet_name
end

newtype :servicedependency do
@@ -400,30 +407,30 @@ class Nagios::Base
setparameters :host_name, :service_description, :dependent_host_name,
:dependent_service_description, :execution_failure_criteria,
:notification_failure_criteria, :hostgroup_name,
- :dependent_hostgroup_name
+ :dependent_hostgroup_name, :_puppet_name

- setnamevar :host_name
+ setnamevar :_puppet_name
end

newtype :serviceescalation do
setparameters :host_name, :service_description, :first_notification,
- :last_notification, :contact_groups, :notification_interval, :hostgroup_name
+ :last_notification, :contact_groups, :notification_interval, :hostgroup_name,
+ :_puppet_name

- setnamevar :host_name
+ setnamevar :_puppet_name
end

newtype :servicegroup do
setparameters :servicegroup_name, :alias
-
- setnamevar :servicegroup_name
end

newtype :serviceextinfo do
auxiliary = true

- setparameters :host_name, :service_description, :icon_image, :icon_image_alt
+ setparameters :host_name, :service_description, :icon_image, :icon_image_alt,
+ :_puppet_name

- setnamevar :host_name
+ setnamevar :_puppet_name
end

newtype :timeperiod do
--
1.5.6.3

Francois Deppierraz

unread,
Nov 25, 2008, 11:05:14 AM11/25/08
to puppe...@googlegroups.com
John Ferlito wrote:

> So we use a custom attribute called _puppet_name.

+1

Thanks John, this patch is really helpful.

François

Luke Kanies

unread,
Nov 26, 2008, 12:37:34 AM11/26/08
to puppe...@googlegroups.com
This is essentially a patch against Naginator[1]; can you provide it
against that code, and I'll apply and then copy over to Puppet?

Otherwise, I'm not much in a position to assess this patch, since it's
against code that I've barely modified since I wrote it a couple of
years ago.

Am I right in understanding that others are already using this patch
and it's fixing things for them?

1 - http://projects.reductivelabs.com/projects/show/naginator
--
Always behave like a duck - keep calm and unruffled on the surface but
paddle like the devil underneath. -- Jacob Braude
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com

John Ferlito

unread,
Nov 26, 2008, 4:13:29 AM11/26/08
to puppe...@googlegroups.com
Luke,

On Tue, Nov 25, 2008 at 11:37:34PM -0600, Luke Kanies wrote:
>
> This is essentially a patch against Naginator[1]; can you provide it
> against that code, and I'll apply and then copy over to Puppet?

Which git repository should I use? I tried

git://git.reductivelabs.com/naginator.git

but it looks like it's missing patches that are in the puppet tree.

Cheers,

John

--
John
Blog http://www.inodes.org/blog
OLPC Friends http//olpcfriends.org

Mathieu Bornoz

unread,
Nov 26, 2008, 6:56:28 AM11/26/08
to puppe...@googlegroups.com
Hi Luke,

> Am I right in understanding that others are already using this patch
> and it's fixing things for them?

I tested this patch yesterday and I confirm that it's very useful,
thanks John !

Speaking about Nagios: these last days I spent time to test builtin
Nagios types and I noticed that it's not possible to use the concept of
object inheritance. I sent an email on "Puppet Users" group and I'm very
interested to have your opinion on it.

http://groups.google.com/group/puppet-users/browse_thread/thread/684d0eb328aaa7b5/600c20d3ccc4a6b2?hl=en&lnk=gst&q=nagios#600c20d3ccc4a6b2

Thanks in advance
Mathieu

Luke Kanies

unread,
Nov 26, 2008, 9:58:32 AM11/26/08
to puppe...@googlegroups.com


Any missing parameters are merely an artifact of when I wrote
Naginator (a few years ago), and I haven't assessed whether there have
been schema changes or anything. Either this is a new parameter, or
it's one I couldn't find evidence of when I wrote Naginator.

--
The only thing that saves us from the bureaucracy is inefficiency. An
efficient bureaucracy is the greatest threat to liberty.
--Eugene McCarthy

Luke Kanies

unread,
Nov 26, 2008, 9:59:20 AM11/26/08
to puppe...@googlegroups.com
On Nov 26, 2008, at 3:13 AM, John Ferlito wrote:

>
> Luke,
>
> On Tue, Nov 25, 2008 at 11:37:34PM -0600, Luke Kanies wrote:
>>
>> This is essentially a patch against Naginator[1]; can you provide it
>> against that code, and I'll apply and then copy over to Puppet?
>
> Which git repository should I use? I tried
>
> git://git.reductivelabs.com/naginator.git
>
> but it looks like it's missing patches that are in the puppet tree.

Yeah, that's the repo.

What patches are missing? That's no good.

--
The easiest way for your children to learn about money is for you
not to have any. -- Katharine Whitehorn

John Ferlito

unread,
Nov 26, 2008, 7:12:13 PM11/26/08
to puppe...@googlegroups.com
On Wed, Nov 26, 2008 at 08:59:20AM -0600, Luke Kanies wrote:
> > Which git repository should I use? I tried
> >
> > git://git.reductivelabs.com/naginator.git
> >
> > but it looks like it's missing patches that are in the puppet tree.
>
> Yeah, that's the repo.
>
> What patches are missing? That's no good.

See my other email with patches against naginator tree. First patch
brings it up to date with puppet 0.24.x second has my fixes.

Luke Kanies

unread,
Nov 29, 2008, 1:19:06 AM11/29/08
to puppe...@googlegroups.com
On Nov 26, 2008, at 6:12 PM, John Ferlito wrote:

>
> On Wed, Nov 26, 2008 at 08:59:20AM -0600, Luke Kanies wrote:
>>> Which git repository should I use? I tried
>>>
>>> git://git.reductivelabs.com/naginator.git
>>>
>>> but it looks like it's missing patches that are in the puppet tree.
>>
>> Yeah, that's the repo.
>>
>> What patches are missing? That's no good.
>
> See my other email with patches against naginator tree. First patch
> brings it up to date with puppet 0.24.x second has my fixes.

Thanks. I'll apply them.

--
To have a right to do a thing is not at all the same as to be right
in doing it. -- G. K. Chesterton

Reply all
Reply to author
Forward
0 new messages