Skip to content

Commit

Permalink
Merge pull request #437 from weeboo/patch-1
Browse files Browse the repository at this point in the history
Number of services retrived limit 999 to 9999
  • Loading branch information
Henri Wahl authored Sep 13, 2017
2 parents 1327b70 + 71fb730 commit 79780ad
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Nagstamon/Servers/Centreon.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class CentreonServer(GenericServer):
centreon_token = None
# To only detect broker once
first_login = True
# limit number of services retrived
limit_services_number = 9999

def init_config(self):
'''
Expand Down Expand Up @@ -502,18 +504,18 @@ def _get_status(self):

# services (unknown, warning or critical?)
if self.centreon_version == 2.7 or self.centreon_version == 2.8:
nagcgiurl_services = self.urls_centreon['xml_services'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'svcpb', 'p':20201, 'nc':0, 'criticality':0, 'statusService':'svcpb', 'sSetOrderInMemory':1, 'sid':self.SID})
nagcgiurl_services = self.urls_centreon['xml_services'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'svcpb', 'p':20201, 'nc':0, 'criticality':0, 'statusService':'svcpb', 'sSetOrderInMemory':1, 'sid':self.SID})
else:
nagcgiurl_services = self.urls_centreon['xml_services'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'svcpb', 'sort_type':'status', 'sid':self.SID})
nagcgiurl_services = self.urls_centreon['xml_services'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'svcpb', 'sort_type':'status', 'sid':self.SID})

# hosts (up or down or unreachable)
# define hosts xml URL, because of inconsistant url
if self.centreon_version == 2.7:
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'hpb', 'p':20202, 'criticality':0, 'statusHost':'hpb', 'sSetOrderInMemory':1, 'sid':self.SID})
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'hpb', 'p':20202, 'criticality':0, 'statusHost':'hpb', 'sSetOrderInMemory':1, 'sid':self.SID})
elif self.centreon_version == 2.8:
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'hpb', 'p':20202, 'criticality':0, 'statusHost':'hpb', 'sSetOrderInMemory':1, 'sid':self.SID})
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'hpb', 'p':20202, 'criticality':0, 'statusHost':'hpb', 'sSetOrderInMemory':1, 'sid':self.SID})
else:
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'hpb', 'sort_type':'status', 'sid':self.SID})
nagcgiurl_hosts = self.urls_centreon['xml_hosts'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'hpb', 'sort_type':'status', 'sid':self.SID})

# hosts - mostly the down ones
# unfortunately the hosts status page has a different structure so
Expand Down Expand Up @@ -645,9 +647,9 @@ def _get_status(self):
if self.centreon_version < 2.8:
# define meta-services xml URL
if self.centreon_version == 2.7:
nagcgiurl_meta_services = self.urls_centreon['xml_meta'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'meta', 'sort_type':'status', 'sid':self.SID})
nagcgiurl_meta_services = self.urls_centreon['xml_meta'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'meta', 'sort_type':'status', 'sid':self.SID})
else:
nagcgiurl_meta_services = self.urls_centreon['xml_meta'] + '?' + urllib.parse.urlencode({'num':0, 'limit':999, 'o':'meta', 'sort_type':'status', 'sid':self.SID})
nagcgiurl_meta_services = self.urls_centreon['xml_meta'] + '?' + urllib.parse.urlencode({'num':0, 'limit':self.limit_services_number, 'o':'meta', 'sort_type':'status', 'sid':self.SID})

# retrive meta-services xml STATUS
result_meta = self.FetchURL(nagcgiurl_meta_services, giveback='xml')
Expand Down

0 comments on commit 79780ad

Please sign in to comment.