Kinda implement Icinga2 ... but why the f... is the last_checked value not present in the json ???

This commit is contained in:
Benjamin Drieu 2021-11-15 16:09:48 +01:00
parent 332e51b1bf
commit 1f95af7137
1 changed files with 18 additions and 3 deletions

View File

@ -72,10 +72,25 @@ class Icinga2 {
(this, function(_httpSession, message)
{
// TODO format this in the manner of icinga1
log ( '>>> ' + message.response_body.data );
// log ( '>>> ' + message.response_body.data );
let json = JSON.parse(message.response_body.data);
this.status = json.status;
let _statuses = [ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ];
this.status = { };
this.status.service_status = [ ];
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)).toString(),
} );
log ( 'date ' + new Date(parseInt(entry.service_last_state_change)) );
}
extension.refreshUI ( this );
}