diff --git a/README.md b/README.md
index e1d52dc..b1f0ccf 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ inside of the gnome-shell panel (this could not be developed).
Things I plan to add at some point or another:
* Buttons to operate on services à la nagstamon (recheck, connect via SSH, etc.)
- * Filters to hide services (acked, handled, ...)
+ * Filters to hide services (handled, scheduled downtime, host down, ...)
* Support for other (as in free speech) monitoring servers
* Choose which columns are shown in services result
@@ -38,3 +38,4 @@ Things I will be unlikely to add unless a patch is provided:
* Support for broken HTTPS certs
* Notification for new alerts
+ * Display list of down hosts (I am not interested in host monitoring but services)
diff --git a/extension.js b/extension.js
index 69779c5..2fcdf6a 100644
--- a/extension.js
+++ b/extension.js
@@ -59,6 +59,7 @@ const column_definitions = {
status: { label: _('Status'), width: 50, expand: false, },
host_name: { label: _('Host name'), width: 300, expand: false, },
service_display_name: { label: _('Service'), width: 300, expand: false, },
+ has_been_acknowledged: { label: _('Ack'), width: 50, expand: false, align: Clutter.ActorAlign.CENTER, style: 'font-weight:bold;' },
last_check: { label: _('Last check'), width: 200, expand: false, type: 'date' },
attempts: { label: _('Attempts'), width: 50, expand: false, },
status_information: { label: _('Information'), width: 600, expand: true, },
@@ -253,11 +254,14 @@ class Indicator extends PanelMenu.Button {
createBin ( status, text, col ) {
let _child;
- if ( ! text )
+ if ( text === undefined )
text = '…';
if ( ! col [ 'special' ] )
- _child = new St.Label({ style_class: 'monito-label', text: text.toString(), });
+ _child = new St.Label ( { style_class: 'monito-label',
+ text: text.toString(),
+ x_align: ( col.align ? col.align : Clutter.ActorAlign.START ),
+ style: ( col.style ? col.style : '' ) } );
else if ( col.special == 'actions' && this.serverLogic.canRecheck )
{
_child = new St.BoxLayout ( { x_expand: false,
@@ -388,6 +392,13 @@ class Indicator extends PanelMenu.Button {
else if ( _col == 'status_information' && this.account_settings.get_string ( 'status-info-match' ) )
entry [ _col ] = entry [ _col ] . replace ( new RegExp ( this.account_settings.get_string ( 'status-info-match' ), 'i' ),
this.account_settings.get_string ( 'status-info-replace' ) );
+ else if ( _col == 'has_been_acknowledged' )
+ {
+ if ( entry [ _col ] )
+ entry [ _col ] = '✔'; // … or ✅🗹 ?
+ else
+ entry [ _col ] = '';
+ }
infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) );
}
diff --git a/prefs.js b/prefs.js
index a873679..9916e0f 100644
--- a/prefs.js
+++ b/prefs.js
@@ -57,6 +57,7 @@ const prefs = [
{ type: Gtk.ColorButton, category: 'Colors', label: _('Warning color'), key: 'warning-fg', align: Gtk.Align.START },
{ type: Gtk.ColorButton, category: 'Colors', label: _('Critical color'), key: 'critical-fg', align: Gtk.Align.START },
{ type: Gtk.ColorButton, category: 'Colors', label: _('Unknown color'), key: 'unknown-fg', align: Gtk.Align.START },
+ { type: Gtk.Switch, category: 'Filters', label: _('Do not display acknowledged services'), key: 'acknowledged-filter-out', align: Gtk.Align.START },
{ type: Gtk.Entry, category: 'Filters', label: _('Only display hosts matching'), key: 'host-grep' },
{ type: Gtk.Entry, category: 'Filters', label: _('Only display services matching'), key: 'service-grep' },
{ type: Gtk.Entry, category: 'Filters', label: _('Only display status info matching'), key: 'status-info-grep' },
@@ -325,6 +326,15 @@ function activateAccountRow ( ) {
Gio.SettingsBindFlags.DEFAULT
);
}
+ else if ( prefEntry.type == Gtk.Switch )
+ {
+ _account_settings.bind (
+ prefEntry.key,
+ this.prefWidgets[prefEntry.key],
+ 'active',
+ Gio.SettingsBindFlags.DEFAULT
+ );
+ }
else if ( prefEntry.type == Gtk.ColorButton )
{
let _color = new Gdk.RGBA ( );
diff --git a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml
index 361727e..3bcc7ff 100644
--- a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml
@@ -110,7 +110,7 @@
- ['status','host_name','service_display_name','last_check','attempts','status_information']
+ ['status','host_name','service_display_name','has_been_acknowledged','last_check','attempts','status_information']
@@ -129,6 +129,10 @@
''
+
+ false
+
+
''
diff --git a/servers/genericserver.js b/servers/genericserver.js
index 416bae6..8b8e4ec 100644
--- a/servers/genericserver.js
+++ b/servers/genericserver.js
@@ -169,14 +169,22 @@ class GenericServer {
for ( var _filter of filters )
_filter.value = this._settings.get_string ( _filter.prefKey );
- entries: for ( var i = 0 ; i < status.length ; i ++ )
+ entries:
+ for ( var i = 0 ; i < status.length ; i ++ )
{
+ if ( status[i]['has_been_acknowledged'] && this._settings.get_boolean ( 'acknowledged-filter-out' ) )
+ {
+ log ( '> ACKED:%s ' . format ( status[i]['service_display_name'] ) );
+ status.splice ( i, 1 );
+ i --; // This has been removed, so get back one step.
+ continue entries;
+ }
+
for ( var _filter of filters )
{
if ( _filter['value'] &&
( status[i][_filter['entryKey']].match ( new RegExp ( _filter['value'], 'i' ) ) <= 0 ) == _filter['positive'] )
{
-// log ( '> NOT MATCHING: %s =~ %s == %s ' . format ( status[i][_filter['entryKey']], _filter['value'], _filter['positive'] ) );
status.splice ( i, 1 );
i --; // This has been removed, so get back one step.
continue entries;
diff --git a/servers/icinga2.js b/servers/icinga2.js
index 05d2930..8ccc37b 100644
--- a/servers/icinga2.js
+++ b/servers/icinga2.js
@@ -71,6 +71,7 @@ class Icinga2 extends GenericServer {
host_name: entry.host_name,
service_display_name: entry.service_display_name,
attempts: entry.service_attempt,
+ has_been_acknowledged: parseInt(entry.service_acknowledged),
status_information: entry.service_output,
last_check: new Date ( parseInt(entry.service_last_state_change) * 1000 ) . toString(),
} );
diff --git a/servers/icinga2api.js b/servers/icinga2api.js
index b7ea4c1..b68be7b 100644
--- a/servers/icinga2api.js
+++ b/servers/icinga2api.js
@@ -89,6 +89,7 @@ class Icinga2API extends GenericServer {
status: _statuses [ entry.attrs.state ],
host_name: entry.attrs.host_name,
service_display_name: entry.attrs.display_name,
+ has_been_acknowledged: parseInt(entry.attrs.acknowledgement),
attempts: '%d/%d'.format(entry.attrs.check_attempt,entry.attrs.max_check_attempts),
status_information: entry.attrs.last_check_result.output,
last_check: new Date ( entry.attrs.last_state_change * 1000 ) . toString(),