-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrab_lively_data.php
50 lines (44 loc) · 2.6 KB
/
grab_lively_data.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//----------------------------------------------------------------------
// Copyright (c) 2012-2015 Raytheon BBN Technologies
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and/or hardware specification (the "Work") to
// deal in the Work without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Work, and to permit persons to whom the Work
// 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 Work.
//
// THE WORK 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 WORK OR THE USE OR OTHER DEALINGS
// IN THE WORK.
//----------------------------------------------------------------------
$lively_url = "http://www.lively-web.org/nodejs/GEC22ReportServer/all_reports/";
$data = file_get_contents($lively_url);
// error_log("DATA = " . $data);
$jdata = json_decode($data);
// error_log("JDATA = " . print_r($data, true));
$latest_time_per_server = array();
foreach($jdata as $record) {
$total_time = intval($record->totalTime);
$timestamp = intval($record->timestamp);
$server = $record->server;
if (!(array_key_exists($server, $latest_time_per_server))) {
$latest_time_per_server[$server] = array('timestamp' => -1, 'total_time' => 0);
}
$record_server = $latest_time_per_server[$server];
if($timestamp > $record_server['timestamp']) {
$new_record_server = array('timestamp' => $timestamp, 'total_time' => $total_time);
$latest_time_per_server[$server] = $new_record_server;
}
}
print json_encode($latest_time_per_server);
?>