Show error if graph loading fails
This commit is contained in:
@@ -13,11 +13,9 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
$scope.activeApp = null;
|
||||
$scope.disks = [];
|
||||
|
||||
$scope.installedApps = Client.getInstalledApps();
|
||||
$scope.errorMessage = '';
|
||||
|
||||
function bytesToGigaBytes(value) {
|
||||
return (value/1024/1024/1024).toFixed(2);
|
||||
}
|
||||
$scope.installedApps = Client.getInstalledApps();
|
||||
|
||||
function bytesToMegaBytes(value) {
|
||||
return (value/1024/1024).toFixed(2);
|
||||
@@ -40,6 +38,10 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
return getRandomColor();
|
||||
}
|
||||
|
||||
$scope.setError = function (context, error) {
|
||||
$scope.errorMessage = 'Error loading ' + context + ' stats : ' + error.message + '. Try restarting the graphite service.';
|
||||
};
|
||||
|
||||
$scope.setMemoryApp = function (app, color) {
|
||||
$scope.activeApp = app;
|
||||
|
||||
@@ -51,7 +53,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
else target = 'summarize(collectd.localhost.table-' + app.id + '-memory.gauge-rss, "' + timeBucketSize + 'min", "avg")';
|
||||
|
||||
Client.graphs([target], '-' + timePeriod + 'min', {}, function (error, result) {
|
||||
if (error) return console.log('Unable to get graphs.', error);
|
||||
if (error) return $scope.setError('memory', error);
|
||||
|
||||
// translate the data from bytes to MB
|
||||
var datapoints = result[0].datapoints.map(function (d) { return parseInt((d[0] / 1024 / 1024).toFixed(2)); });
|
||||
@@ -64,13 +66,13 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: 'Memory',
|
||||
backgroundColor: color || "#82C4F8",
|
||||
borderColor: color || "#2196F3",
|
||||
backgroundColor: color || '#82C4F8',
|
||||
borderColor: color || '#2196F3',
|
||||
borderWidth: 2,
|
||||
pointBackgroundColor: color || "rgba(151,187,205,1)",
|
||||
pointBorderColor: color || "#2196F3",
|
||||
pointHoverBackgroundColor: color || "#82C4F8",
|
||||
pointHoverBorderColor: color || "#82C4F8",
|
||||
pointBackgroundColor: color || 'rgba(151,187,205,1)',
|
||||
pointBorderColor: color || '#2196F3',
|
||||
pointHoverBackgroundColor: color || '#82C4F8',
|
||||
pointHoverBorderColor: color || '#82C4F8',
|
||||
data: datapoints
|
||||
}]
|
||||
};
|
||||
@@ -114,7 +116,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
// on scaleway, for some reason docker devices are collected as part of collectd
|
||||
// until we figure why just hardcode popular disk devices - https://www.mjmwired.net/kernel/Documentation/devices.txt
|
||||
Client.disks(function (error, result) {
|
||||
if (error) return console.log(error);
|
||||
if (error) return $scope.setError('disk', error);
|
||||
|
||||
result.disks.forEach(function (disk, index) {
|
||||
disk.id = index;
|
||||
@@ -146,7 +148,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
'absolute(collectd.localhost.df-' + diskName + '.df_complex-reserved)',
|
||||
'absolute(collectd.localhost.df-' + diskName + '.df_complex-used)'
|
||||
], '-1min', {}, function (error, data) {
|
||||
if (error) return console.error(error);
|
||||
if (error) return $scope.setError('disk', error);
|
||||
|
||||
disk.size = data[2].datapoints[0][0] + data[1].datapoints[0][0] + data[0].datapoints[0][0];
|
||||
disk.free = data[0].datapoints[0][0];
|
||||
@@ -163,7 +165,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
});
|
||||
|
||||
Client.graphs(graphiteQueries, '-1day', { noNullPoints: true }, function (error, data) {
|
||||
if (error) return console.error(error);
|
||||
if (error) return $scope.setError('disk', error);
|
||||
|
||||
var usageOther = disk.occupied;
|
||||
|
||||
@@ -206,7 +208,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
targetsInfo.push({ label: 'Free', color: '#27CE65' });
|
||||
|
||||
Client.graphs(targets, '-1min', {}, function (error, result) {
|
||||
if (error) return console.log(error);
|
||||
if (error) return $scope.setError('memory', error);
|
||||
|
||||
$scope.memoryUsageSystem = result.map(function (data, index) {
|
||||
return {
|
||||
@@ -263,7 +265,7 @@ angular.module('Application').controller('GraphsController', ['$scope', '$locati
|
||||
callback(null);
|
||||
});
|
||||
}, function (error) {
|
||||
if (error) return console.log(error);
|
||||
if (error) return $scope.setError('memory', error);
|
||||
|
||||
$scope.memoryUsageApps = aggregatedResult.map(function (data, index) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user