forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc_stats.php
303 lines (281 loc) · 9.85 KB
/
dc_stats.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
require_once("db.inc.php");
require_once("facilities.inc.php");
$subheader=__("Data Center Statistics");
$cab=new Cabinet();
$dc=new DataCenter();
$dev=new Device();
//setting airflow
if(isset($_POST["cabinetid"]) && isset($_POST["airflow"]) && $user->SiteAdmin){
$cab->CabinetID=$_POST["cabinetid"];
if ($cab->GetCabinet()){
if ($cab->CabRowID>0 && isset($_POST["row"]) && $_POST["row"]=="true"){
//update all row
$cabinets=$cab->GetCabinetsByRow();
foreach($cabinets as $index => $cabinet){
$cabinet->FrontEdge=$_POST["airflow"];
$cabinet->UpdateCabinet();
}
}else{
//update cabinet
$cab->FrontEdge=$_POST["airflow"];
$cab->UpdateCabinet();
}
}
exit;
}
if(isset($_POST['dc']) && (isset($_POST['getobjects']) || isset($_POST['getoverview']))){
$payload=array();
if(isset($_POST['getobjects'])){
$cab->DataCenterID=$_POST['dc'];
$zone=new Zone();
$zone->DataCenterID=$cab->DataCenterID;
$payload=array('cab'=>$cab->ListCabinetsByDC(true),'zone'=>$zone->GetZonesByDC(true));
}else{
$dc->DataCenterID=$_POST['dc'];
$dc->GetDataCenterByID();
$payload=$dc->GetOverview();
}
header('Content-Type: application/json');
echo json_encode($payload);
exit;
}
if(!isset($_GET["dc"])){
// No soup for you.
header('Location: '.redirect());
exit;
}
$dc->DataCenterID=$_GET["dc"];
$dc->GetDataCenterbyID();
$dcStats=$dc->GetDCStatistics();
function MakeImageMap($dc){
$mapHTML="";
if(strlen($dc->DrawingFileName)>0){
$mapfile="drawings".DIRECTORY_SEPARATOR.$dc->DrawingFileName;
if(file_exists($mapfile)){
list($width, $height, $type, $attr)=getimagesize($mapfile);
$mapHTML="<div class=\"canvas\" style=\"background-image: url('drawings/$dc->DrawingFileName')\">
<img src=\"css/blank.gif\" usemap=\"#datacenter\" width=\"$width\" height=\"$height\" alt=\"clearmap over canvas\">
<map name=\"datacenter\" data-dc=$dc->DataCenterID data-zoom=1 data-x1=0 data-y1=0>
</map>
<canvas id=\"mapCanvas\" width=\"$width\" height=\"$height\"></canvas>
\n</div>\n";
}
}
return $mapHTML;
}
$height=0;
$width=0;
$ie8fix="";
if(strlen($dc->DrawingFileName) >0){
$mapfile="drawings/$dc->DrawingFileName";
if(file_exists($mapfile)){
list($width, $height, $type, $attr)=getimagesize($mapfile);
// There is a bug in the excanvas shim that can set the width of the canvas to 10x the width of the image
$ie8fix="
<script type=\"text/javascript\">
function uselessie(){
document.getElementById(\'mapCanvas\').className = \"mapCanvasiefix\";
}
$(document).ready(function() {
uselessie();
});
</script>
<style type=\"text/css\">
.mapCanvasiefix {
width: {$width}px !important;
}
</style>";
}
}
// If no mapfile is set then we don't need the buttons to control drawing the map. Adjust the CSS to hide them and make the heading centered
if(strlen($dc->DrawingFileName) <1 || !file_exists("drawings/$dc->DrawingFileName")){
$screenadjustment="<style type=\"text/css\">.dcstats .heading > div { width: 100% !important;} .dcstats .heading > div + div { display: none; }</style>";
}
if ( $config->ParameterArray["mUnits"] == "english" ) {
$vol = __("Square Feet");
$tempUnits = "F";
$density = __("Watts per Square Foot");
} else {
$vol = __("Square Meters");
$tempUnits = "C";
$density = __("Watts per Square Meter" );
}
?>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo __("openDCIM Data Center Information Management");?></title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/print.css" type="text/css" media="print">
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css">
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
<script type="text/javascript" src="scripts/common.js"></script>
<script type="text/javascript" src="scripts/jquery.ui-contextmenu.js"></script>
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/ie.css" type="text/css">
<?php if(isset($ie8fix)){print $ie8fix;} ?>
<script src="scripts/excanvas.js"></script>
<![endif]-->
</head>
<body>
<?php include( 'header.inc.php' ); ?>
<div class="page dcstats" id="mapadjust">
<?php
include( "sidebar.inc.php" );
echo '<div class="main">
<div class="center"><div>
<div class="centermargin" id="dcstats">
<div class="table border">
<div class="title">',$dc->Name,'<span><a href="search_export.php?datacenterid=',$dc->DataCenterID,'">',__("Export"),'</a> , <a href="report_xml_CFD.php?datacenterid=',$dc->DataCenterID,'">',__("XML"),'</a></span></div>
<div>
<div></div>
<div>',__("Infrastructure"),'</div>
<div>',__("Occupied"),'</div>
<div>',__("Allocated"),'</div>
<div>',__("Available"),'</div>
</div>
<div>
<div>',sprintf(__("Total U")." %5d",$dcStats["TotalU"]),'</div>
<div>',sprintf("%3d",$dcStats["Infrastructure"]),'</div>
<div>',sprintf("%3d",$dcStats["Occupied"]),'</div>
<div>',sprintf("%3d",$dcStats["Allocated"]),'</div>
<div>',sprintf("%3d",$dcStats["Available"]),'</div>
</div>
<div>
<div>',__("Percentage"),'</div>
<div>',(($dcStats["TotalU"])?sprintf("%3.1f%%",$dcStats["Infrastructure"]/$dcStats["TotalU"]*100):"0"),'</div>
<div>',(($dcStats["TotalU"])?sprintf("%3.1f%%",$dcStats["Occupied"]/$dcStats["TotalU"]*100):"0"),'</div>
<div>',(($dcStats["TotalU"])?sprintf("%3.1f%%",$dcStats["Allocated"]/$dcStats["TotalU"]*100):"0"),'</div>
<div>',(($dcStats["TotalU"])?sprintf("%3.1f%%",$dcStats["Available"]/$dcStats["TotalU"]*100):"0"),'</div>
</div>
</div> <!-- END div.table -->
<div class="table border">
<div>
<div>',__("Computed Wattage"),'</div>
<div>',sprintf("%7d %s", $dcStats["ComputedWatts"], __("Watts")),'</div>
</div>
<div>
<div>',__("Measured Wattage"), '</div>
<div>',sprintf("%7d %s", $dcStats["MeasuredWatts"], __("Watts")),'</div>
</div>
<div>
<div>',__("Design Maximum (kW)"),'</div>
<div>',sprintf("%7d kW",$dc->MaxkW ),'</div>
</div>
<div>
<div>',__("BTU Computation from Computed Watts"),'</div>
<div>',sprintf("%8d ".__("BTU"),$dcStats["ComputedWatts"]*3.412 ),'</div>
</div>
<div>
<div>',__("Data Center Size"),'</div>
<div>',sprintf("%8d %s",$dc->SquareFootage, $vol),'</div>
</div>
<div>
<div>',$density,'</div>
<div>',(($dc->SquareFootage)?sprintf("%8d ".__("Watts"),$dcStats["ComputedWatts"]/$dc->SquareFootage):"0 ".__("Watts")),'</div>
</div>
<div>
<div>',__("Minimum Cooling Tonnage (Based on Computed Watts)"),'</div>
<div>',sprintf("%7d ".__("Tons"),$dcStats["ComputedWatts"]*3.412*1.15/12000),'</div>
</div>
<div>
<div>',__("Average Temperature"),'</div>
<div>',sprintf("%7d %s", $dcStats["AvgTemp"], __("°". $tempUnits)),'</div>
</div>
<div>
<div>',__("Average Humidity"), '</div>
<div>',sprintf("%7d %s", $dcStats["AvgHumidity"], __("%")),'</div>
</div>
</div> <!-- END div.table -->
</div> <!-- END div.centermargin -->
<br>
<div id="maptitle"><span></span><div class="nav">';
$select="\n\t<select>\n";
foreach(array(
'overview' => __("Overview"),
'space' => __("Space"),
'weight' => __("Weight"),
'power' => __("Calculated Power"),
'realpower' => __("Measured Power"),
'temperature' => __("Temperature"),
'humidity' => __("Humidity"),
'airflow' => __("Air Flow")
) as $value => $option){
$select.="\t\t<option value=\"$value\">$option</option>\n";
}
$select.="\t</select>\n";
echo $select."</div></div>\n".MakeImageMap($dc);
echo '
</div></div>
<ul id="options" class="hide">
<li class="ui-state-disabled">',__("Set the air intake direction"),'</li>
<li>----</li>
<li><a>',__("Cabinet"),'</a>
<ul data-context="cabinet">
<li><a href="#Top">',__("Top"),'</a></li>
<li><a href="#Right">',__("Right"),'</a></li>
<li><a href="#Bottom">',__("Bottom"),'</a></li>
<li><a href="#Left">',__("Left"),'</a></li>
</ul>
</li>
<li><a href="#row">',__("Row"),'</a>
<ul data-context="row">
<li><a href="#Test">',__("Top"),'</a></li>
<li><a href="#Right">',__("Right"),'</a></li>
<li><a href="#Bottom">',__("Bottom"),'</a></li>
<li><a href="#Left">',__("Left"),'</a></li>
</ul>
</li>
</ul>';
?>
</div><!-- END div.main -->
</div><!-- END div.page -->
<script type="text/javascript">
$(document).ready(function() {
// Hard set widths to stop IE from being retarded
$('#mapCanvas').css('width', $('.canvas > img[alt="clearmap over canvas"]').width()+'px');
$('#mapCanvas').parent('.canvas').css('width', $('.canvas > img[alt="clearmap over canvas"]').width()+'px');
var firstcabinet=$('#dc<?php echo $dc->DataCenterID;?> > ul > li:first-child').attr('id');
// Don't attempt to open the datacenter tree until it is loaded
function opentree(){
if($('#datacenters .bullet').length==0){
setTimeout(function(){
opentree();
},500);
}else{
expandToItem('datacenters',firstcabinet);
}
}
<?php
if ( $user->SiteAdmin ) {
// Only Site Administrators should even have the option to change the air flow
?>
// Bind context menu to the cabinets
$(".canvas > map").contextmenu({
delegate: "area[name^=cab]",
menu: "#options",
select: function(event, ui) {
var row=(ui.item.context.parentElement.getAttribute('data-context')=='row')?true:false;
var cabid=ui.target.context.attributes.name.value.substr(3);
$.post('',{cabinetid: cabid, airflow: ui.cmd, row: row}).done(function(){startmap()});
},
beforeOpen: function(event, ui) {
$('#options').removeClass('hide');
$('.center .nav > select').val('airflow').trigger('change');
$(".canvas > map").contextmenu("showEntry", "row", $(ui.target.context).data('row'));
}
});
<?php
}
?>
// Bind tooltips, highlight functions to the map
startmap();
opentree();
});
</script>
</body>
</html>