check disk graphs
This commit is contained in:
parent
e168952f63
commit
c05d6eb7b4
46
cloudron.js
46
cloudron.js
@ -306,16 +306,11 @@ Cloudron.prototype.checkA = function (callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Cloudron.prototype.checkGraphs = function (appId) {
|
Cloudron.prototype._checkGraphs = function (targets, from) {
|
||||||
var timePeriod = 2 * 60; // in minutes
|
|
||||||
var timeBucketSize = 30; // in minutes
|
|
||||||
|
|
||||||
var target = 'summarize(collectd.localhost.table-' + appId + '-memory.gauge-rss, "' + timeBucketSize + 'min", "avg")';
|
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
target: [ target ],
|
target: targets,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
from: '-' + timePeriod + 'min',
|
from: from,
|
||||||
access_token: this._credentials.accessToken
|
access_token: this._credentials.accessToken
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -323,19 +318,40 @@ Cloudron.prototype.checkGraphs = function (appId) {
|
|||||||
for (var i = 0; i < 40; i++) {
|
for (var i = 0; i < 40; i++) {
|
||||||
sleep(10);
|
sleep(10);
|
||||||
res = request.get(this._origin + '/api/v1/cloudron/graphs').query(params).end();
|
res = request.get(this._origin + '/api/v1/cloudron/graphs').query(params).end();
|
||||||
if (res.statusCode === 200) {
|
|
||||||
if (util.isArray(res.body) && res.body.length !== 0 && res.body[0].target && res.body[0].datapoints && res.body[0].datapoints.length !== 0) {
|
|
||||||
console.log();
|
|
||||||
console.log(res.body);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
process.stdout.write('.');
|
process.stdout.write('.');
|
||||||
|
if (res.statusCode !== 200) continue;
|
||||||
|
if (!util.isArray(res.body) && res.body.length !== targets.length) continue;
|
||||||
|
|
||||||
|
for (var j = 0; j < res.body.length; j++) {
|
||||||
|
if (res.body[j].datapoints.length === 0) break; // no data
|
||||||
|
console.log();
|
||||||
|
console.log(res.body);
|
||||||
|
return; // success
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false, 'Graphs are not populated');
|
assert(false, 'Graphs are not populated');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Cloudron.prototype.checkAppGraphs = function (appId) {
|
||||||
|
var timePeriod = 2 * 60; // in minutes
|
||||||
|
var timeBucketSize = 30; // in minutes
|
||||||
|
|
||||||
|
var target = 'summarize(collectd.localhost.table-' + appId + '-memory.gauge-rss, "' + timeBucketSize + 'min", "avg")';
|
||||||
|
|
||||||
|
this._checkGraphs([target], '-' + timePeriod + 'min');
|
||||||
|
};
|
||||||
|
|
||||||
|
Cloudron.prototype.checkDiskGraphs = function () {
|
||||||
|
var targets = [
|
||||||
|
'averageSeries(collectd.localhost.df-loop*.df_complex-free)',
|
||||||
|
'averageSeries(collectd.localhost.df-loop*.df_complex-reserved)',
|
||||||
|
'averageSeries(collectd.localhost.df-loop*.df_complex-used)'
|
||||||
|
];
|
||||||
|
|
||||||
|
this._checkGraphs(targets, '-1min');
|
||||||
|
};
|
||||||
|
|
||||||
Cloudron.prototype.checkSPF = function (callback) {
|
Cloudron.prototype.checkSPF = function (callback) {
|
||||||
var that = this;
|
var that = this;
|
||||||
dns.resolveTxt(this._box.domain, function (error, records) {
|
dns.resolveTxt(this._box.domain, function (error, records) {
|
||||||
|
@ -76,7 +76,7 @@ describe('Application flow test', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('displays app graphs', function () {
|
it('displays app graphs', function () {
|
||||||
cloudron.checkGraps(appId);
|
cloudron.checkAppGraphs(appId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can configure app', function () {
|
it('can configure app', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user