Commit bc230614 authored by Alexandra's avatar Alexandra Committed by Alexandra Rogova

implemented nexedi's slapos python monitor for ram

parent a707b8ca
items,timestamp items,timestamp
1000,1581432948010 1000,1582278164094
2000,1581432948164 2000,1582278164224
3000,1581432948289 3000,1582278164332
4000,1581432948401 4000,1582278164441
5000,1581432948521 5000,1582278164544
6000,1581432948642 6000,1582278164648
7000,1581432948772 7000,1582278164751
8000,1581432948884 8000,1582278164845
9000,1581432948988 9000,1582278164937
10000,1581432949099 10000,1582278165038
11000,1581432949204 11000,1582278165141
12000,1581432949308 12000,1582278165261
13000,1581432949447 13000,1582278165354
14000,1581432949571 14000,1582278165462
15000,1581432949684 15000,1582278165562
16000,1581432949795 16000,1582278165662
17000,1581432949896 17000,1582278165760
18000,1581432950016 18000,1582278165858
19000,1581432950129 19000,1582278165956
20000,1581432950248 20000,1582278166054
21000,1581432950365 21000,1582278166156
22000,1581432950490 22000,1582278166280
23000,1581432950599 23000,1582278166372
24000,1581432950725 24000,1582278166494
25000,1581432950830 25000,1582278166585
26000,1581432950947 26000,1582278166704
27000,1581432951064 27000,1582278166802
28000,1581432951180 28000,1582278166897
29000,1581432951300 29000,1582278166990
30000,1581432951417 30000,1582278167104
31000,1581432951534 31000,1582278167202
32000,1581432951642 32000,1582278167298
33000,1581432951756 33000,1582278167403
34000,1581432951876 34000,1582278167499
35000,1581432951982 35000,1582278167591
36000,1581432952099 36000,1582278167691
37000,1581432952213 37000,1582278167801
38000,1581432952331 38000,1582278167907
39000,1581432952461 39000,1582278168034
40000,1581432952565 40000,1582278168133
41000,1581432952691 41000,1582278168228
42000,1581432952830 42000,1582278168345
43000,1581432952940 43000,1582278168447
44000,1581432953056 44000,1582278168567
45000,1581432953165 45000,1582278168702
46000,1581432953284 46000,1582278168828
47000,1581432953402 47000,1582278168929
48000,1581432953520 48000,1582278169028
49000,1581432953629 49000,1582278169128
50000,1581432953755 50000,1582278169236
51000,1581432953867 51000,1582278169357
52000,1581432953980 52000,1582278169456
53000,1581432954098 53000,1582278169552
54000,1581432954217 54000,1582278169649
55000,1581432954335 55000,1582278169745
56000,1581432954443 56000,1582278169839
57000,1581432954557 57000,1582278169940
58000,1581432954670 58000,1582278170041
59000,1581432954784 59000,1582278170137
60000,1581432954899 60000,1582278170254
61000,1581432955017 61000,1582278170350
62000,1581432955131 62000,1582278170448
63000,1581432955251 63000,1582278170544
64000,1581432955367 64000,1582278170640
65000,1581432955484 65000,1582278170738
66000,1581432955603 66000,1582278170850
67000,1581432955712 67000,1582278170956
68000,1581432955903 68000,1582278171127
69000,1581432956015 69000,1582278171240
70000,1581432956119 70000,1582278171345
71000,1581432956225 71000,1582278171480
72000,1581432956331 72000,1582278171582
73000,1581432956450 73000,1582278171728
74000,1581432956562 74000,1582278171827
75000,1581432956667 75000,1582278171923
76000,1581432956783 76000,1582278172021
77000,1581432956895 77000,1582278172129
78000,1581432957001 78000,1582278172264
79000,1581432957114 79000,1582278172362
80000,1581432957239 80000,1582278172480
81000,1581432957348 81000,1582278172605
82000,1581432957468 82000,1582278172738
83000,1581432957578 83000,1582278172854
84000,1581432957679 84000,1582278172956
85000,1581432957802 85000,1582278173057
86000,1581432957918 86000,1582278173153
87000,1581432958039 87000,1582278173251
88000,1581432958154 88000,1582278173360
89000,1581432958258 89000,1582278173455
90000,1581432958372 90000,1582278173555
91000,1581432958484 91000,1582278173667
92000,1581432958589 92000,1582278173765
93000,1581432958704 93000,1582278173857
94000,1581432958809 94000,1582278173958
95000,1581432958912 95000,1582278174055
96000,1581432959030 96000,1582278174154
97000,1581432959150 97000,1582278174258
98000,1581432959267 98000,1582278174359
99000,1581432959384 99000,1582278174456
100000,1581432959500 100000,1582278174554
101000,1581432959617 101000,1582278174664
102000,1581432959741 102000,1582278174759
103000,1581432959847 103000,1582278174858
104000,1581432959969 104000,1582278174955
105000,1581432960085 105000,1582278175060
106000,1581432960198 106000,1582278175158
107000,1581432960315 107000,1582278175256
108000,1581432960432 108000,1582278175356
109000,1581432960550 109000,1582278175456
110000,1581432960676 110000,1582278175558
111000,1581432960786 111000,1582278175661
112000,1581432961016 112000,1582278175847
113000,1581432961136 113000,1582278176031
114000,1581432961251 114000,1582278176126
115000,1581432961362 115000,1582278176223
116000,1581432961487 116000,1582278176334
117000,1581432961594 117000,1582278176450
118000,1581432961707 118000,1582278176551
119000,1581432961815 119000,1582278176654
120000,1581432961937 120000,1582278176752
121000,1581432962051 121000,1582278176850
122000,1581432962186 122000,1582278176965
123000,1581432962303 123000,1582278177064
124000,1581432962421 124000,1582278177210
125000,1581432962528 125000,1582278177303
126000,1581432962648 126000,1582278177406
127000,1581432962769 127000,1582278177508
128000,1581432962884 128000,1582278177619
129000,1581432963003 129000,1582278177719
130000,1581432963113 130000,1582278177818
131000,1581432963218 131000,1582278177917
132000,1581432963332 132000,1582278178020
133000,1581432963456 133000,1582278178163
134000,1581432963569 134000,1582278178257
135000,1581432963677 135000,1582278178367
136000,1581432963786 136000,1582278178465
137000,1581432963897 137000,1582278178569
138000,1581432964016 138000,1582278178666
139000,1581432964161 139000,1582278178761
140000,1581432964266 140000,1582278178857
141000,1581432964381 141000,1582278178965
142000,1581432964500 142000,1582278179063
143000,1581432964616 143000,1582278179158
144000,1581432964734 144000,1582278179270
145000,1581432964856 145000,1582278179370
146000,1581432964967 146000,1582278179466
147000,1581432965072 147000,1582278179563
148000,1581432965182 148000,1582278179657
149000,1581432965298 149000,1582278179766
150000,1581432965423 150000,1582278179864
151000,1581432965543 151000,1582278179975
152000,1581432965652 152000,1582278180074
153000,1581432965774 153000,1582278180175
154000,1581432965878 154000,1582278180272
155000,1581432966001 155000,1582278180385
156000,1581432966120 156000,1582278180484
157000,1581432966242 157000,1582278180583
158000,1581432966355 158000,1582278180680
159000,1581432966462 159000,1582278180790
160000,1581432966582 160000,1582278180889
161000,1581432966698 161000,1582278180990
162000,1581432966819 162000,1582278181090
163000,1581432966942 163000,1582278181192
164000,1581432967046 164000,1582278181289
165000,1581432967169 165000,1582278181396
166000,1581432967293 166000,1582278181490
167000,1581432967401 167000,1582278181590
168000,1581432967519 168000,1582278181689
169000,1581432967651 169000,1582278181790
170000,1581432967785 170000,1582278181907
171000,1581432967892 171000,1582278182007
172000,1581432967998 172000,1582278182116
173000,1581432968117 173000,1582278182217
174000,1581432968235 174000,1582278182314
175000,1581432968378 175000,1582278182440
176000,1581432968690 176000,1582278182685
177000,1581432968815 177000,1582278182810
178000,1581432968932 178000,1582278182903
179000,1581432969051 179000,1582278183013
180000,1581432969168 180000,1582278183113
181000,1581432969279 181000,1582278183222
182000,1581432969387 182000,1582278183336
183000,1581432969499 183000,1582278183437
184000,1581432969621 184000,1582278183537
185000,1581432969733 185000,1582278183636
186000,1581432969854 186000,1582278183735
187000,1581432969965 187000,1582278183832
188000,1581432970091 188000,1582278183926
189000,1581432970198 189000,1582278184025
190000,1581432970319 190000,1582278184122
191000,1581432970435 191000,1582278184226
192000,1581432970551 192000,1582278184322
193000,1581432970667 193000,1582278184421
194000,1581432970784 194000,1582278184532
195000,1581432970898 195000,1582278184625
196000,1581432971016 196000,1582278184723
197000,1581432971141 197000,1582278184837
198000,1581432971249 198000,1582278184934
199000,1581432971367 199000,1582278185035
200000,1581432971491 200000,1582278185133
201000,1581432971597 201000,1582278185231
202000,1581432971719 202000,1582278185326
203000,1581432971862 203000,1582278185426
204000,1581432971972 204000,1582278185521
205000,1581432972088 205000,1582278185634
206000,1581432972192 206000,1582278185731
207000,1581432972300 207000,1582278185825
208000,1581432972416 208000,1582278185921
209000,1581432972541 209000,1582278186022
210000,1581432972652 210000,1582278186120
211000,1581432972766 211000,1582278186235
212000,1581432972883 212000,1582278186348
213000,1581432972993 213000,1582278186444
214000,1581432973105 214000,1582278186548
215000,1581432973209 215000,1582278186643
216000,1581432973324 216000,1582278186740
217000,1581432973433 217000,1582278186838
218000,1581432973548 218000,1582278186948
219000,1581432973666 219000,1582278187056
220000,1581432973784 220000,1582278187164
221000,1581432973895 221000,1582278187259
222000,1581432974033 222000,1582278187358
223000,1581432974139 223000,1582278187456
224000,1581432974248 224000,1582278187567
225000,1581432974368 225000,1582278187682
226000,1581432974491 226000,1582278187779
227000,1581432974597 227000,1582278187875
228000,1581432974718 228000,1582278187974
229000,1581432974831 229000,1582278188075
230000,1581432974957 230000,1582278188174
231000,1581432975069 231000,1582278188275
232000,1581432975186 232000,1582278188375
233000,1581432975302 233000,1582278188473
234000,1581432975417 234000,1582278188577
235000,1581432975533 235000,1582278188675
236000,1581432975650 236000,1582278188773
237000,1581432975768 237000,1582278188875
238000,1581432975876 238000,1582278188971
239000,1581432975983 239000,1582278189098
240000,1581432976102 240000,1582278189193
241000,1581432976222 241000,1582278189291
242000,1581432976333 242000,1582278189389
243000,1581432976440 243000,1582278189489
244000,1581432976548 244000,1582278189589
245000,1581432976674 245000,1582278189691
246000,1581432976789 246000,1582278189799
247000,1581432976899 247000,1582278189899
248000,1581432977001 248000,1582278189993
249000,1581432977119 249000,1582278190090
250000,1581432977222 250000,1582278190190
251000,1581432977334 251000,1582278190290
252000,1581432977448 252000,1582278190390
253000,1581432977563 253000,1582278190492
254000,1581432977681 254000,1582278190590
255000,1581432977808 255000,1582278190697
256000,1581432977926 256000,1582278190794
This source diff could not be displayed because it is too large. You can view the blob instead.
items,ramUsed,memUsed
1000,0.1296115260144386,5.12109375
2000,0.1690131572551702,7.19921875
3000,0.1530372945722992,7.69921875
4000,0.1568615260144386,15.44921875
5000,0.13156515504669675,9.7265625
6000,-0.1358904734856864,12.16015625
7000,-0.10511908929321523,12.6328125
8000,0.13174770641252376,1.88671875
9000,0.024319474027435395,2.359375
10000,-0.14388847398556137,4.86328125
11000,-0.14388847398556137,5.19140625
12000,-0.11240421611449691,25.125
13000,-0.14388847398556137,8.59375
14000,-0.13589247198656085,30.96875
15000,-0.14012435855268812,32.8828125
16000,-0.10031164778908785,14.68359375
17000,-0.1358904734856864,14.45703125
18000,-0.14388847398556137,17.10546875
19000,-0.13987341752382987,23.25
20000,-0.13992022001730742,19.984375
21000,-0.1283845980165691,20.68359375
22000,-0.1360740046132397,23.18359375
23000,-0.14388847398556137,35.23828125
24000,0.4067745232623746,38.765625
25000,-0.13589247198656085,41.1875
26000,-0.11687496723218471,29.30078125
27000,-0.14388847398556137,47.12890625
28000,-0.1083973467673659,50.73828125
29000,-0.13988847398556137,32.81640625
30000,-0.13188847398556136,35.2421875
31000,-0.14388847398556137,35.77734375
32000,-0.12072533575392996,40.8125
33000,-0.14388847398556137,38.6015625
34000,-0.13641463243100238,41.10546875
35000,-0.12789646998756032,41.9921875
36000,-0.13993590481560092,44.48046875
37000,-0.13985621592104525,44.88671875
38000,-0.13988847398556137,47.390625
39000,-0.13610734948756942,50.19140625
40000,-0.14388847398556137,52.73828125
41000,-0.14388847398556137,53.13671875
42000,-0.14388847398556137,76.7109375
43000,-0.12398421598606524,56.046875
44000,-0.13988847398556137,58.65234375
45000,-0.14388847398556137,59.11328125
46000,-0.12874824067704804,61.578125
47000,-0.14388847398556137,61.9453125
48000,-0.14388847398556137,64.4296875
49000,-0.12398421598606524,64.80078125
50000,-0.14388847398556137,65.515625
51000,-0.13988847398556137,67.73828125
52000,-0.13582598973260096,68.55078125
53000,-0.13189447098706064,71.22265625
54000,-0.14013847398556134,71.97265625
55000,-0.1401375362511278,74.37109375
56000,-0.13988947373562388,75.12109375
57000,-0.12389347273587381,77.25
58000,-0.14388847398556137,78.203125
59000,-0.14388847398556137,80.20703125
60000,-0.13586037564135667,81.671875
61000,-0.13988947373562388,83.16015625
62000,-0.11276297597759322,85.16015625
63000,-0.13613653600106523,86.25390625
64000,-0.13988947373562388,86.79296875
65000,-0.1358904734856864,89.23046875
66000,-0.07037738502468427,89.8046875
67000,-0.09356460751819717,92.29296875
68000,-0.13189447098706064,93.34375
69000,-0.09739400904091189,95.765625
70000,-0.14388847398556137,98.18359375
71000,-0.14388847398556137,99.09765625
72000,-0.13213847398556133,99.515625
73000,-0.1323827211091232,102.07421875
74000,-0.13988847398556137,102.51953125
75000,-0.13209424562922512,104.9453125
76000,-0.13607794236550597,105.47265625
77000,-0.13988847398556137,107.9921875
78000,-0.13592034649552154,108.4453125
79000,-0.14388847398556137,110.9453125
80000,-0.14388847398556137,111.51953125
81000,-0.1213173258010668,114.53125
82000,-0.08535920935324526,119.125
83000,-0.12454323589032323,117.4296875
84000,-0.04616290537771328,126.203125
85000,-0.14388847398556137,120.46484375
86000,-0.06986996935940482,127.68359375
87000,-0.14388847398556137,123.48828125
88000,-0.11618066542132965,133.29296875
89000,-0.13214141075136987,126.46484375
90000,-0.09275497272611555,140.37109375
91000,-0.13988847398556137,129.609375
92000,-0.09695072298154528,146.25
93000,-0.1401375362511278,133.18359375
94000,-0.06502729988629208,143.36328125
95000,-0.13238559826663165,128.60546875
96000,-0.0538659683591548,138.01953125
97000,-0.13214141075136987,131.44921875
98000,-0.1401375362511278,154.03125
99000,-0.1361053959037135,134.48828125
100000,-0.1282012229895454,134.95703125
101000,-0.12446132579128988,137.3828125
102000,-0.13641463243100238,137.9140625
103000,-0.13613847398556134,161.6875
104000,-0.1321355357510028,160.46875
105000,-0.13613847398556134,143.98046875
106000,-0.13613847398556134,144.52734375
107000,-0.14388847398556137,146.88671875
108000,-0.12421715924452548,150.640625
109000,-0.14388847398556137,155.12109375
110000,-0.09293465872451723,165.87109375
111000,-0.14388847398556137,158.32421875
112000,-0.08138847398556137,163.21875
113000,-0.12414834405052888,162.3671875
114000,-0.06959128523054126,167.07421875
115000,-0.14388847398556137,165.30078125
116000,-0.13614041100130747,182.70703125
117000,-0.14388847398556137,168.34375
118000,-0.13218237186850035,168.77734375
119000,-0.14388847398556137,171.35546875
120000,-0.06986996935940482,178.375
121000,-0.12439334776711597,192.6484375
122000,-0.12813847398556133,195.9921875
123000,-0.14388847398556137,177.83984375
124000,-0.13988947373562388,178.23828125
125000,-0.0897941811815911,201.44921875
126000,-0.14388847398556137,181.03515625
127000,-0.1358904734856864,183.5390625
128000,-0.1130090273452452,197.55859375
129000,-0.13988947373562388,186.63671875
130000,-0.13613653600106523,187.33984375
131000,-0.11663847398556138,202.4375
132000,-0.1363865985166941,190.546875
133000,-0.1363865985166941,193.1875
134000,-0.10479484848755338,193.6875
135000,-0.13988847398556137,196.19921875
136000,-0.12844638183114043,196.625
137000,-0.13607597398556137,199.203125
138000,-0.13588847398556136,199.64453125
139000,-0.13988947373562388,220.984375
140000,-0.11670784636015985,203.09765625
141000,-0.1401375362511278,205.71484375
142000,-0.11239439487243463,205.97265625
143000,-0.1005833470567411,214.73828125
144000,-0.13218237186850035,209.21875
145000,-0.14388847398556137,211.703125
146000,-0.13613847398556134,212.21484375
147000,-0.13613847398556134,215.234375
148000,-0.13586037564135667,215.63671875
149000,-0.14388847398556137,218.3203125
150000,-0.13582598973260096,218.82421875
151000,-0.14388847398556137,221.07421875
152000,-0.13592233009708743,217.7265625
153000,-0.14388847398556137,241.40234375
154000,-0.1398724097285332,220.7890625
155000,-0.14388847398556137,223.71484375
156000,-0.08515315781460409,232.1796875
157000,-0.1401082320500775,226.8046875
158000,-0.05036509314035009,230.4375
159000,-0.1358904734856864,229.8125
160000,-0.10072661702194785,240.390625
161000,-0.13184632646925432,254.1796875
162000,-0.13613653600106523,233.92578125
163000,-0.1401375362511278,236.30078125
164000,-0.14388847398556137,236.89453125
165000,-0.13218820014936516,239.2578125
166000,-0.13616935047958523,239.86328125
167000,-0.14388847398556137,257.89453125
168000,-0.14388847398556137,242.93359375
169000,-0.12863466053219808,245.3515625
170000,-0.1321355357510028,265.66796875
171000,-0.13610734948756942,249.0234375
172000,-0.13613653600106523,249.43359375
173000,-0.14388847398556137,251.83203125
174000,-0.07763847398556134,260.19140625
175000,-0.12438847398556141,254.87890625
176000,-0.13238559826663165,276.62109375
177000,-0.13614041100130747,258.58984375
178000,-0.1361961662932537,258.96484375
179000,-0.12438359776650665,261.34375
180000,-0.11664528478286207,282.90625
181000,-0.12813847398556133,264.48828125
182000,-0.14388847398556137,265.14453125
183000,-0.1401082320500775,267.5234375
184000,-0.13238559826663165,289.63671875
185000,-0.14388847398556137,270.98828125
186000,-0.09336321135424575,276.125
187000,-0.12789646998756032,274.109375
188000,-0.09713847398556141,282.890625
189000,-0.12813453550094023,299.31640625
190000,-0.09688847398556133,294.0078125
191000,-0.14388847398556137,281.4296875
192000,-0.11639534726724099,298.98046875
193000,-0.1321852867345653,284.96875
194000,-0.07686907363282769,294.05859375
195000,-0.14388847398556137,288.05859375
196000,0.036332409548575195,306.92578125
197000,-0.13242858360190413,291.3359375
198000,-0.08516783430540142,319.05078125
199000,-0.14388847398556137,295.60546875
200000,0.020570411293118984,317.1484375
201000,-0.14388847398556137,299.01953125
202000,-0.12423121592104525,317.1875
203000,-0.13613847398556134,323.421875
204000,-0.0891384739855614,305.05078125
205000,-0.13613847398556134,327.22265625
206000,-0.11190660543859587,306.375
207000,-0.12825571964312965,308.7578125
208000,-0.10887972179751437,309.94140625
209000,-0.13988947373562388,328.1171875
210000,-0.1163884739855614,325.6796875
211000,-0.13214141075136987,329.4921875
212000,-0.10873026203176928,336.23828125
213000,-0.14388847398556137,318.30859375
214000,-0.1280791891674936,334.7890625
215000,-0.13607597398556137,321.21484375
216000,-0.10887972179751437,356.40625
...@@ -19,6 +19,7 @@ const args = require("yargs") ...@@ -19,6 +19,7 @@ const args = require("yargs")
.nargs("verbose", 0) .nargs("verbose", 0)
.argv; .argv;
var run; var run;
var to_run = []; var to_run = [];
var options = []; var options = [];
...@@ -82,6 +83,7 @@ run = function (callback) { ...@@ -82,6 +83,7 @@ run = function (callback) {
}; };
fs.readFile("./config.json", "utf8", function (err, data) { fs.readFile("./config.json", "utf8", function (err, data) {
if (err) { if (err) {
return console.log("Error while reading config file : " + err); return console.log("Error while reading config file : " + err);
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
var childProcess = require("child_process"); var childProcess = require("child_process");
var cut_file = require("./random_gen").cut_file; var cut_file = require("./random_gen").cut_file;
var diskspace = require("diskspace"); // var diskspace = require("diskspace");
// var os_utils = require("os-utils"); // var os_utils = require("os-utils");
var os = require('os'); // var os = require('os');
const puppeteer = require("puppeteer"); const puppeteer = require("puppeteer");
const Server = require("ws").Server; const Server = require("ws").Server;
const args = require("yargs") const args = require("yargs")
...@@ -28,8 +28,9 @@ var page; ...@@ -28,8 +28,9 @@ var page;
var n = 0; var n = 0;
var time; var time;
var monitor; var monitor;
var ramBefore; // var ramBefore;
var memBefore; // var memBefore;
var browser_pid;
function init_server (){ function init_server (){
var port = 9030; var port = 9030;
...@@ -92,10 +93,11 @@ async function query (){ ...@@ -92,10 +93,11 @@ async function query (){
files = cut_file(args.file, 1000); files = cut_file(args.file, 1000);
init_server(); init_server();
browser = await puppeteer.launch(); browser = await puppeteer.launch();
browser_pid = browser.process().pid;
page = await browser.newPage(); page = await browser.newPage();
await page.goto(link); await page.goto(link);
monitor = childProcess.fork("./unit_tests/monitor.js", monitor = childProcess.fork("./unit_tests/monitor.js",
args.r ? ["-r"] : []); args.r ? ["-r", "-p", browser_pid] : ["-p", browser_pid]);
timeout(); timeout();
query(); query();
// diskspace.check("C", function (err, result){ // diskspace.check("C", function (err, result){
......
var os = require('os');
const fs = require("fs"); const fs = require("fs");
var diskspace = require("diskspace"); var diskspace = require("diskspace");
const args = require("yargs").argv; const args = require("yargs").argv;
var childProcess = require("child_process");
var pid = args.p;
var path = args.r var path = args.r
? "./results/add_random_csv_monitor.csv" ? "./results/add_random_csv_monitor.csv"
: "./results/add_csv_monitor.csv"; : "./results/add_csv_monitor.csv";
...@@ -10,35 +11,36 @@ var stream = fs.createWriteStream(path, {flags: "w+"}); ...@@ -10,35 +11,36 @@ var stream = fs.createWriteStream(path, {flags: "w+"});
stream.write("time,ram,disk\n"); stream.write("time,ram,disk\n");
var start_disk; var start_disk;
var start_ram = os.totalmem() - os.freemem();
function init_monitor(){
// function init_server (){ var net = require('net');
// var port = 9030; const port = 9040;
// var ws = new Server({port: port});
// ws.on("connection", function(w){ var server = net.createServer(function(socket) {
// w.on("message", function(){ socket.on("data", function(data){
// process.send(max_ram); diskspace.check("/", function(err, result){
// }); var disk_used = result.used - start_disk;
// w.on("close", function() { var ram_used = data;
// ws.close(); stream.write(Date.now() + "," + ram_used + "," + disk_used + "\n");
// }); });
// }); })
// } socket.on("error", function(err){
console.log("Error : " + err.message);
var check = function(){ })
setTimeout(function () { });
diskspace.check("/", function(err, result){
//var disk_used = parseInt(result.used) - parseInt(start_disk); server.listen(port, function() {});
var disk_used = result.used - start_disk;
var ram_used = os.totalmem() - os.freemem(); var monitor = childProcess.spawn('python',
stream.write(Date.now() + "," + ram_used + "," + disk_used + "\n"); ["./unit_tests/monitor.py", "--p", pid],
check(); { stdio: 'inherit' });
});
}, 1);
} }
//init_server(); process.on("exit", function(){
monitor.kill();
})
diskspace.check("C", function (err, result){ diskspace.check("C", function (err, result){
start_disk = result.used; start_disk = result.used;
check(); init_monitor();
}); });
import psutil
import os
import subprocess
import time
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument("--p", type=int, help="pid")
args = parser.parse_args()
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('localhost', 9040))
class _Snapshot(object):
def get(self, property, default=None):
return getattr(self, property, default)
class ProcessSnapshot(_Snapshot):
def __init__(self, process=None):
assert type(process) is psutil.Process
self.username = process.username()
self.process_object = process
self.pid = process.pid
# Memory percentage
self.memory_percent = process.memory_percent()
def update_memory_percent(self):
if self.process_object.is_running():
self.memory_percent = self.process_object.memory_percent()
process = psutil.Process(args.p)
snapshot = ProcessSnapshot(process)
while (1) :
snapshot.update_memory_percent()
client.send(str(snapshot.memory_percent))
time.sleep(0.1)
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