Add more loging + error control
This commit is contained in:
parent
aec2df8b7a
commit
dce089494f
10
extension.js
10
extension.js
@ -274,6 +274,8 @@ class Indicator extends PanelMenu.Button {
|
|||||||
y_align: Clutter.ActorAlign.CENTER,
|
y_align: Clutter.ActorAlign.CENTER,
|
||||||
can_focus: true,
|
can_focus: true,
|
||||||
} );
|
} );
|
||||||
|
_button.service = text;
|
||||||
|
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
|
||||||
_button.child = new St.Icon ( {
|
_button.child = new St.Icon ( {
|
||||||
icon_name: 'view-refresh-symbolic',
|
icon_name: 'view-refresh-symbolic',
|
||||||
icon_size: 16,
|
icon_size: 16,
|
||||||
@ -343,7 +345,7 @@ class Indicator extends PanelMenu.Button {
|
|||||||
{
|
{
|
||||||
infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) );
|
infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) );
|
||||||
}
|
}
|
||||||
infoBox.add_child ( this.createBin ( entry.status, '', column_definitions [ 'actions' ] ) );
|
infoBox.add_child ( this.createBin ( entry.status, entry, column_definitions [ 'actions' ] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,6 +388,12 @@ class Indicator extends PanelMenu.Button {
|
|||||||
this.refreshUI ( );
|
this.refreshUI ( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onRecheckButtonClick ( e )
|
||||||
|
{
|
||||||
|
monitoLog ( JSON.stringify ( e.service ) );
|
||||||
|
this.serverLogic.recheck ( e.service );
|
||||||
|
}
|
||||||
|
|
||||||
_createButton ( icon, text, callback ) {
|
_createButton ( icon, text, callback ) {
|
||||||
let button = new St.Button({
|
let button = new St.Button({
|
||||||
x_align: Clutter.ActorAlign.END,
|
x_align: Clutter.ActorAlign.END,
|
||||||
|
@ -55,17 +55,51 @@ class Icinga extends GenericServer {
|
|||||||
this.authenticateAndSend ( message );
|
this.authenticateAndSend ( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recheck ( entry )
|
||||||
|
{
|
||||||
|
let cmdcgi = this.urlcgi.replace ( /status.cgi/, 'cmd.cgi' );
|
||||||
|
let params = { cmd_typ: '7',
|
||||||
|
cmd_mod: '2',
|
||||||
|
hostservice: '%s^%s'.format ( entry.host_name, entry.service_description.replaceAll ( ' ', '+' ) ),
|
||||||
|
start_time: '2021-11-22%2018:13:48',
|
||||||
|
force_check: 'on',
|
||||||
|
btnSubmit: 'Commit',
|
||||||
|
};
|
||||||
|
let message = Soup.form_request_new_from_hash ( 'POST', cmdcgi, params );
|
||||||
|
log ( JSON.stringify ( params ) );
|
||||||
|
|
||||||
|
// message.request_headers.append ( 'Accept', 'application/json' );
|
||||||
|
this.authenticateAndSend ( message );
|
||||||
|
// cmd_typ: 7
|
||||||
|
// cmd_mod: 2
|
||||||
|
// start_time: '2021-11-22 17:21:12'
|
||||||
|
// hostservice: srv03^servicename (avec encodage + à la place des ' ')
|
||||||
|
// force_check: on
|
||||||
|
}
|
||||||
|
|
||||||
handleMessage ( _httpSession, message )
|
handleMessage ( _httpSession, message )
|
||||||
{
|
{
|
||||||
let _data = super.handleMessage ( _httpSession, message );
|
let _data;
|
||||||
let json = JSON.parse ( _data );
|
try {
|
||||||
|
_data = super.handleMessage ( _httpSession, message );
|
||||||
|
if ( this.error )
|
||||||
|
log ( 'Parent error ' + this.error );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let json = JSON.parse ( _data );
|
||||||
|
this.status = json.status;
|
||||||
|
this.error = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.status = json.status;
|
this.extension.refreshUI ( this );
|
||||||
this.error = null;
|
|
||||||
this.extension.refreshUI ( this );
|
return this.status != { };
|
||||||
|
}
|
||||||
return this.status != { };
|
catch ( e )
|
||||||
|
{
|
||||||
|
log ( e );
|
||||||
|
log ( _data );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,21 +55,26 @@ class Icinga2 extends GenericServer {
|
|||||||
handleMessage ( _httpSession, message )
|
handleMessage ( _httpSession, message )
|
||||||
{
|
{
|
||||||
let _data = super.handleMessage ( _httpSession, message );
|
let _data = super.handleMessage ( _httpSession, message );
|
||||||
let json = JSON.parse ( _data );
|
if ( this.error )
|
||||||
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
|
log ( 'Parent error ' + this.error );
|
||||||
|
else
|
||||||
for ( var entry of json )
|
|
||||||
{
|
{
|
||||||
this.status.service_status.push ( {
|
let json = JSON.parse ( _data );
|
||||||
status: _statuses [ entry.service_state ],
|
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
|
||||||
host_name: entry.host_name,
|
|
||||||
service_display_name: entry.service_display_name,
|
for ( var entry of json )
|
||||||
attempts: entry.service_attempt,
|
{
|
||||||
status_information: entry.service_output,
|
this.status.service_status.push ( {
|
||||||
last_check: new Date ( parseInt(entry.service_last_state_change) * 1000 ) . toString(),
|
status: _statuses [ entry.service_state ],
|
||||||
} );
|
host_name: entry.host_name,
|
||||||
|
service_display_name: entry.service_display_name,
|
||||||
|
attempts: entry.service_attempt,
|
||||||
|
status_information: entry.service_output,
|
||||||
|
last_check: new Date ( parseInt(entry.service_last_state_change) * 1000 ) . toString(),
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
this.error = null;
|
||||||
}
|
}
|
||||||
this.error = null;
|
|
||||||
|
|
||||||
this.extension.refreshUI ( this );
|
this.extension.refreshUI ( this );
|
||||||
return this.status != { };
|
return this.status != { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user