Skip to content

Commit

Permalink
Merge pull request #991 from fermino/master
Browse files Browse the repository at this point in the history
Thruk: add disabled_backends field to filter out thruk backends (#219)
  • Loading branch information
HenriWahl authored Nov 30, 2023
2 parents 424584e + 3297bd5 commit e6da242
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Nagstamon/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ def __init__(self):
self.notification_filter = "user.name=*"
self.notification_lookback = "30 minutes"

# Thruk
self.disabled_backends = ""

class Action(object):
"""
class for custom actions, which whill be thrown into one config dictionary like the servers
Expand Down
2 changes: 2 additions & 0 deletions Nagstamon/QUI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5821,6 +5821,8 @@ def __init__(self, dialog):
self.window.label_notification_filter: ['IcingaDBWebNotifications'],
self.window.input_lineedit_notification_lookback: ['IcingaDBWebNotifications'],
self.window.label_notification_lookback: ['IcingaDBWebNotifications'],
self.window.label_disabled_backends: ['Thruk'],
self.window.input_lineedit_disabled_backends: ['Thruk'],
}

# to be used when selecting authentication method Kerberos
Expand Down
3 changes: 3 additions & 0 deletions Nagstamon/Servers/Generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ def __init__(self, **kwds):
self.notification_filter = None
self.notification_lookback = None

# Thruk
self.disabled_backends = None

def init_config(self):
'''
set URLs for CGI - they are static and there is no need to set them with every cycle
Expand Down
3 changes: 3 additions & 0 deletions Nagstamon/Servers/Thruk.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def login(self):
self.refresh_authentication = True
return Result(result=None, error="Login failed")

if self.disabled_backends is not None:
self.session.cookies.set('thruk_backends', '&'.join((f"{v}=2" for v in self.disabled_backends.split(','))))
print(self.session.cookies.get('thruk_backends'))

def open_monitor(self, host, service=''):
'''
Expand Down
3 changes: 3 additions & 0 deletions Nagstamon/Servers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def create_server(server=None):
new_server.map_to_critical = server.map_to_critical
new_server.map_to_down = server.map_to_down

# Thruk
new_server.disabled_backends = server.disabled_backends

# server's individual preparations for HTTP connections (for example cookie creation)
# is done in GetStatus() method of monitor
if server.enabled is True:
Expand Down
24 changes: 22 additions & 2 deletions Nagstamon/resources/qui/settings_server.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_disabled_backends">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Disabled backends:</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<widget class="QLineEdit" name="input_lineedit_monitor_url">
<property name="inputMask">
Expand All @@ -77,7 +90,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QLineEdit" name="input_lineedit_username">
<property name="text">
<string>username</string>
Expand All @@ -94,7 +107,7 @@
<item row="1" column="2">
<widget class="QComboBox" name="input_combobox_type"/>
</item>
<item row="8" column="2">
<item row="9" column="2">
<widget class="QLineEdit" name="input_lineedit_password">
<property name="text">
<string>1234567890</string>
Expand All @@ -104,6 +117,13 @@
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QLineEdit" name="input_lineedit_disabled_backends">
<property name="text">
<string>1234567890</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QCheckBox" name="input_checkbox_use_proxy">
<property name="text">
Expand Down

0 comments on commit e6da242

Please sign in to comment.