Commit 4c079ff4 authored by Alexandra Rogova's avatar Alexandra Rogova Committed by Alexandra Rogova

testing ram and disk monitoring

parent a6e13c59
items,ramUsed,diskUsed
1000,-0.556598572009277,3.10546875
2000,-0.46393734146813537,5.2265625
3000,-0.5450302605122971,4.890625
1000,1581416858085
2000,1581416858551
3000,1581416859096
4000,1581416859858
5000,1581416860733
6000,1581416861642
7000,1581416862627
8000,1581416863841
9000,1581416864847
10000,1581416866342
11000,1581416868005
12000,1581416869435
13000,1581416871063
14000,1581416872439
15000,1581416874165
16000,1581416875933
17000,1581416877703
18000,1581416879848
19000,1581416882035
20000,1581416884151
21000,1581416886421
22000,1581416888978
23000,1581416891413
24000,1581416893909
25000,1581416896291
26000,1581416898795
27000,1581416902025
28000,1581416904612
29000,1581416907309
30000,1581416910877
31000,1581416915391
32000,1581416918514
33000,1581416921572
34000,1581416925424
35000,1581416929364
36000,1581416934214
37000,1581416937452
38000,1581416942113
39000,1581416946047
40000,1581416950932
41000,1581416956546
42000,1581416961903
43000,1581416967699
44000,1581416973539
45000,1581416981729
46000,1581416988363
47000,1581416994071
48000,1581416999970
49000,1581417005833
50000,1581417012280
This diff is collapsed.
"use strict";
var childProcess = require("child_process");
var cut_file = require("./random_gen").cut_file;
var diskspace = require("diskspace");
var os_utils = require("os-utils");
// var os_utils = require("os-utils");
var os = require('os');
const puppeteer = require("puppeteer");
const Server = require("ws").Server;
const args = require("yargs")
.usage("Usage : load_content.js -saveAs metadata/attachment -file file_path")
.demandOption(["file"])
.demandOption(["saveAs"])
.alias("f", "file")
.alias("s", "saveAs")
.alias("l", "link")
.describe("file", "file containing content, data must follow the CSV standard")
.describe("saveAs", "choose whether to save the content as " +
"metadata or attachments in the indexeddb")
.describe("link", "link to website treating the data, defaults to Mynij")
.nargs("file", 1)
.nargs("saveAs", 1)
.nargs("link", 1)
.argv;
.usage("Usage : load_content.js -saveAs metadata/attachment -file file_path")
.demandOption(["file"])
.demandOption(["saveAs"])
.alias("f", "file")
.alias("s", "saveAs")
.alias("l", "link")
.describe("file", "file containing content, data must follow the CSV standard")
.describe("saveAs", "choose whether to save the content as " +
"metadata or attachments in the indexeddb")
.describe("link", "link to website treating the data, defaults to Mynij")
.nargs("file", 1)
.nargs("saveAs", 1)
.nargs("link", 1)
.argv;
if (!(args.saveAs === "metadata" ||args.saveAs === "attachment")){
throw "Unrecognized save as argument";
}
var link = args.link
? args.link
: "https://softinst115787.host.vifib.net/public/unit_tests/" +
"content_load.html?saveAs=";
? args.link
: "https://softinst115787.host.vifib.net/public/unit_tests/" +
"index_load.html?saveAs=";
var saveAs = args.saveAs;
var files;
var browser;
var page;
var n = 0;
var time;
var monitor;
var ramBefore;
var memBefore;
......@@ -42,14 +45,8 @@ function init_server (){
var ws = new Server({port: port});
ws.on("connection", function(w){
w.on("message", function(){
diskspace.check("C", function (err, result){
var memUsed = (result.used/1024/1024) - memBefore;
os_utils.cpuUsage(function(v){
var ramUsed = v - ramBefore;
process.send(n + "," + ramUsed + "," + memUsed + "\n");
query();
});
});
process.send(n + "," + Date.now());
query();
});
w.on("close", function() {
ws.close();
......@@ -58,7 +55,7 @@ function init_server (){
}
function timeout (){
//Every 30 minutes, check if more than 2 hours have passed since last response
//Every 30 minutes, check if more than 2 hours have passed since last response
setTimeout(function () {
if (Date.now() - time > 7200000){ //2 hours
process.send(n + ",Timeout error \n");
......@@ -72,6 +69,7 @@ function timeout (){
async function query (){
if (files.length === 0){
monitor.kill();
var ipc=require("node-ipc");
ipc.config.silent = true;
ipc.connectTo("main");
......@@ -80,6 +78,17 @@ async function query (){
} else {
n += 1000;
time = Date.now();
// monitor = childProcess.fork("./unit_tests/monitor.js");
// monitor.on("message", function(msg){
// diskspace.check("C", function (err, result){
// var memUsed = (result.used/1024/1024) - memBefore;
// var ramUsed = parseInt(msg) - ramBefore;
// console.log(ramUsed/1024/1024);
// //process.send(n + "," + ramUsed + "," + memUsed + "\n");
// monitor.kill();
// query();
// });
// });
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click("input#load")
......@@ -94,12 +103,12 @@ async function query (){
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto(link+saveAs);
os_utils.cpuUsage(function(v){
ramBefore = v;
});
diskspace.check("C", function (err, result){
memBefore = result.used/1024/1024;
});
monitor = childProcess.fork("./unit_tests/monitor.js");
timeout();
query();
// diskspace.check("C", function (err, result){
// memBefore = result.used/1024/1024;
// timeout();
// query();
// });
})();
var os = require('os');
const fs = require("fs");
var diskspace = require("diskspace");
var max_ram;
var total_ram = os.totalmem();
var start_disk;
var stream = fs.createWriteStream("./results/add_csv_attachments_monitor.csv", {flags: "w+"});
stream.write("time,disk,ram\n");
// function init_server (){
// var port = 9030;
// var ws = new Server({port: port});
// ws.on("connection", function(w){
// w.on("message", function(){
// process.send(max_ram);
// });
// w.on("close", function() {
// ws.close();
// });
// });
// }
var check = function(){
setTimeout(function () {
diskspace.check("C", function(err, result){
var ram_used = parseInt(result.used) - parseInt(start_disk);
var disk_used = total_ram - os.freemem();
stream.write(Date.now() + "," + ram_used + "," + disk_used + "\n");
check();
});
}, 1);
}
//init_server();
max_ram = total_ram - os.freemem();
diskspace.check("C", function (err, result){
start_disk = parseInt(result.used);
check();
});
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../systeminformation/lib/cli.js" "$@"
ret=$?
else
node "$basedir/../systeminformation/lib/cli.js" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\systeminformation\lib\cli.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\systeminformation\lib\cli.js" %*
)
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/color-name`
# Summary
This package contains type definitions for color-name ( https://github.com/colorjs/color-name ).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/color-name
Additional Details
* Last updated: Wed, 13 Feb 2019 16:16:48 GMT
* Dependencies: none
* Global values: none
# Credits
These definitions were written by Junyoung Clare Jang <https://github.com/Ailrun>.
// Type definitions for color-name 1.1
// Project: https://github.com/colorjs/color-name
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Tuple of Red, Green, and Blue
* @example
* // Red = 55, Green = 70, Blue = 0
* const rgb: RGB = [55, 70, 0];
*/
export type RGB = [number, number, number];
export const aliceblue: RGB;
export const antiquewhite: RGB;
export const aqua: RGB;
export const aquamarine: RGB;
export const azure: RGB;
export const beige: RGB;
export const bisque: RGB;
export const black: RGB;
export const blanchedalmond: RGB;
export const blue: RGB;
export const blueviolet: RGB;
export const brown: RGB;
export const burlywood: RGB;
export const cadetblue: RGB;
export const chartreuse: RGB;
export const chocolate: RGB;
export const coral: RGB;
export const cornflowerblue: RGB;
export const cornsilk: RGB;
export const crimson: RGB;
export const cyan: RGB;
export const darkblue: RGB;
export const darkcyan: RGB;
export const darkgoldenrod: RGB;
export const darkgray: RGB;
export const darkgreen: RGB;
export const darkgrey: RGB;
export const darkkhaki: RGB;
export const darkmagenta: RGB;
export const darkolivegreen: RGB;
export const darkorange: RGB;
export const darkorchid: RGB;
export const darkred: RGB;
export const darksalmon: RGB;
export const darkseagreen: RGB;
export const darkslateblue: RGB;
export const darkslategray: RGB;
export const darkslategrey: RGB;
export const darkturquoise: RGB;
export const darkviolet: RGB;
export const deeppink: RGB;
export const deepskyblue: RGB;
export const dimgray: RGB;
export const dimgrey: RGB;
export const dodgerblue: RGB;
export const firebrick: RGB;
export const floralwhite: RGB;
export const forestgreen: RGB;
export const fuchsia: RGB;
export const gainsboro: RGB;
export const ghostwhite: RGB;
export const gold: RGB;
export const goldenrod: RGB;
export const gray: RGB;
export const green: RGB;
export const greenyellow: RGB;
export const grey: RGB;
export const honeydew: RGB;
export const hotpink: RGB;
export const indianred: RGB;
export const indigo: RGB;
export const ivory: RGB;
export const khaki: RGB;
export const lavender: RGB;
export const lavenderblush: RGB;
export const lawngreen: RGB;
export const lemonchiffon: RGB;
export const lightblue: RGB;
export const lightcoral: RGB;
export const lightcyan: RGB;
export const lightgoldenrodyellow: RGB;
export const lightgray: RGB;
export const lightgreen: RGB;
export const lightgrey: RGB;
export const lightpink: RGB;
export const lightsalmon: RGB;
export const lightseagreen: RGB;
export const lightskyblue: RGB;
export const lightslategray: RGB;
export const lightslategrey: RGB;
export const lightsteelblue: RGB;
export const lightyellow: RGB;
export const lime: RGB;
export const limegreen: RGB;
export const linen: RGB;
export const magenta: RGB;
export const maroon: RGB;
export const mediumaquamarine: RGB;
export const mediumblue: RGB;
export const mediumorchid: RGB;
export const mediumpurple: RGB;
export const mediumseagreen: RGB;
export const mediumslateblue: RGB;
export const mediumspringgreen: RGB;
export const mediumturquoise: RGB;
export const mediumvioletred: RGB;
export const midnightblue: RGB;
export const mintcream: RGB;
export const mistyrose: RGB;
export const moccasin: RGB;
export const navajowhite: RGB;
export const navy: RGB;
export const oldlace: RGB;
export const olive: RGB;
export const olivedrab: RGB;
export const orange: RGB;
export const orangered: RGB;
export const orchid: RGB;
export const palegoldenrod: RGB;
export const palegreen: RGB;
export const paleturquoise: RGB;
export const palevioletred: RGB;
export const papayawhip: RGB;
export const peachpuff: RGB;
export const peru: RGB;
export const pink: RGB;
export const plum: RGB;
export const powderblue: RGB;
export const purple: RGB;
export const rebeccapurple: RGB;
export const red: RGB;
export const rosybrown: RGB;
export const royalblue: RGB;
export const saddlebrown: RGB;
export const salmon: RGB;
export const sandybrown: RGB;
export const seagreen: RGB;
export const seashell: RGB;
export const sienna: RGB;
export const silver: RGB;
export const skyblue: RGB;
export const slateblue: RGB;
export const slategray: RGB;
export const slategrey: RGB;
export const snow: RGB;
export const springgreen: RGB;
export const steelblue: RGB;
export const tan: RGB;
export const teal: RGB;
export const thistle: RGB;
export const tomato: RGB;
export const turquoise: RGB;
export const violet: RGB;
export const wheat: RGB;
export const white: RGB;
export const whitesmoke: RGB;
export const yellow: RGB;
export const yellowgreen: RGB;
{
"_from": "@types/color-name@^1.1.1",
"_id": "@types/color-name@1.1.1",
"_inBundle": false,
"_integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"_location": "/@types/color-name",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@types/color-name@^1.1.1",
"name": "@types/color-name",
"escapedName": "@types%2fcolor-name",
"scope": "@types",
"rawSpec": "^1.1.1",
"saveSpec": null,
"fetchSpec": "^1.1.1"
},
"_requiredBy": [
"/wrap-ansi/ansi-styles"
],
"_resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"_shasum": "1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0",
"_spec": "@types/color-name@^1.1.1",
"_where": "C:\\Users\\thequ\\Documents\\Mynij\\Mynij-unit-tests\\node_modules\\wrap-ansi\\node_modules\\ansi-styles",
"bugs": {
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Junyoung Clare Jang",
"url": "https://github.com/Ailrun"
}
],
"dependencies": {},
"deprecated": false,