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 ...@@ -32,5 +32,5 @@ $ docker exec -it kl_wrapper_name bash
* Uuenda teenust * Uuenda teenust
$ docker exec kl_wrapper_name /src/docker_update.sh $ docker exec kl_wrapper_name /wrapper/docker_update.sh
{ {
"name": "keeleliin-wrapper-service", "name": "keeleliin-wrapper-service",
"version": "0.0.0", "version": "1.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -450,6 +450,15 @@ ...@@ -450,6 +450,15 @@
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true "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": { "doctypes": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz",
...@@ -474,6 +483,11 @@ ...@@ -474,6 +483,11 @@
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" "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": { "escape-html": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
...@@ -1373,6 +1387,11 @@ ...@@ -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": { "natives": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"async": "^1.4.0", "async": "^1.4.0",
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
"debug": "^4.1.1", "debug": "^4.1.1",
"diskusage": "^1.0.0",
"express": "~4.16.0", "express": "~4.16.0",
"fs": "0.0.2", "fs": "0.0.2",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
var logger = require('log4js').getLogger('statistics_service'); var logger = require('log4js').getLogger('statistics_service');
var async = require('async'); var async = require('async');
var os = require('os'); var os = require('os');
// var njds = require('nodejs-disks'); var disk = require('diskusage');
function StatisticsService() { function StatisticsService() {
var self = this; var self = this;
this.getServerStatistics = function(req, cb) { this.getServerStatistics = function (req, cb) {
var summary = {}; var summary = {};
...@@ -42,46 +42,42 @@ function StatisticsService() { ...@@ -42,46 +42,42 @@ function StatisticsService() {
this.getMemoryStatistics = function (callback) { this.getMemoryStatistics = function (callback) {
var total = Math.round( os.totalmem() / 10737418,24 ) / 100; var total = Math.round(os.totalmem() / 10737418, 24) / 100;
var used = Math.round( (os.totalmem() - os.freemem()) / 10737418,24 ) / 100; var used = Math.round((os.totalmem() - os.freemem()) / 10737418, 24) / 100;
var systemMemory = { var systemMemory = {
total: total + ' GB', total: total + ' GB',
used: used + ' GB' used: used + ' GB'
}; };
callback( null, systemMemory); callback(null, systemMemory);
}; };
this.getDrivesStatistics = function ( callback ) { this.getDrivesStatistics = function (callback) {
var drivesSummary = []; var drivesSummary = [];
njds.drives( function (err, drives) { var path = os.platform() === 'win32' ? 'c:' : '/';
njds.drivesDetail( disk.check(path, function (err, info) {
drives, if (err) {
function (err, data) { logger.error(err);
for(var i in data) { } else {
var drive = {
var drive = { name: path,
name: data[i].drive, total: info.total,
total: data[i].total, used: info.total - info.free
used: data[i].used };
}; drivesSummary.push(drive);
drivesSummary.push(drive); callback(null, drivesSummary);
}
callback(null, drivesSummary);
}
);
} }
) });
}; };
this.getCPULoad = function (callback) { this.getCPULoad = function (callback) {
var loads = os.loadavg(); var loads = os.loadavg();
for(i in loads){ for (i in loads) {
var load = loads[i]; var load = loads[i];
loads[i] = Math.round(load * 100) / 100; loads[i] = Math.round(load * 100) / 100;
} }
loads.push( os.cpus().length ); loads.push(os.cpus().length);
callback( null, loads); 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