forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_realtimemetrics.php
202 lines (179 loc) · 7.77 KB
/
report_realtimemetrics.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
<?php
// header( "content-type: text/xml" );
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: inline; filename=\"realtime.xls\"");
header("Pragma: no-cache");
header("Expires: 0");
include( "db.inc.php" );
include( "facilities.inc.php" );
printf( "<?xml version=\"1.0\"?>\n" );
printf( "<?mso-application progid=\"Excel.Sheet\"?>\n" );
$data = array();
// This needs to be all generated from the db someplace.
// ITS Statistics
$sql = "select count(*) as Devices, sum(Height) as Size, sum(NominalWatts) as Power from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='ITS'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$ITSdevices = $row["Devices"];
$ITSsize = $row["Size"];
$ITSpower = $row["Power"];
$ITSheat = $ITSpower * 3.412 / 12000;
$sql = "select count(*) as VMcount from fac_VMInventory a, fac_Department b where a.Owner=b.DeptID and b.Classification='ITS'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$ITSVM = $row["VMcount"];
$data["ITS Managed Services"] = array( $ITSdevices, $ITSsize, $ITSVM, $ITSpower, $ITSheat );
// Administrative Statistics
$sql = "select count(*) as Devices from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Administrative'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Admindevices = $row["Devices"];
$sql = "select sum(Height) as Size from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Administrative'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Adminsize = $row["Size"];
$sql = "select count(*) as VMcount from fac_VMInventory a, fac_Department b where a.Owner=b.DeptID and b.Classification='Administrative'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$AdminVM = $row["VMcount"];
$sql = "select sum(NominalWatts) as Power from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Administrative'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Adminpower = $row["Power"];
$Adminheat = $Adminpower * 3.412 / 12000;
$data["Non-ITS Administrative Colocations"] = array( $Admindevices, $Adminsize, $AdminVM, $Adminpower, $Adminheat );
// Academic (non-research) Statistics
$sql = "select count(*) as Devices from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Academic'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Academicdevices = $row["Devices"];
$sql = "select sum(Height) as Size from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Academic'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Academicsize = $row["Size"];
$sql = "select count(*) as VMcount from fac_VMInventory a, fac_Department b where a.Owner=b.DeptID and b.Classification='Academic'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$AcademicVM = $row["VMcount"];
$sql = "select sum(NominalWatts) as Power from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Academic'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Academicpower = $row["Power"];
$Academicheat = $Academicpower * 3.412 / 12000;
$data["Academic (Non-Research) Colocations"] = array( $Academicdevices, $Academicsize, $AcademicVM, $Academicpower, $Academicheat );
// Research Computing Statistics
$sql = "select count(*) as Devices from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Research'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Researchdevices = $row["Devices"];
$sql = "select sum(Height) as Size from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Research'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Researchsize = $row["Size"];
$sql = "select count(*) as VMcount from fac_VMInventory a, fac_Department b where a.Owner=b.DeptID and b.Classification='Research'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$ResearchVM = $row["VMcount"];
$sql = "select sum(NominalWatts) as Power from fac_Device a, fac_Department b where a.Owner=b.DeptID and b.Classification='Research'";
$res = mysql_query( $sql, $facDB );
$row = mysql_fetch_array( $res );
$Researchpower = $row["Power"];
$Researchheat = $Researchpower * 3.412 / 12000;
$data["Research Computing Colocations"] = array( $Researchdevices, $Researchsize, $ResearchVM, $Researchpower, $Researchheat );
?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>openDCIM</Author>
<LastAuthor>openDCIM</LastAuthor>
<Created>2012-04-03T06:38:53Z</Created>
<Company>openDCIM</Company>
<Version>14.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>15930</WindowHeight>
<WindowWidth>20025</WindowWidth>
<WindowTopX>480</WindowTopX>
<WindowTopY>105</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s62">
<NumberFormat ss:Format="Fixed"/>
</Style>
<Style ss:ID="s63">
<NumberFormat ss:Format="#,##0"/>
</Style>
</Styles>
<Worksheet ss:Name="Data_Center_Metrics">
<Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="<? echo( count( $data ) + 1 ) ?>" x:FullColumns="1"
x:FullRows="1">
<Column ss:Width="186"/>
<Column ss:Width="66.75"/>
<Column ss:Width="135.75"/>
<Column ss:Width="84"/>
<Column ss:Width="128.25"/>
<Column ss:Width="106.5"/>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Department</Data></Cell>
<?php
foreach(array("Device Count","Space Occupied (1U = 1.75\")","Virtual Machines","Power Consumed (kW/hr)","Heat Produced (Tons)",) as $key=>$val){
print " <Cell><Data ss:Type=\"String\">$val</Data></Cell>\n";
}
?>
</Row>
<?php
foreach($data as $key=>$row){
print " <Row ss:AutoFitHeight=\"0\">\n";
print " <Cell><Data ss:Type=\"String\">$key</Data></Cell>\n";
foreach($row as $key=>$val){
if(next($row)==false){
print " <Cell ss:StyleID=\"s62\"><Data ss:Type=\"Number\">$val</Data></Cell>\n";
}else{
print " <Cell ss:StyleID=\"s63\"><Data ss:Type=\"Number\">$val</Data></Cell>\n";
}
}
print " </Row>\n";
}
?>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Print>
<ValidPrinterInfo/>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>