Skip to content

Commit 6843461

Browse files
author
Henri Wahl
committed
ignore BadStatusLine errors as they soon vanish to avoid misleading ERROR status
1 parent 3b92d7d commit 6843461

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.swp
66
nagstamon.conf/
77
.directory
8+
.metadata/

Nagstamon/QUI/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,7 @@ def get_status(self):
30283028
self.change_label_status.emit('Refreshing...', '')
30293029
# get status from server instance
30303030
status = self.server.GetStatus()
3031-
3031+
30323032
# all is OK if no error info came back
30333033
if self.server.status_description == '' and\
30343034
self.server.status_code < 400 and\

Nagstamon/Servers/Generic.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,26 @@ def GetStatus(self, output=None):
807807
else:
808808
return Result()
809809

810-
if status.error != '' or status.status_code > 400:
810+
# some monitor server seem to have a problem with too short intervals
811+
# and sometimes send a bad status line which would result in a misleading
812+
# ERROR display - it seems safe to ignore theese errors
813+
# see https://github.com/HenriWahl/Nagstamon/issues/207
814+
if 'BadStatusLine' in self.status_description:
815+
self.status_description = ''
816+
self.isChecking = False
817+
return Result(result=self.status,
818+
error=self.status_description,
819+
status_code=self.status_code)
820+
821+
if (self.status_description != '' or
822+
self.status_code > 400):
811823
# ask for password if authorization failed
812-
if 'HTTP Error 401' in status.error or \
813-
'HTTP Error 403' in status.error or \
814-
'HTTP Error 500' in status.error or \
815-
'bad session id' in status.error.lower() or \
816-
'login failed' in status.error.lower() or \
817-
status.status_code in self.STATUS_CODES_NO_AUTH:
824+
if 'HTTP Error 401' in self.status_description or \
825+
'HTTP Error 403' in self.status_description or \
826+
'HTTP Error 500' in self.status_description or \
827+
'bad session id' in self.status_description.lower() or \
828+
'login failed' in self.status_description.lower() or \
829+
self.status_code in self.STATUS_CODES_NO_AUTH:
818830
if conf.servers[self.name].enabled == True:
819831
# needed to get valid credentials
820832
self.refresh_authentication = True
@@ -832,7 +844,7 @@ def GetStatus(self, output=None):
832844
error=self.status_description,
833845
status_code=self.status_code)
834846

835-
# no rew authentication needed
847+
# no new authentication needed
836848
self.refresh_authentication = False
837849

838850
# this part has been before in GUI.RefreshDisplay() - wrong place, here it needs to be reset

0 commit comments

Comments
 (0)