[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:22:06 UTC 2012
The following commit has been merged in the debian/master branch:
commit 1ad2d867a312ad9385e803e89442659e3694f323
Author: Naparuba <naparuba at gmail.com>
Date: Tue Feb 21 14:30:47 2012 +0100
Fix : set display_name to service description if not set.
diff --git a/shinken/objects/host.py b/shinken/objects/host.py
index f62c6bb..562e825 100644
--- a/shinken/objects/host.py
+++ b/shinken/objects/host.py
@@ -66,7 +66,7 @@ class Host(SchedulingItem):
properties.update({
'host_name': StringProp(fill_brok=['full_status', 'check_result', 'next_schedule']),
'alias': StringProp(fill_brok=['full_status']),
- 'display_name': StringProp(default='none', fill_brok=['full_status']),
+ 'display_name': StringProp(default='', fill_brok=['full_status']),
'address': StringProp(fill_brok=['full_status']),
'parents': ListProp(brok_transformation=to_hostnames_list, default='', fill_brok=['full_status']),
'hostgroups': StringProp(brok_transformation=to_list_string_of_names, default='', fill_brok=['full_status']),
diff --git a/shinken/objects/item.py b/shinken/objects/item.py
index 0728ba5..7833f0c 100644
--- a/shinken/objects/item.py
+++ b/shinken/objects/item.py
@@ -723,10 +723,12 @@ class Items(object):
# Then look for individual ok
for i in self:
- # Alias hook
+ # Alias and display_name hook hook
prop_name = getattr(self.__class__, 'name_property', None)
if prop_name and not hasattr(i, 'alias') and hasattr(i, prop_name):
setattr(i, 'alias', getattr(i, prop_name))
+ if prop_name and getattr(i, 'display_name', '') == '' and hasattr(i, prop_name):
+ setattr(i, 'display_name', getattr(i, prop_name))
# Now other checks
if not i.is_correct():
diff --git a/shinken/objects/service.py b/shinken/objects/service.py
index 55495c6..a4bf0e2 100644
--- a/shinken/objects/service.py
+++ b/shinken/objects/service.py
@@ -383,6 +383,10 @@ class Service(SchedulingItem):
if self.notifications_enabled and self.contacts == []:
logger.log("Warning The service '%s' in the host '%s' do not have contacts nor contact_groups in '%s'" % (desc, hname, source))
+ # Set display_name if need
+ if getattr(self, 'display_name', '') == '':
+ self.display_name = getattr(self, 'service_description', '')
+
if not hasattr(self, 'check_command'):
logger.log("%s : I've got no check_command" % self.get_name())
state = False
diff --git a/test/test_services.py b/test/test_services.py
index 70c43f0..2764236 100755
--- a/test/test_services.py
+++ b/test/test_services.py
@@ -105,6 +105,17 @@ class TestService(ShinkenTest):
self.assert_(svc.state == ori_state)
self.assert_(svc.state_id == ori_state_id)
+
+
+ # Look for display name setting
+ def test_display_name(self):
+ svc = self.get_svc()
+ print 'Display name', svc.display_name, 'toto'
+ print 'Full name', svc.get_full_name()
+ self.assert_(svc.display_name == 'test_ok_0')
+
+
+
def test_set_state_from_exit_status(self):
svc = self.get_svc()
#First OK
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list