Add more loging + error control
This commit is contained in:
parent
76319c11d5
commit
d533f08e44
10
extension.js
10
extension.js
@ -274,6 +274,8 @@ class Indicator extends PanelMenu.Button {
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
can_focus: true,
|
||||
} );
|
||||
_button.service = text;
|
||||
_button.connect ( 'clicked', Lang.bind ( this, this._onRecheckButtonClick ) );
|
||||
_button.child = new St.Icon ( {
|
||||
icon_name: 'view-refresh-symbolic',
|
||||
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, '', 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 ( );
|
||||
}
|
||||
|
||||
_onRecheckButtonClick ( e )
|
||||
{
|
||||
monitoLog ( JSON.stringify ( e.service ) );
|
||||
this.serverLogic.recheck ( e.service );
|
||||
}
|
||||
|
||||
_createButton ( icon, text, callback ) {
|
||||
let button = new St.Button({
|
||||
x_align: Clutter.ActorAlign.END,
|
||||
|
@ -55,17 +55,51 @@ class Icinga extends GenericServer {
|
||||
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 )
|
||||
{
|
||||
let _data = super.handleMessage ( _httpSession, message );
|
||||
let json = JSON.parse ( _data );
|
||||
let _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.error = null;
|
||||
this.extension.refreshUI ( this );
|
||||
|
||||
return this.status != { };
|
||||
this.extension.refreshUI ( this );
|
||||
|
||||
return this.status != { };
|
||||
}
|
||||
catch ( e )
|
||||
{
|
||||
log ( e );
|
||||
log ( _data );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,21 +55,26 @@ class Icinga2 extends GenericServer {
|
||||
handleMessage ( _httpSession, message )
|
||||
{
|
||||
let _data = super.handleMessage ( _httpSession, message );
|
||||
let json = JSON.parse ( _data );
|
||||
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
|
||||
|
||||
for ( var entry of json )
|
||||
if ( this.error )
|
||||
log ( 'Parent error ' + this.error );
|
||||
else
|
||||
{
|
||||
this.status.service_status.push ( {
|
||||
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(),
|
||||
} );
|
||||
let json = JSON.parse ( _data );
|
||||
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
|
||||
|
||||
for ( var entry of json )
|
||||
{
|
||||
this.status.service_status.push ( {
|
||||
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 );
|
||||
return this.status != { };
|
||||
|
Loading…
x
Reference in New Issue
Block a user