Some cleanup + add Icinga2 API server
This commit is contained in:
parent
64806075b6
commit
93d4e485ae
34
extension.js
34
extension.js
@ -49,6 +49,7 @@ const Convenience = Me.imports.convenience;
|
|||||||
const GenericServer = Me.imports.servers.genericserver.GenericServer;
|
const GenericServer = Me.imports.servers.genericserver.GenericServer;
|
||||||
const Icinga = Me.imports.servers.icinga.Icinga;
|
const Icinga = Me.imports.servers.icinga.Icinga;
|
||||||
const Icinga2 = Me.imports.servers.icinga2.Icinga2;
|
const Icinga2 = Me.imports.servers.icinga2.Icinga2;
|
||||||
|
const Icinga2API = Me.imports.servers.icinga2api.Icinga2API;
|
||||||
const Preferences = Me.imports.prefs;
|
const Preferences = Me.imports.prefs;
|
||||||
|
|
||||||
let settings = Convenience.getSettings(SETTINGS_SCHEMA);
|
let settings = Convenience.getSettings(SETTINGS_SCHEMA);
|
||||||
@ -86,6 +87,8 @@ class Indicator extends PanelMenu.Button {
|
|||||||
this.serverLogic = new Icinga ( this.server );
|
this.serverLogic = new Icinga ( this.server );
|
||||||
else if ( type == 'Icinga2' )
|
else if ( type == 'Icinga2' )
|
||||||
this.serverLogic = new Icinga2 ( this.server );
|
this.serverLogic = new Icinga2 ( this.server );
|
||||||
|
else if ( type == 'Icinga2API' )
|
||||||
|
this.serverLogic = new Icinga2API ( this.server );
|
||||||
|
|
||||||
this.initUI ( );
|
this.initUI ( );
|
||||||
}
|
}
|
||||||
@ -249,8 +252,11 @@ class Indicator extends PanelMenu.Button {
|
|||||||
createBin ( status, text, col ) {
|
createBin ( status, text, col ) {
|
||||||
let _child;
|
let _child;
|
||||||
|
|
||||||
|
if ( ! text )
|
||||||
|
text = '…';
|
||||||
|
|
||||||
if ( ! col [ 'special' ] )
|
if ( ! col [ 'special' ] )
|
||||||
_child = new St.Label({ style_class: 'monito-label', text: text, });
|
_child = new St.Label({ style_class: 'monito-label', text: text.toString(), });
|
||||||
else if ( col.special == 'actions' )
|
else if ( col.special == 'actions' )
|
||||||
{
|
{
|
||||||
_child = new St.BoxLayout ( { x_expand: true,
|
_child = new St.BoxLayout ( { x_expand: true,
|
||||||
@ -291,17 +297,15 @@ class Indicator extends PanelMenu.Button {
|
|||||||
|
|
||||||
if ( row % 2 )
|
if ( row % 2 )
|
||||||
{
|
{
|
||||||
bgColor = this.lightenColor(bgColor, 16);
|
bgColor = this.lightenColor(bgColor, 12);
|
||||||
fgColor = this.lightenColor(fgColor, 16);
|
fgColor = this.lightenColor(fgColor, 12);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bgColor = this.lightenColor(bgColor, -16);
|
bgColor = this.lightenColor(bgColor, -12);
|
||||||
fgColor = this.lightenColor(fgColor, -16);
|
fgColor = this.lightenColor(fgColor, -12);
|
||||||
}
|
}
|
||||||
|
|
||||||
monitoLog ( 'background-color: %s; color: %s' . format ( bgColor, fgColor ) );
|
|
||||||
|
|
||||||
return 'background-color: %s; color: %s' . format ( bgColor, fgColor );
|
return 'background-color: %s; color: %s' . format ( bgColor, fgColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,6 +319,7 @@ class Indicator extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshUI ( ) {
|
refreshUI ( ) {
|
||||||
|
try {
|
||||||
this.initStatus ( );
|
this.initStatus ( );
|
||||||
|
|
||||||
this._box.remove_all_children();
|
this._box.remove_all_children();
|
||||||
@ -350,17 +355,16 @@ class Indicator extends PanelMenu.Button {
|
|||||||
});
|
});
|
||||||
scrollBox.add_actor(tableBox);
|
scrollBox.add_actor(tableBox);
|
||||||
|
|
||||||
for ( let entryCount of this.serverLogic.getProcessedStatus ( ) )
|
let processedStatus = this.serverLogic.getProcessedStatus ( )
|
||||||
|
for ( let entryCount of processedStatus )
|
||||||
_status [ entryCount.status ] ++;
|
_status [ entryCount.status ] ++;
|
||||||
|
|
||||||
let _row = 0;
|
let _row = 0;
|
||||||
for ( let entry of this.serverLogic.getProcessedStatus ( ) )
|
for ( let entry of processedStatus )
|
||||||
{
|
{
|
||||||
if ( ( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) ||
|
if ( ( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) ||
|
||||||
( ( _status [ 'WARNING' ] || _status [ 'CRITICAL' ] || _status [ 'UNKNOWN' ] ) && entry.status != 'OK' ) )
|
( ( _status [ 'WARNING' ] || _status [ 'CRITICAL' ] || _status [ 'UNKNOWN' ] ) && entry.status != 'OK' ) )
|
||||||
{
|
{
|
||||||
monitoLog ( this.account_settings.get_string ( entry.status.toLowerCase() + '-color' ) );
|
|
||||||
|
|
||||||
let _style = this.getStyleForRow ( entry.status.toLowerCase(), _row );
|
let _style = this.getStyleForRow ( entry.status.toLowerCase(), _row );
|
||||||
let infoBox = new St.BoxLayout({
|
let infoBox = new St.BoxLayout({
|
||||||
style_class: 'monito-service-line',
|
style_class: 'monito-service-line',
|
||||||
@ -412,6 +416,12 @@ class Indicator extends PanelMenu.Button {
|
|||||||
this.boxes['unknown'].set_text ( String(_status.UNKNOWN) );
|
this.boxes['unknown'].set_text ( String(_status.UNKNOWN) );
|
||||||
this.boxes['unkown'].get_parent().show ( );
|
this.boxes['unkown'].get_parent().show ( );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch ( e )
|
||||||
|
{
|
||||||
|
monitoLog ( 'RefreshUI error: ' + e );
|
||||||
|
monitoLog ( e.stack );
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -430,8 +440,6 @@ class Indicator extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onSortColumnClick ( button ) {
|
_onSortColumnClick ( button ) {
|
||||||
monitoLog ( 'column >> ' + button.column );
|
|
||||||
|
|
||||||
let _sortOrder = Preferences.getSortOrder ( this.server );
|
let _sortOrder = Preferences.getSortOrder ( this.server );
|
||||||
let _columns = Preferences.getColumns ( this.server );
|
let _columns = Preferences.getColumns ( this.server );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user