-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreboot-test.php
55 lines (55 loc) · 1.29 KB
/
reboot-test.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
<html>
<head>
<style>
body{
background: url(background.jpg) no-repeat center center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
h1{
color: white;
text-align: right;
font-style: italic;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
h3{
color: white;
text-align: right;
font-style: italic;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
p{
color: white;
}
</style>
</head>
<body>
<h1><?php print gethostname(); ?></h1>
<h3><?php
$grace = 300;
$now = 3600;
$diff = 0;
$contents = array();
$contents['USEC'] = 0;
$load = sys_getloadavg();
$response = "System up; load averages: $load[0] | $load[1] | $load[2]\n";
if ( file_exists ( "/var/run/systemd/shutdown/scheduled" ) ) {
$contents = parse_ini_file ( "/var/run/systemd/shutdown/scheduled" );
#print_r ($contents);
$now = date("U");
$diff = ( round ( $contents['USEC'] / 1000000 ) ) - $now;
$response = "Error 503 - Service Unavailable: System rebooting in $diff seconds\n";
if ( ( 0 < $diff) && ( $diff < $grace ) ) {
http_response_code(503);
} else {
http_response_code(200);
}
} else {
http_response_code(200);
}
print $response;
?></h3>
</body>
</html>