Better error handling
This commit is contained in:
parent
6230b03cff
commit
4ce284d782
@ -245,6 +245,12 @@ class Indicator extends PanelMenu.Button {
|
||||
|
||||
this._box.remove_all_children();
|
||||
|
||||
if ( serverLogic.error )
|
||||
{
|
||||
this._box.add_child ( new St.Label ( { style_class: 'monito-network-error', text: serverLogic.error } ) );
|
||||
return;
|
||||
}
|
||||
|
||||
let headerBox = new St.BoxLayout({
|
||||
style_class: 'monito-service-line',
|
||||
hover: true,
|
||||
|
@ -69,17 +69,21 @@ class Icinga {
|
||||
{
|
||||
log ( '>>> error: ' + message.reason_phrase );
|
||||
Main.notify ( 'Monito: ' + name, message.reason_phrase );
|
||||
return;
|
||||
this.status = null;
|
||||
this.error = message.reason_phrase;
|
||||
}
|
||||
else
|
||||
{
|
||||
let json = JSON.parse(message.response_body.data);
|
||||
this.status = json.status;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
let json = JSON.parse(message.response_body.data);
|
||||
this.status = json.status;
|
||||
|
||||
extension.refreshUI ( this );
|
||||
}
|
||||
)
|
||||
);
|
||||
return true;
|
||||
return this.status != null;
|
||||
}
|
||||
catch (e) {
|
||||
Main.notify(_('Zbeu!'));
|
||||
|
@ -74,35 +74,38 @@ class Icinga2 {
|
||||
|
||||
handleMessage ( _httpSession, message )
|
||||
{
|
||||
this.status = { };
|
||||
this.status.service_status = [ ];
|
||||
|
||||
if ( message.status_code != Soup.Status.OK )
|
||||
{
|
||||
log ( '>>> error: ' + message.reason_phrase );
|
||||
Main.notifyError ( 'Monito: ' + this.name,
|
||||
'URL: ' + this.urlcgi + "\n" +
|
||||
message.status_code + ': ' + message.reason_phrase );
|
||||
return;
|
||||
this.error = message.reason_phrase;
|
||||
}
|
||||
|
||||
let json = JSON.parse(message.response_body.data);
|
||||
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
|
||||
|
||||
this.status = { };
|
||||
this.status.service_status = [ ];
|
||||
|
||||
for ( var entry of json )
|
||||
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(message.response_body.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.extension.refreshUI ( this );
|
||||
return true;
|
||||
return this.status != { };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,11 @@
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.monito-network-error {
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.monito-button-icon {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
|
Loading…
Reference in New Issue
Block a user