Skip to content

Commit c0e2ad5

Browse files
committed
fix ssv verify for CentreonAPI.py
1 parent 9d94709 commit c0e2ad5

File tree

6 files changed

+13
-43
lines changed

6 files changed

+13
-43
lines changed

Nagstamon/Config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class AppInfo(object):
125125
contains app information previously located in GUI.py
126126
"""
127127
NAME = 'Nagstamon'
128-
VERSION = '3.9-20220807'
128+
VERSION = '3.9-20220814'
129129
WEBSITE = 'https://nagstamon.de'
130130
COPYRIGHT = '©2008-2022 Henri Wahl et al.'
131131
COMMENTS = 'Nagios status monitor for your desktop'

Nagstamon/QUI/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,8 @@ def finish_worker_thread(self):
20912091
"""
20922092
attempt to shutdown thread cleanly
20932093
"""
2094+
# stop debugging
2095+
self.worker.debug_loop_looping = False
20942096
# tell thread to quit
20952097
self.worker_thread.quit()
20962098
# wait until thread is really stopped
@@ -2157,7 +2159,7 @@ def debug_loop(self):
21572159
time.sleep(1)
21582160

21592161
# unset looping
2160-
self.debug_mode_looping = False
2162+
self.debug_loop_looping = False
21612163
# close file if any
21622164
if self.debug_file is not None:
21632165
self.close_debug_file()
@@ -7008,7 +7010,7 @@ def exit():
70087010
# save configuration
70097011
conf.SaveConfig()
70107012

7011-
# hide statuswindow first ro avoid lag when waiting for finished threads
7013+
# hide statuswindow first to avoid lag when waiting for finished threads
70127014
statuswindow.hide()
70137015

70147016
# stop statuswindow workers
@@ -7020,16 +7022,6 @@ def exit():
70207022
server_vbox.table.worker.finish.emit()
70217023

70227024
APP.exit()
7023-
# # delete all windows
7024-
# for dialog in dialogs.__dict__.values():
7025-
# try:
7026-
# dialog.window().destroy()
7027-
# except:
7028-
# dialog.window.destroy()
7029-
# statuswindow.destroy()
7030-
#
7031-
# bye bye
7032-
# APP.instance().quit()
70337025

70347026

70357027
def check_servers():

Nagstamon/Servers/Centreon/CentreonAPI.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1919

20+
import traceback
2021
import urllib.request
2122
import urllib.parse
2223
import urllib.error
23-
import socket
2424
import sys
25-
import re
26-
import copy
2725
# API V2
2826
import pprint
2927
import json
@@ -103,12 +101,11 @@ def init_config(self):
103101

104102

105103
def init_HTTP(self):
104+
GenericServer.init_HTTP(self)
106105
if self.session is None:
107-
GenericServer.init_HTTP(self)
108106
self.session.headers.update({'Content-Type': 'application/json'})
109107
self.token = self.get_token().result
110108

111-
112109
def define_url(self):
113110
urls_centreon_api_v2 = {
114111
'resources': self.monitor_cgi_url + '/api/' + self.restapi_version + '/monitoring/resources',
@@ -175,7 +172,6 @@ def get_token(self):
175172
return Result(result=token)
176173

177174
except:
178-
import traceback
179175
traceback.print_exc(file=sys.stdout)
180176
result, error = self.Error(sys.exc_info())
181177
return Result(result=result, error=error)
@@ -207,7 +203,6 @@ def GetHost(self, host):
207203
return Result(result=fqdn)
208204

209205
except:
210-
import traceback
211206
traceback.print_exc(file=sys.stdout)
212207
# set checking flag back to False
213208
self.isChecking = False
@@ -241,13 +236,6 @@ def get_host_and_service_id(self, host, service=''):
241236
return host_id
242237

243238
except:
244-
import traceback
245-
246-
247-
248-
249-
250-
251239
traceback.print_exc(file=sys.stdout)
252240
# set checking flag back to False
253241
self.isChecking = False
@@ -284,7 +272,6 @@ def get_host_and_service_id(self, host, service=''):
284272
return host_id,service_id
285273

286274
except:
287-
import traceback
288275
traceback.print_exc(file=sys.stdout)
289276
# set checking flag back to False
290277
self.isChecking = False
@@ -365,7 +352,6 @@ def _get_status(self):
365352
self.Debug(server='[' + self.get_name() + ']', debug='Host indexed : ' + new_host)
366353

367354
except:
368-
import traceback
369355
traceback.print_exc(file=sys.stdout)
370356
# set checking flag back to False
371357
self.isChecking = False
@@ -427,7 +413,6 @@ def _get_status(self):
427413
self.new_hosts[new_host].services[new_service].criticality = alerts["severity_level"]
428414

429415
except:
430-
import traceback
431416
traceback.print_exc(file=sys.stdout)
432417
# set checking flag back to False
433418
self.isChecking = False
@@ -524,7 +509,6 @@ def _set_acknowledge(self, host, service, author, comment, sticky, notify, persi
524509
debug="Set Acks, status code : " + str(status_code))
525510

526511
except:
527-
import traceback
528512
traceback.print_exc(file=sys.stdout)
529513
# set checking flag back to False
530514
self.isChecking = False
@@ -598,7 +582,6 @@ def _set_recheck(self, host, service):
598582
debug="Reckeck on Host ("+host+") / Service ("+service+"), status code : " + str(status_code))
599583

600584
except:
601-
import traceback
602585
traceback.print_exc(file=sys.stdout)
603586
# set checking flag back to False
604587
self.isChecking = False
@@ -699,7 +682,6 @@ def _set_downtime(self, host, service, author, comment, fixed, start_time, end_t
699682

700683

701684
except:
702-
import traceback
703685
traceback.print_exc(file=sys.stdout)
704686
# set checking flag back to False
705687
self.isChecking = False
@@ -715,7 +697,7 @@ def check_session(self):
715697
# self.init_config()
716698
try:
717699
if conf.debug_mode == True:
718-
self.Debug(server='[' + self.get_name() + ']', debug='Check-session, the token will be deleted if it has not been used for more than one hour. Current Token = ' + self.token )
700+
self.Debug(server='[' + self.get_name() + ']', debug='Check-session, the token will be deleted if it has not been used for more than one hour. Current Token = ' + str(self.token) )
719701

720702
cgi_data = {'limit':'0'}
721703
self.session = requests.Session()
@@ -725,7 +707,8 @@ def check_session(self):
725707
# Get en empty service list, to check the status of the current token
726708
# This request must be done in a GET, so just encode the parameters and fetch
727709
result = self.FetchURL(self.urls_centreon['resources'] + '?' + urllib.parse.urlencode(cgi_data), giveback="raw")
728-
710+
if result.status_code == 403:
711+
self.get_token()
729712
data = json.loads(result.result)
730713
error = result.error
731714
status_code = result.status_code
@@ -743,7 +726,6 @@ def check_session(self):
743726
self.Debug(server='[' + self.get_name() + ']', debug='Check-session, session renewed')
744727

745728
except:
746-
import traceback
747729
traceback.print_exc(file=sys.stdout)
748730
result, error = self.Error(sys.exc_info())
749731
return Result(result=result, error=error)

Nagstamon/Servers/Centreon/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, **kwds):
3939
data = json.loads(versions_raw.result)
4040
ver_major = int(data["web"]["major"])
4141
ver_minor = int(data["web"]["minor"])
42-
# API V2 is usable only after 21.04 (not tested), ressources endpoit is buggy in 20.10
42+
# API V2 is usable only after 21.04 (not tested), ressources endpoint is buggy in 20.10
4343
if ver_major >= 21:
4444
self.Debug(server='[' + self.get_name() + ']', debug='Loading class API, Centreon version : ' + str(ver_major) + '.' + str(ver_minor))
4545
from .CentreonAPI import CentreonServer as CentreonServerReal

Nagstamon/Servers/Generic.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,6 @@ def FetchURL(self, url, giveback='obj', cgi_data=None, no_auth=False, multipart=
14841484

14851485
except Exception:
14861486
if conf.debug_mode:
1487-
#traceback.print_exc(file=sys.stdout)
1488-
#self.Debug(server=self.get_name(), debug=' '.join(sys.exc_info()))
14891487
self.Error(sys.exc_info())
14901488
result, error = self.Error(sys.exc_info())
14911489
if error.startswith('requests.exceptions.SSLError:'):
@@ -1516,9 +1514,7 @@ def FetchURL(self, url, giveback='obj', cgi_data=None, no_auth=False, multipart=
15161514
status_code=response.status_code)
15171515

15181516
except Exception:
1519-
#traceback.print_exc(file=sys.stdout)
15201517
self.Error(sys.exc_info())
1521-
15221518
result, error = self.Error(sys.exc_info())
15231519
return Result(result=result, error=error, status_code=response.status_code)
15241520

build/debian/changelog

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
nagstamon (3.9-20220807) unstable; urgency=low
1+
nagstamon (3.9-20220814) unstable; urgency=low
22
* New upstream
33

4-
-- Henri Wahl <[email protected]> Sun, 26 Jun 2022 08:00:00 +0100
4+
-- Henri Wahl <[email protected]> Sun, 14 Aug 2022 08:00:00 +0100
55

66
nagstamon (3.8.0) stable; urgency=low
77
* New upstream

0 commit comments

Comments
 (0)