-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoverview.php
196 lines (170 loc) · 6.41 KB
/
overview.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/*
TinyMTR Web Monitor
Version 1.5.0
https://picotory.com
overview.php
*/
include ("config.php");
# Not logged in
if(!isset($_SESSION['Logged_In']) || !isset($_SESSION['User'])) {
header("Location: login" . $x);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>TinyMTR : Painless Server Monitoring</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="iAlex">
<meta name="description" content="TinyMTR is a simple server monitoring tool">
<link rel="shortcut icon" href="img/favicon.ico" />
<link href='//brick.a.ssl.fastly.net/Open+Sans:300i,400i,600i,700i,400,300,600,700' rel='stylesheet' type='text/css'>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet" media="screen">
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 960px;
overflow:hidden;
}
.container-narrow > hr {
margin: 30px 0;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
</style>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-narrow">
<div class="masthead">
<img style="margin:0 auto; display:block;" src="img/logo.png" /><br />
<ul class="nav nav-pills nav-justified">
<li class="active sideSpace"><a href="overview<?php echo $x; ?>"><?php echo $l['Overview']; ?></a></li>
<li class="sideSpace"><a href="monitor<?php echo $x; ?>"><?php echo $l['Monitors']; ?></a></li>
<?php
if($MULTISERV) {
echo '<li class="sideSpace"><a href="remote' . $x . '">' . $l['Remote'] . '</a></li>';
}
echo '<li class="sideSpace"><a href="settings' . $x . '">' . $l['Settings'] . '</a></li>';
?>
<li class="sideSpace"><a href="logout<?php echo $x; ?>"><?php echo $l['Logout']; ?></a></li>
</ul>
</div>
<hr>
<?php
# Count the servers
$stmt = $dbh->prepare("SELECT * FROM servers WHERE userid = :userid");
$stmt->bindParam(':userid', $_SESSION['UserID']);
$stmt->execute();
$serDetails = $stmt->fetchAll(PDO::FETCH_ASSOC);
# See how many there are
$countSer = count($serDetails);
# Count the records
$stmt = $dbh->prepare("SELECT COUNT(*) FROM records WHERE userid = :userid");
$stmt->bindParam(':userid', $_SESSION['UserID']);
$stmt->execute();
$recDetails = $stmt->fetchAll(PDO::FETCH_ASSOC);
# Strip the beginning as the function adds this
$siteAdd = removePrefix($siteLoc);
$siteAdd = rtrim($siteAdd, "/");
# Get the local server info
$getInfo = getServerInfo($siteAdd, $externalFile);
$getMemPercent = round(($getInfo['memoryused'] / $getInfo['memorytotal']) * 100);
$memLeft = $getInfo['memorytotal'] - $getInfo['memoryused'];
# Style the progress bar according to usage
if($getMemPercent < 75) {
$memClass = 'progress-bar-success';
}else if($getMemPercent < 90 && $getMemPercent >= 75){
$memClass = 'progress-bar-warning';
}else if($getMemPercent >= 90){
$memClass = 'progress-bar-danger';
}
# Work out disk space
$dSpaceKB = (disk_total_space("/")/1024);
$dSpaceMB = $dSpaceKB/1024;
$dSpaceGB = round($dSpaceMB/1024, 2);
$dFSpaceKB = (disk_free_space("/")/1024);
$dFSpaceMB = $dFSpaceKB/1024;
$dFSpaceGB = round($dFSpaceMB/1024, 1);
$dsUsed = round($dSpaceGB - $dFSpaceGB, 1);
$getSpPercent = round(($dsUsed / $dSpaceGB) * 100);
$upTime = sysUptime();
?>
<h3 align="center"><?php echo $l['SystemOverview']; ?></h3>
<br />
<div class="row">
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Servers']; ?></h4>
<?php echo $countSer; ?>
</div>
</div>
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Uptime']; ?></h4>
<?php echo $upTime; ?>
</div>
</div>
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Records']; ?></h4>
<?php echo number_format($recDetails[0]['COUNT(*)']); ?>
</div>
</div>
</div>
<br />
<h2 align="center">TinyMTR Monitoring System</h2>
<h4 align="center">v<?php echo $version; ?></h4>
<br />
<div class="row">
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Disk']; ?></h4>
<div class="progress" style="width:75%; margin: 0 auto;" align="center">
<span style="font-size:10px;"><?php echo $dFSpaceGB; ?>GB</span>
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' . $getMemPercent . '" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $getSpPercent; ?>%">
<span style="font-size:10px;"><?php echo $dsUsed; ?>GB</span><span class="sr-only"><?php echo $getSpPercent; ?></span>
</div>
</div>
</div>
</div>
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Load']; ?></h4>
<span class="label label-success"><?php echo $getInfo['load1']; ?></span> -
<span class="label label-info"><?php echo $getInfo['load5']; ?></span> -
<span class="label label-warning"><?php echo $getInfo['load15']; ?></span>
</div>
</div>
<div class="col-md-4" align="center">
<div class="circleHold">
<h4><?php echo $l['Ram']; ?></h4>
<div class="progress" style="width:75%; margin: 0 auto;" align="center">
<span style="font-size:10px;"><?php echo $memLeft; ?>MB</span>
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo $getMemPercent; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $getMemPercent; ?>%">
<span style="font-size:10px;"><?php echo $getInfo['memoryused']; ?>MB</span><span class="sr-only"><?php echo $getMemPercent; ?></span>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="footer">
<p class="small sideSpace">© Powered by <a href="https://picotory.com">TinyMTR</a> <?php echo date("Y"); ?></p>
</div>
</div>
</body>
</html>