forked from simonebrunozzi-zz/simplewebpage2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
75 lines (65 loc) · 1.5 KB
/
index.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
<!DOCTYPE html>
<html>
<body>
<div align="center">
<h1 style="font-family:verdana;">CPU Stress test Page</h1>
<p style="font-family:verdana;font-size:130%;color:black">
<?php
echo "This machine is: ";
echo gethostname();
?>
</p>
<?php
$EC2_AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`;
if ($EC2_AZ == 'eu-central-1a') $COLOR="blue";
if ($EC2_AZ == 'eu-central-1b') $COLOR="green";
if ($EC2_AZ == 'eu-central-1c') $COLOR="red";
echo '<p style="font-family:verdana;font-size:180%;color:'.$COLOR.'">'.$EC2_AZ;
?>
</p>
<br><br><br>
<p style="font-family:verdana;font-size:120%;color:black">
CPU Stress test performed.
</p>
<?php
// CPU stress test
for($i = 0; $i < 100000000; $i++) {
$a += $i;
}
?>
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<p style="font-family:verdana;font-size:90%;color:black">';
echo 'Page generated in '.$total_time.' seconds.';
echo '</p>';
?>
<p style="font-family:verdana;font-size:100%;color:black">
Page reloads: <?php
if (isset($_GET['reload'])){
echo ($_GET['reload']);
} else {
echo "0";
}
?>
</p>
</div>
<script>
var url = new URL(window.location.href);
var reload = url.searchParams.get("reload");
reload++;
setTimeout(() => {
window.location.href = window.location.origin + "/?reload=" + reload;
}, 100);
</script>
</body>
</html>