forked from sergeychernyshev/showslow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor.php
53 lines (41 loc) · 1.36 KB
/
monitor.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
51
52
<?php
require_once(dirname(__FILE__).'/global.php');
header('Content-type: text/plain');
// whatever to display all URLs or only new ones, just recently added
$new = false;
if (array_key_exists('new', $_GET)) {
$new = true;
}
if (array_key_exists('refresh', $_GET) && array_key_exists('beacon', $_GET)) {
if ($_GET['beacon'] == 'yslow') {
$query = "SELECT DISTINCT url FROM urls WHERE y_refresh_request <> 0";
}
else if ($_GET['beacon'] == 'pagespeed') {
$query = "SELECT DISTINCT url FROM urls WHERE x_refresh_request <> 0";
}
else if ($_GET['beacon'] == 'dynatrace') {
$query = "SELECT DISTINCT url FROM urls WHERE dt_refresh_request <> 0";
}
} else if ($new) {
$query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id WHERE DATE_ADD(added, INTERVAL %d HOUR) > NOW()";
foreach ($all_metrics as $provider_name => $provider) {
$query .= " AND ".$provider['table'].'_last_id IS NULL';
}
$query = sprintf($query, $monitoringPeriod);
} else {
$query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id";
}
$result = mysql_query($query);
if (!$result) {
error_log(mysql_error());
}
$urls = array();
while ($row = mysql_fetch_assoc($result)) {
$url = validateURL($row['url'], false);
if (is_null($url)) {
continue;
}
$urls[] = $url;
}
mysql_free_result($result);
echo implode("\n", $urls);