Commit 5c98a90b authored by Indrek Jentson's avatar Indrek Jentson

Koodi parandused

Signed-off-by: default avatarIndrek Jentson <indrek.jentson@cgi.com>
parent 669143a5
......@@ -32,5 +32,5 @@ $ docker exec -it kl_wrapper_name bash
* Uuenda teenust
$ docker exec kl_wrapper_name /src/docker_update.sh
$ docker exec kl_wrapper_name /wrapper/docker_update.sh
{
"name": "keeleliin-wrapper-service",
"version": "0.0.0",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -450,6 +450,15 @@
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"diskusage": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/diskusage/-/diskusage-1.0.0.tgz",
"integrity": "sha512-eOrPVSZLxo8kXz03GA+gdKauSSmicNET/pXMZKXs1vkdZrEayeZmJYu1Eo2uzVhkQL748vq1irIi7hzoPWBRmQ==",
"requires": {
"es6-promise": "^4.2.5",
"nan": "^2.11.1"
}
},
"doctypes": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz",
......@@ -474,6 +483,11 @@
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"es6-promise": {
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz",
"integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg=="
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
......@@ -1373,6 +1387,11 @@
}
}
},
"nan": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz",
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw=="
},
"natives": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
......
......@@ -11,6 +11,7 @@
"async": "^1.4.0",
"body-parser": "^1.18.3",
"debug": "^4.1.1",
"diskusage": "^1.0.0",
"express": "~4.16.0",
"fs": "0.0.2",
"graceful-fs": "^4.1.2",
......
......@@ -4,12 +4,12 @@
var logger = require('log4js').getLogger('statistics_service');
var async = require('async');
var os = require('os');
// var njds = require('nodejs-disks');
var disk = require('diskusage');
function StatisticsService() {
var self = this;
this.getServerStatistics = function(req, cb) {
this.getServerStatistics = function (req, cb) {
var summary = {};
......@@ -42,46 +42,42 @@ function StatisticsService() {
this.getMemoryStatistics = function (callback) {
var total = Math.round( os.totalmem() / 10737418,24 ) / 100;
var used = Math.round( (os.totalmem() - os.freemem()) / 10737418,24 ) / 100;
var total = Math.round(os.totalmem() / 10737418, 24) / 100;
var used = Math.round((os.totalmem() - os.freemem()) / 10737418, 24) / 100;
var systemMemory = {
total: total + ' GB',
used: used + ' GB'
};
callback( null, systemMemory);
callback(null, systemMemory);
};
this.getDrivesStatistics = function ( callback ) {
this.getDrivesStatistics = function (callback) {
var drivesSummary = [];
njds.drives( function (err, drives) {
njds.drivesDetail(
drives,
function (err, data) {
for(var i in data) {
var drive = {
name: data[i].drive,
total: data[i].total,
used: data[i].used
};
drivesSummary.push(drive);
}
callback(null, drivesSummary);
}
);
var path = os.platform() === 'win32' ? 'c:' : '/';
disk.check(path, function (err, info) {
if (err) {
logger.error(err);
} else {
var drive = {
name: path,
total: info.total,
used: info.total - info.free
};
drivesSummary.push(drive);
callback(null, drivesSummary);
}
)
});
};
this.getCPULoad = function (callback) {
var loads = os.loadavg();
for(i in loads){
for (i in loads) {
var load = loads[i];
loads[i] = Math.round(load * 100) / 100;
}
loads.push( os.cpus().length );
callback( null, loads);
loads.push(os.cpus().length);
callback(null, loads);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment