Skip to content

Commit

Permalink
First cut also show the mbean CurrentStatus attribute if it's available.
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Oct 30, 2013
1 parent 4b4fc88 commit b5958a0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 32 deletions.
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/health/html/health.html
Expand Up @@ -13,6 +13,7 @@
ng-show="filterValues(display)"
hawtio-auto-columns=".health-display">
<div class="health-display-title">{{display.mbean}}</div>
<div ng-show="mbeanStatus[display.mbean]">Status: {{mbeanStatus[display.mbean]}}</div>
<div ng-show="display.values.length === 0">No displays to show...</div>
<div ng-repeat="value in display.values"
class="health-display {{value.level}}"
Expand Down
126 changes: 94 additions & 32 deletions hawtio-web/src/main/webapp/app/health/js/health.ts
Expand Up @@ -26,13 +26,105 @@ module Health {
$scope.results = [];
$scope.responses = {};
$scope.mbeans = [];
$scope.mbeanStatus = {};
$scope.displays = [];
$scope.page = '';

$scope.pageFilter = '';

$scope.$watch('mbeans', (newValue, oldValue) => {
Core.unregister(jolokia, $scope);
if (!newValue) {
return;
}
$scope.mbeanStatus = {};
newValue.forEach((mbean) => {
Core.register(jolokia, $scope, {
type: 'exec', mbean: mbean,
operation: "healthList()"
}, {
success: $scope.render,
error: (response) => {
log.error("Failed to invoke healthList() on mbean: " + mbean + " due to: ", response.error);
log.info("Stack trace: ", response.stacktrace.split("\n"));
}
});

var error = (response) => {
if (!response.error.has("AttributeNotFoundException")) {
log.error("Failed to read CurrentStatus on mbean: " + mbean + " due to: ", response.error);
log.info("Stack trace: ", response.stacktrace.split("\n"));
}
};

//see if the mbean has a CurrentStatus attribute and keep an eye on it if so
jolokia.request({
type: 'read', mbean: mbean, attribute: 'CurrentStatus'
}, {
success: (response) => {
$scope.mbeanStatus[response.request['mbean']] = response.value;
Core.register(jolokia, $scope, {
type: 'read', mbean: mbean, attribute: 'CurrentStatus'
}, {
success: (response) => {
/*
log.debug("response for CurrentStatus",
response.request['mbean'],
": ",
response.value);
*/
if (response.value === $scope.mbeanStatus[response.request['mbean']]) {
return;
}
$scope.mbeanStatus[response.request['mbean']] = response.value;
Core.$apply($scope);
},
error: error
});
},
error: error
});
});
}, true);


$scope.getMBeans = () => {
var healthMap = getHealthMBeans(workspace);
log.debug("HealthMap: ", healthMap);
if (healthMap) {
if (!angular.isArray(healthMap)) {
return [healthMap.objectName];
}
var answer = healthMap.map((obj) => { return obj.objectName; });
log.debug("Health mbeans: ", answer);
return answer;
} else {
log.debug("No health mbeans found...");
return [];
}
};


$scope.$on('jmxTreeUpdated', () => {
$scope.mbeans = $scope.getMBeans();
});

$scope.$on('$routeChangeSuccess', () => {
$scope.mbeans = $scope.getMBeans();
});

$scope.mbeans = $scope.getMBeans();


$scope.render = (response) => {
//log.debug("Got response: ", response);
/*
log.debug("response for ",
response.request['mbean'],
".",
response.request['operation'],
": ",
response.value);
*/
var mbean = response.request['mbean'];
var values = response.value;

Expand Down Expand Up @@ -99,40 +191,12 @@ module Health {
Core.$apply($scope);
};


$scope.filterValues = (value) => {
var json = angular.toJson(value);
return json.has($scope.pageFilter);
};

$scope.$watch('mbeans', (newValue, oldValue) => {
Core.unregister(jolokia, $scope);
$scope.mbeans.forEach((mbean) => {
Core.register(jolokia, $scope, {
type: 'exec', mbean: mbean,
operation: "healthList()"
}, {
success: $scope.render,
error: (response) => {
log.error("Failed to invoke healthList() on mbean: " + mbean + " due to: ", response.error);
log.info("Stack trace: ", response.stacktrace.split("\n"));
}
});
});
}, true);

$scope.getMBeans = () => {
var healthMap = getHealthMBeans(workspace);
//log.debug("HealthMap: ", healthMap);
if (healthMap) {
if (!angular.isArray(healthMap)) {
return [healthMap.objectName];
}
var answer = healthMap.map((obj) => { return obj.objectName; });
return answer;
} else {
return [];
}
};

$scope.sanitize = (value) => {
var answer = {};
Expand All @@ -159,8 +223,6 @@ module Health {
return 'HealthID: <strong>' + value['healthId'] + '</strong>';
};

$scope.mbeans = $scope.getMBeans();

/**
* Default the values that are missing in the returned JSON
*/
Expand Down

0 comments on commit b5958a0

Please sign in to comment.