Drupal: Added selenium, http load and jenkins info to Drupal info tile

Change-Id: I6179dcfc1e883693fcb945aaaebbedea6509d6a7
This commit is contained in:
Frédéric Vachon 2015-06-23 17:42:50 -04:00 committed by Alexandre Viau
parent 61c391e3ef
commit 2f7b56e588
2 changed files with 85 additions and 20 deletions

View File

@ -2,7 +2,7 @@
<h1 class="drupal__dashboard__title">{{drupal_id}}</h1>
<bansho-drupal-info host-name="{{hostName}}"
plugin="drupal_status"
plugin="drupal_status,drupal_jenkins,http_load,selenium"
title="General informations"></bansho-drupal-info>
<bansho-drupal-tile host-name="{{hostName}}"

View File

@ -10,24 +10,45 @@ angular.module('bansho.drupal.info', [])
apiName = 'services',
filters = {},
currentIndex = DrupalInfoConfig.nextIndex,
conf = DrupalInfoConfig.conf[currentIndex];
conf = DrupalInfoConfig.conf[currentIndex],
getStateClass;
$scope.plugin = conf.plugin;
$scope.plugin = conf.plugin.split(',');
$scope.title = conf.title;
$scope.hostName = conf.hostName;
filters = {'is': {'host_name': [$scope.hostName],
'service_description': [$scope.plugin]}};
'service_description': $scope.plugin}};
getStateClass = function (obj) {
var stateClass = '';
if (obj.state === 'CRITICAL') {
stateClass = 'btn-danger';
} else if (obj.state === 'WARNING') {
stateClass = 'btn-warning';
}
return stateClass;
};
surveilStatus.getObjects(fields, filters, apiName)
.success(function (response) {
var finalScore = response[0].plugin_output.split(' ')[1],
out = [],
data = response[0].long_output.split('\n').slice(0, -1);
var out = [],
tuple_jenkins = [],
tuple_selenium = [],
tuple_http_load = [],
output, result, stateClass;
// Split data into (key, value, score_class) tuples
for (var i = 0; i < data.length; i++) {
var tuple = data[i].split(';'),
for (var i = 0; i < response.length; i++) {
if (response[i].service_description === 'drupal_status') {
var finalScore = response[i].plugin_output.split(' ')[1],
data = response[i].long_output.split('\n').slice(0, -1);
// Split data into (key, value, stateClass) tuples
for (var j = 0; j < data.length; j++) {
var tuple = data[j].split(';'),
score = parseInt(tuple[2], 10);
if (score === 1) {
@ -41,6 +62,50 @@ angular.module('bansho.drupal.info', [])
out.push(tuple);
}
} else if (response[i].service_description === 'drupal_jenkins') {
output = response[i].plugin_output;
result = 'Unknown';
if (output.indexOf('successful') != -1) {
result = 'Successful';
} else if (output.indexOf('failed') != -1) {
result = 'Failed';
} else if (output.indexOf('unstable') != -1) {
result = 'Unstable';
}
stateClass = getStateClass(response[i]);
tuple_jenkins = ['Last build', result, stateClass];
} else if (response[i].service_description === 'http_load') {
output = response[i].plugin_output;
if (response[i].state !== 'UNKNOWN') {
result = output.split(':')[2];
} else {
result = 'Unknown';
}
stateClass = getStateClass(response[i]);
tuple_http_load = ['Under load', result, stateClass];
} else if (response[i].service_description === 'selenium') {
output = response[i].plugin_output;
if (response[i].state !== 'UNKNOWN') {
result = output.split(':')[2];
} else {
result = 'Unknown';
}
stateClass = getStateClass(response[i]);
tuple_selenium = ['Scenario time', result, stateClass];
}
}
out.push(tuple_jenkins);
out.push(tuple_selenium);
out.push(tuple_http_load);
$scope.data = out;
});