To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

update_stats.php 18.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
 * Copyright (c) 2010 - 2020, ETH Zurich, Computer Engineering Group
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * * Neither the name of the copyright holder nor the names of its
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
33
34
?>
<?php
Reto Da Forno's avatar
Reto Da Forno committed
35
set_include_path(get_include_path() . PATH_SEPARATOR . "/home/flocklab/webserver");
36
37
38
39
40
41
42

require_once('include/libflocklab.php');

if (!set_time_limit(120)) {
  die("unable to set max. execution time");
}

Reto Da Forno's avatar
Reto Da Forno committed
43
$statsFileName = "/home/flocklab/webserver/statistics.dat";
44
45


Reto Da Forno's avatar
Reto Da Forno committed
46
function collect_stats($filename, $monthly)
47
48
49
{
  if (!is_string($filename)) return;

50
  $testoverhead = 2 * 1 * 60;           // config value
Reto Da Forno's avatar
Reto Da Forno committed
51

52
  // --- start data collection ---
Reto Da Forno's avatar
Reto Da Forno committed
53

54
  //$citations = shell_exec("./scripts/scholar.py -C 10650874796619438829 -c 1 | grep Citations -m 1 | awk '{ print $2 }'");  // citation count
Reto Da Forno's avatar
Reto Da Forno committed
55
56
57

  $db  = db_connect();

58
  $sql = "select count(*) as num from tbl_serv_users";
Reto Da Forno's avatar
Reto Da Forno committed
59
  $rs  = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
60
61
  $row = mysqli_fetch_array($rs);
  $usercnt = $row['num'];
Reto Da Forno's avatar
Reto Da Forno committed
62

63
  $sql = "select COUNT(*) as num from tbl_serv_users where datediff(DATE_SUB(DATE_SUB(CURDATE(),INTERVAL (DAY(CURDATE())-1) DAY),INTERVAL 12 MONTH),last_login) <=0 and is_active=1";
Reto Da Forno's avatar
Reto Da Forno committed
64
  $rs  = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
65
66
  $row = mysqli_fetch_array($rs);
  $usercntactive = $row['num'];
Reto Da Forno's avatar
Reto Da Forno committed
67

68
  $sql = 'select country, count(country) as num from tbl_serv_users group by country';
Reto Da Forno's avatar
Reto Da Forno committed
69
  $rs  = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  $countries['others'] = 0;
  $countrycnt = 0;
  while ($row = mysqli_fetch_array($rs)) {
    $countrycnt = $countrycnt + 1;
    if (intval($row['num']) < 5) {
      $countries['others'] += intval($row['num']);
    } else {
      $countries[$row['country']] = intval($row['num']);
    }
  }
  arsort($countries);
  $sql = 'select institution, count(institution) as num from tbl_serv_users group by institution';
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  $institutions['others'] = 0;
  $institutioncnt = 0;
  while ($row = mysqli_fetch_array($rs)) {
    $institutioncnt = $institutioncnt + 1;
    if (intval($row['num']) < 5) {
      $institutions['others'] += intval($row['num']);
    } else {
      $institutions[$row['institution']] = intval($row['num']);
    }
  }
  arsort($institutions);
  // number of tests per year and mote, including service type
Reto Da Forno's avatar
Reto Da Forno committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  $tests_per_year         = Array();
  $testcnt                = 0;
  $tests_per_mote         = Array();
  $tmotetests_per_year    = Array();
  $tmotetestcnt           = 0;
  $dpptests_per_year      = Array();
  $dpptestcnt             = 0;
  $dpp2tests_per_year     = Array();
  $dpp2testcnt            = 0;
  $nrftests_per_year      = Array();
  $nrftestcnt             = 0;
  $serial_per_year        = Array();
  $serialcnt              = 0;
  $gpiotracing_per_year   = Array();
  $gpiotracingcnt         = 0;
110
  $gpioactuation_per_year = Array();
Reto Da Forno's avatar
Reto Da Forno committed
111
112
113
  $gpioactuationcnt       = 0;
  $powerprof_per_year     = Array();
  $powerprofcnt           = 0;
Reto Da Forno's avatar
Reto Da Forno committed
114
115
  $debug_per_year         = Array();
  $debugcnt               = 0;
Reto Da Forno's avatar
Reto Da Forno committed
116
117

  $sql = "select month(time_start_act) as m, year(time_start_act) as y, count(*) as num from tbl_serv_tests where time_start_act is not null group by ".($monthly ? "y, m" : "y");
118
119
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  while ($row = mysqli_fetch_array($rs)) {
Reto Da Forno's avatar
Reto Da Forno committed
120
121
122
123
124
    $year  = $row['y'];
    $month = $row['m'];
    $index = ($monthly ? sprintf("%d-%02d", intval($year), intval($month)) : $year);   // index in the output array
    $tests_per_year[$index] = $row['num'];
    $testcnt                = $testcnt + $row['num'];
125
    // initialize with 0
Reto Da Forno's avatar
Reto Da Forno committed
126
127
128
129
130
    $tmotetests_per_year[$index] = 0;
    $dpptests_per_year[$index]   = 0;
    $dpp2tests_per_year[$index]  = 0;
    $nrftests_per_year[$index]   = 0;
    $sql = "select pname, count(*) as c from (select distinct test_fk, tbl_serv_platforms.name as pname from tbl_serv_map_test_observer_targetimages left join tbl_serv_targetimages on (targetimage_fk = serv_targetimages_key) left join tbl_serv_platforms on (platforms_fk = serv_platforms_key)) as a left join tbl_serv_tests as b on (a.test_fk = b.serv_tests_key) where year(time_start_act) = $year".($monthly ? " and month(time_start_act) = $month" : "")." and pname is not null group by pname";
131
132
133
134
135
136
137
    $rs2 = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
    while ($row = mysqli_fetch_array($rs2)) {
      if (array_key_exists($row['pname'], $tests_per_mote)) {
        $tests_per_mote[$row['pname']] = $tests_per_mote[$row['pname']] + $row['c'];
      } else {
        $tests_per_mote[$row['pname']] = $row['c'];
      }
Reto Da Forno's avatar
Reto Da Forno committed
138
      $val = $row['c'];   // or as percent: round($row['c'] * 100 / $tests_per_year[$index])
139
      if ($row['pname'] == 'Tmote') {
Reto Da Forno's avatar
Reto Da Forno committed
140
        $tmotetests_per_year[$index] = $val;
141
142
        $tmotetestcnt = $tmotetestcnt + $row['c'];
      } else if ($row['pname'] == 'DPP') {
Reto Da Forno's avatar
Reto Da Forno committed
143
        $dpptests_per_year[$index] = $val;
144
145
        $dpptestcnt = $dpptestcnt + $row['c'];
      } else if ($row['pname'] == 'DPP2LoRa') {
Reto Da Forno's avatar
Reto Da Forno committed
146
        $dpp2tests_per_year[$index] = $val;
147
        $dpp2testcnt = $dpp2testcnt + $row['c'];
148
      } else if ($row['pname'] == 'nRF5') {
Reto Da Forno's avatar
Reto Da Forno committed
149
        $nrftests_per_year[$index] = $val;
150
        $nrftestcnt = $nrftestcnt + $row['c'];
Reto Da Forno's avatar
Reto Da Forno committed
151
      }
152
153
    }
    // Tests by service
Reto Da Forno's avatar
Reto Da Forno committed
154
    $sql = "select sum(ExtractValue(testconfig_xml, 'count(/testConf/serialConf|/testConf/serialReaderConf)') > 0) as num_serial, sum(ExtractValue(testconfig_xml, 'count(/testConf/gpioTracingConf|/testConf/gpioMonitorConf)') > 0) as num_tracing, sum(ExtractValue(testconfig_xml, 'count(/testConf/gpioActuationConf|/testConf/gpioSettingConf)') > 0) as num_actuation, sum(ExtractValue(testconfig_xml, 'count(/testConf/powerProfilingConf|/testConf/powerprofConf)') > 0) as num_power, sum(ExtractValue(testconfig_xml, 'count(/testConf/debugConf)') > 0) as num_debug from tbl_serv_tests where year(time_start_act) = $year".($monthly ? " and month(time_start_act) = $month" : "");
155
156
    $rs3 = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
    $row = mysqli_fetch_array($rs3);
Reto Da Forno's avatar
Reto Da Forno committed
157
158

    $serial_per_year[$index] = round($row['num_serial'] * 100 / $tests_per_year[$index]);
159
    $serialcnt = $serialcnt + $row['num_serial'];
Reto Da Forno's avatar
Reto Da Forno committed
160
    $gpiotracing_per_year[$index] = round($row['num_tracing'] * 100 / $tests_per_year[$index]);
161
    $gpiotracingcnt = $gpiotracingcnt + $row['num_tracing'];
Reto Da Forno's avatar
Reto Da Forno committed
162
    $gpioactuation_per_year[$index] = round($row['num_actuation'] * 100 / $tests_per_year[$index]);
163
    $gpioactuationcnt = $gpioactuationcnt + $row['num_actuation'];
Reto Da Forno's avatar
Reto Da Forno committed
164
    $powerprof_per_year[$index] = round($row['num_power'] * 100 / $tests_per_year[$index]);
165
    $powerprofcnt = $powerprofcnt + $row['num_power'];
Reto Da Forno's avatar
Reto Da Forno committed
166
167
    $debug_per_year[$index] = round($row['num_debug'] * 100 / $tests_per_year[$index]);
    $debugcnt = $debugcnt + $row['num_debug'];
168
169
  }
  arsort($tests_per_mote);
Reto Da Forno's avatar
Reto Da Forno committed
170

171
  // Users by service and node type
Reto Da Forno's avatar
Reto Da Forno committed
172
173
174
175
176
177
178
  $activeusers_per_year        = Array();
  $tmoteusers_per_year         = Array();
  $dppusers_per_year           = Array();
  $dpp2users_per_year          = Array();
  $nrfusers_per_year           = Array();
  $serialusers_per_year        = Array();
  $gpiotracingusers_per_year   = Array();
179
  $gpioactuationusers_per_year = Array();
Reto Da Forno's avatar
Reto Da Forno committed
180
  $powerprofusers_per_year     = Array();
Reto Da Forno's avatar
Reto Da Forno committed
181
  $debugusers_per_year         = Array();
Reto Da Forno's avatar
Reto Da Forno committed
182
  $sql = "select month(time_start_act) as m, year(time_start_act) as y, count(distinct owner_fk) as num from tbl_serv_tests group by ".($monthly ? "y, m" : "y")." having y is not null";
183
184
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  while ($row = mysqli_fetch_array($rs)) {
Reto Da Forno's avatar
Reto Da Forno committed
185
186
    $year      = $row['y'];
    $month     = $row['m'];
187
    $num_users = $row['num'];
Reto Da Forno's avatar
Reto Da Forno committed
188
189
    $index     = ($monthly ? sprintf("%d-%02d", intval($year), intval($month)) : $year);
    $activeusers_per_year[$index] = $row['num'];
190
    // initialize with 0
Reto Da Forno's avatar
Reto Da Forno committed
191
192
193
194
195
    $tmoteusers_per_year[$index] = 0;
    $dppusers_per_year[$index]   = 0;
    $dpp2users_per_year[$index]  = 0;
    $nrfusers_per_year[$index]   = 0;
    $sql = "select pname, count(distinct owner_fk) as c from (select distinct test_fk, tbl_serv_platforms.name as pname from tbl_serv_map_test_observer_targetimages left join tbl_serv_targetimages on (targetimage_fk = serv_targetimages_key) left join tbl_serv_platforms on (platforms_fk = serv_platforms_key)) as a left join tbl_serv_tests as b on (a.test_fk = b.serv_tests_key) where year(time_start_act) = $year".($monthly ? " and month(time_start_act) = $month" : "")." and time_start_act is not null and pname is not null group by pname";
196
197
198
    $rs2 = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
    while ($row = mysqli_fetch_array($rs2)) {
      if ($row['pname'] == 'Tmote') {
Reto Da Forno's avatar
Reto Da Forno committed
199
        $tmoteusers_per_year[$index] = round($row['c'] / $num_users * 100);    // in percent
200
      } else if ($row['pname'] == 'DPP') {
Reto Da Forno's avatar
Reto Da Forno committed
201
        $dppusers_per_year[$index]   = round($row['c'] / $num_users * 100);
202
      } else if ($row['pname'] == 'DPP2LoRa') {
Reto Da Forno's avatar
Reto Da Forno committed
203
        $dpp2users_per_year[$index]  = round($row['c'] / $num_users * 100);
204
      } else if ($row['pname'] == 'nRF5') {
Reto Da Forno's avatar
Reto Da Forno committed
205
        $nrfusers_per_year[$index]   = round($row['c'] / $num_users * 100);
206
207
      }
    }
Reto Da Forno's avatar
Reto Da Forno committed
208
    $sql = "select sum(num_all > 0) as user_all, sum(num_serial > 0) as user_serial, sum(num_tracing > 0) as user_tracing, sum(num_actuation > 0) as user_actuation, sum(num_power > 0) as user_power, sum(num_debug > 0) as user_debug from (select sum(1) as num_all, sum(ExtractValue(testconfig_xml, 'count(/testConf/serialConf|/testConf/serialReaderConf)') > 0) as num_serial, sum(ExtractValue(testconfig_xml, 'count(/testConf/gpioTracingConf|/testConf/gpioMonitorConf)') > 0) as num_tracing, sum(ExtractValue(testconfig_xml, 'count(/testConf/gpioActuationConf|/testConf/gpioSettingConf)') > 0) as num_actuation, sum(ExtractValue(testconfig_xml, 'count(/testConf/powerProfilingConf|/testConf/powerprofConf)') > 0) as num_power, sum(ExtractValue(testconfig_xml, 'count(/testConf/debugConf)') > 0) as num_debug from tbl_serv_tests where year(time_start_act) = $year".($monthly ? " and month(time_start_act) = $month" : "")." and (test_status_preserved in ('finished', 'retention expiring', 'synced') or test_status_preserved is null) group by owner_fk) as stats;";
209
210
    $rs3 = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
    $row = mysqli_fetch_array($rs3);
Reto Da Forno's avatar
Reto Da Forno committed
211
212
213
214
    $serialusers_per_year[$index]        = round($row['user_serial'] / $num_users * 100);        // in percent
    $gpiotracingusers_per_year[$index]   = round($row['user_tracing'] / $num_users * 100);
    $gpioactuationusers_per_year[$index] = round($row['user_actuation'] / $num_users * 100);
    $powerprofusers_per_year[$index]     = round($row['user_power'] / $num_users * 100);
Reto Da Forno's avatar
Reto Da Forno committed
215
    $debugusers_per_year[$index]         = round($row['user_debug'] / $num_users * 100);
Reto Da Forno's avatar
Reto Da Forno committed
216
  }
217
  $sql = 'select avg(setuptime) as tsetup, avg(cleanuptime) as tcleanup, avg(timestampdiff(SECOND, time_start_act, time_end_act)) as avgruntime from tbl_serv_tests where time_start_act is not null and time_end_act is not null';
Reto Da Forno's avatar
Reto Da Forno committed
218
  $rs  = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
219
  $row = mysqli_fetch_array($rs);
Reto Da Forno's avatar
Reto Da Forno committed
220
221
  $avgruntime     = intval($row['avgruntime']);
  $avgsetuptime   = intval($row['tsetup']);
222
223
224
225
226
227
228
229
230
  $avgcleanuptime = intval($row['tcleanup']);
  // runtime median  
  $runtime = Array();
  $sql = 'select timestampdiff(SECOND, time_start_act, time_end_act) as runtime from tbl_serv_tests where time_start_act is not null and time_end_act is not null';
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  while ($row = mysqli_fetch_array($rs)) {
    $runtime[] = $row['runtime'];
  }
  sort($runtime, SORT_NUMERIC) or flocklab_die('Array sort failed');
Reto Da Forno's avatar
Reto Da Forno committed
231
  $cnt        = count($runtime);
232
  $runtimecdf = Array();
Reto Da Forno's avatar
Reto Da Forno committed
233
234
235
  $cdfelem    = 20;
  $step       = intval($runtime[round($cnt * ($cdfelem - 1) / $cdfelem)] / $cdfelem);  // equally spaced in time
  $tcurr      = $step;
236
237
238
  for ($i = 0; $i < $cnt && $cdfelem; $i++) {
    if ($runtime[$i] >= $tcurr) {
      $runtimecdf[(string)round($tcurr / 60)] = round($i * 100 / $cnt);   // calc the percentage at this point
Reto Da Forno's avatar
Reto Da Forno committed
239
      $tcurr  += $step;
240
241
      $cdfelem = $cdfelem - 1;
    }
Reto Da Forno's avatar
Reto Da Forno committed
242
  }
243
244
  // occupancy per year in percent
  $utilization_per_year = Array();
Reto Da Forno's avatar
Reto Da Forno committed
245
  $sql = "select year(time_start_act) as y, month(time_start_act) as m, min(time_start_act) as minp, max(time_end_act) as maxp, max(time_end_act - time_start_act), sum(timestampdiff(SECOND,time_start_act,time_end_act)) as duration from tbl_serv_tests where (time_end_act is not null and time_start_act is not null and time_start_act < time_end_act and timestampdiff(SECOND,time_start_act,time_end_act) < 72 * 3600) group by ".($monthly ? "y, m" : "y");
246
247
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  while ($row = mysqli_fetch_array($rs)) {
Reto Da Forno's avatar
Reto Da Forno committed
248
249
    $index = ($monthly ? sprintf("%d-%02d", intval($row['y']), intval($row['m'])) : $row['y']);
    $utilization_per_year[$index] = round((($row['duration'] + $tests_per_year[$index] * $testoverhead) / (strtotime($row['maxp']) - strtotime($row['minp'])) * 100));
250
251
252
253
254
255
256
  }
  // occupancy of last 12 month, weekly resolution
  $sql = 'select year(time_start_act) as y, week(time_start_act,3) as w, count(*) as num, sum(timestampdiff(SECOND, time_start_act, time_end_act)) as runtime from tbl_serv_tests where 
          datediff(DATE_SUB(DATE_SUB(CURDATE(),INTERVAL (DAY(CURDATE())-1) DAY),INTERVAL 12 MONTH),time_start_act) <=0 group by year(time_start_act), week(time_start_act,3) having y is not null';
  $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get statistics from database because: ' . mysqli_error($db));
  $utilization_per_week = Array();
  while ($row = mysqli_fetch_array($rs)) {
Reto Da Forno's avatar
Reto Da Forno committed
257
    $utilization_per_week['week '.$row['w']] = round(($row['runtime'] + $row['num'] * $testoverhead) * 100 / 604800);
258
  }
Reto Da Forno's avatar
Reto Da Forno committed
259

260
261
262
263
264
265
  // --- data collection finished ---

  // put together the new .dat file
  $new_stats = "
[general]
last_update = ".(string)time()."
Reto Da Forno's avatar
Reto Da Forno committed
266
granularity = ".($monthly ? "month" : "year")."
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

[users]
registered = ".(string)$usercnt."
active = ".(string)$usercntactive."
num_countries = ".(string)$countrycnt."
country = \"".str_replace('"', '\'', serialize($countries))."\"
num_institutions = ".(string)$institutioncnt."
institution = \"".str_replace('"', '\'', serialize($institutions))."\"
users_per_year = \"".str_replace('"', '\'', serialize($activeusers_per_year))."\"

[tests]
num_tests = ".(string)$testcnt."
tests_per_year = \"".str_replace('"', '\'', serialize($tests_per_year))."\"
tests_per_mote = \"".str_replace('"', '\'', serialize($tests_per_mote))."\"
avg_setup_time = ".(string)$avgsetuptime."
avg_cleanup_time = ".(string)$avgcleanuptime."
avg_runtime = ".(string)$avgruntime."
runtime_cdf = \"".str_replace('"', '\'', serialize($runtimecdf))."\"
utilization_per_year = \"".str_replace('"', '\'', serialize($utilization_per_year))."\"
utilization_per_week = \"".str_replace('"', '\'', serialize($utilization_per_week))."\"

[motes]
tmote_tests = ".(string)$tmotetestcnt."
tmote_per_year = \"".str_replace('"', '\'', serialize($tmotetests_per_year))."\"
tmoteusers_per_year = \"".str_replace('"', '\'', serialize($tmoteusers_per_year))."\"
dpp_tests = ".(string)$dpptestcnt."
dpp_per_year = \"".str_replace('"', '\'', serialize($dpptests_per_year))."\"
dppusers_per_year = \"".str_replace('"', '\'', serialize($dppusers_per_year))."\"
dpp2_tests = ".(string)$dpp2testcnt."
dpp2_per_year = \"".str_replace('"', '\'', serialize($dpp2tests_per_year))."\"
dpp2users_per_year = \"".str_replace('"', '\'', serialize($dpp2users_per_year))."\"
Reto Da Forno's avatar
Reto Da Forno committed
298
299
300
nrf_tests = ".(string)$nrftestcnt."
nrf_per_year = \"".str_replace('"', '\'', serialize($nrftests_per_year))."\"
nrfusers_per_year = \"".str_replace('"', '\'', serialize($nrfusers_per_year))."\"
301
302
303
304
305
306
307
308
309
310
311
312
313
314

[services]
serial_tests = ".(string)$serialcnt."
serial_per_year = \"".str_replace('"', '\'', serialize($serial_per_year))."\"
serialusers_per_year = \"".str_replace('"', '\'', serialize($serialusers_per_year))."\"
gpiotracing_tests = ".(string)$gpiotracingcnt."
gpiotracing_per_year = \"".str_replace('"', '\'', serialize($gpiotracing_per_year))."\"
gpiotracingusers_per_year = \"".str_replace('"', '\'', serialize($gpiotracingusers_per_year))."\"
gpioactuation_tests = ".(string)$gpioactuationcnt."
gpioactuation_per_year = \"".str_replace('"', '\'', serialize($gpioactuation_per_year))."\"
gpioactuationusers_per_year = \"".str_replace('"', '\'', serialize($gpioactuationusers_per_year))."\"
powerprof_tests = ".(string)$powerprofcnt."
powerprof_per_year = \"".str_replace('"', '\'', serialize($powerprof_per_year))."\"
powerprofusers_per_year = \"".str_replace('"', '\'', serialize($powerprofusers_per_year))."\"
Reto Da Forno's avatar
Reto Da Forno committed
315
316
317
debug_tests = ".(string)$debugcnt."
debug_per_year = \"".str_replace('"', '\'', serialize($debug_per_year))."\"
debugusers_per_year = \"".str_replace('"', '\'', serialize($debugusers_per_year))."\"
318
319
320
321
322
323
324

";

  // write the stats into the file
  file_put_contents($filename, $new_stats);
}

Reto Da Forno's avatar
Reto Da Forno committed
325
collect_stats($statsFileName, true);
326
?>