Implement recheck
This commit is contained in:
parent
367bee14e2
commit
46dd36c653
@ -31,6 +31,7 @@ const GenericServer = Me.imports.servers.genericserver.GenericServer;
|
||||
|
||||
|
||||
class Icinga2API extends GenericServer {
|
||||
|
||||
constructor ( _server ) {
|
||||
super(_server, 'Icinga2 API');
|
||||
}
|
||||
@ -46,13 +47,31 @@ class Icinga2API extends GenericServer {
|
||||
{
|
||||
super.prepareHttp ( );
|
||||
|
||||
let message = Soup.form_request_new_from_hash ( 'GET', this.urlcgi, { 'format': 'json' } );
|
||||
let message = Soup.form_request_new_from_hash ( 'GET', this.urlcgi + '/objects/services', { } );
|
||||
message.request_headers.append ( 'Accept', 'application/json' );
|
||||
|
||||
this.authenticateAndSend ( message );
|
||||
this.authenticateAndSend ( message, this.handlePollMessage );
|
||||
}
|
||||
|
||||
handleMessage ( _httpSession, message )
|
||||
recheck ( entry )
|
||||
{
|
||||
let message = Soup.form_request_new_from_hash ( 'POST', this.urlcgi + '/actions/reschedule-check', { } );
|
||||
|
||||
let params = '{ "type": "Service", "filter": "host.name==\\"%s\\" && service.name==\\"%s\\"", "force": true, "pretty": true }' . format ( encodeURI ( entry.host_name ), encodeURI ( entry.service_display_name ) );
|
||||
|
||||
message.request_body.truncate();
|
||||
message.request_body.append ( params );
|
||||
message.request_body.flatten();
|
||||
|
||||
log ( '> Body: ' + message.request_body.data );
|
||||
|
||||
message.request_headers.append ( 'Accept', 'application/json' );
|
||||
log ( message.request_headers );
|
||||
|
||||
this.authenticateAndSend ( message, this.handleCMDMessage );
|
||||
}
|
||||
|
||||
handlePollMessage ( _httpSession, message )
|
||||
{
|
||||
let _data = super.handleMessage ( _httpSession, message );
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user