-
Notifications
You must be signed in to change notification settings - Fork 205
/
index.php
159 lines (142 loc) · 5.15 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
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
<?php
# catch for assholes that don't read the install instructions
if(!file_exists("db.inc.php")){
require_once( "preflight.php" );
exit;
}
require_once( 'db.inc.php' );
require_once( 'facilities.inc.php' );
$subheader=__("Data Center Operations Metrics");
$sql = 'select count(*) as DCs from fac_DataCenter';
$row=$dbh->query($sql)->fetch();
$DCs = number_format($row['DCs']);
// Overall Statistics
$sql='SELECT SUM(NominalWatts) AS Power,
(SELECT COUNT(*) FROM fac_Device WHERE DeviceType!="Server" LIMIT 1) AS Devices,
(SELECT COUNT(*) FROM fac_Device WHERE DeviceType="Server" LIMIT 1) AS Servers,
(SELECT SUM(Height) FROM fac_Device LIMIT 1) AS Size,
(SELECT COUNT(*) FROM fac_VMInventory LIMIT 1) AS VMcount,
(select count(*) from fac_Device where Hypervisor!="None") as VMhosts,
(select count(*) from fac_Cabinet) as CabinetCount
FROM fac_Device LIMIT 1;';
$row=$dbh->query($sql)->fetch();
$StatsDevices=number_format($row['Devices']);
$StatsServers=number_format($row['Servers']);
$StatsSize=number_format($row['Size']);
$StatsVM=number_format($row['VMcount']);
$StatsHost=number_format($row["VMhosts"]);
$StatsCabinet=number_format($row["CabinetCount"]);
$StatsPower=number_format($row['Power'] / 1000);
$StatsHeat=number_format($row['Power'] * 3.412 / 12000);
$StatsVirtualization=number_format(intval($row['VMcount']/(($row['VMhosts']==0)?1:$row['VMhosts'])));
$dc = new DataCenter();
$dcList = $dc->GetDCList();
// Build table to display pending rack requests for inclusion later
$rackrequest='';
if($config->ParameterArray["RackRequests"]=="enabled" && $person->RackAdmin){
$rackrequest="<h3>".__("Pending Rack Requests")."</h3>\n<div class=\"table whiteborder rackrequest\">\n<div>\n <div>".__("Submit Time")."</div>\n <div>".__("Requestor")."</div>\n <div>".__("System Name")."</div>\n <div>".__("Department")."</div>\n <div>".__("Due By")."</div>\n</div>\n";
$rack=new RackRequest();
$tmpContact=new People();
$dept=new Department();
$rackList=$rack->GetOpenRequests();
foreach($rackList as $request){
$tmpContact->PersonID=$request->RequestorID;
$tmpContact->GetPerson();
$dept->DeptID=$request->Owner;
$dept->GetDeptByID();
$reqDate=getdate(strtotime($request->RequestTime));
$dueDate=date('M j Y H:i:s',mktime($reqDate['hours'],$reqDate['minutes'],$reqDate['seconds'],$reqDate['mon'],$reqDate['mday']+1,$reqDate['year']));
if((strtotime($dueDate) - strtotime('now'))< intval( $config->ParameterArray['RackOverdueHours'] * 3600 ) ) {
$colorCode='overdue';
}elseif((strtotime($dueDate) - strtotime('now'))< intval( $config->ParameterArray['RackWarningHours'] * 3600 ) ) {
$colorCode='soon';
}else{
$colorCode='clear';
}
$rackrequest.="<div class=\"$colorCode\"><div>".date("M j Y H:i:s",strtotime($request->RequestTime))."</div><div>$tmpContact->FirstName $tmpContact->LastName</div><div><a href=\"rackrequest.php?requestid=$request->RequestID\">$request->Label</a></div><div>$dept->Name</div><div>$dueDate</div></div>\n";
}
$rackrequest.='</div><!-- END div.table -->';
}
?>
<!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>openDCIM Data Center Inventory</title>
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css">
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css" />
<![endif]-->
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
</head>
<body>
<?php include( 'header.inc.php' ); ?>
<div class="page index">
<?php
include( 'sidebar.inc.php' );
echo '
<div class="main">
<div class="center"><div>
',$rackrequest,'
<h3>',__("Data Center Inventory"),' <a href="search_export.php">(',__("Export Inventory"),')</a></h3>
<div class="table border centermargin">
<div class="title">
',__("Hosted Systems"),'
</div>';
echo '
<div>
<div>',__("Data Centers"),'</div>
<div align="right">',$DCs,'</div>
</div>';
echo '
<div>
<div>',__("Physical Server Count"),'</div>
<div align="right">',$StatsServers,'</div>
</div>
<div>
<div>',__("Other Device Count"),'</div>
<div align="right">',$StatsDevices,'</div>
</div>
<div>
<div>',__("Space"),' (1U=1.75")</div>
<div align="right">',$StatsSize,' U</div>
</div>
<div>
<div>',__("Power Consumption"),'</div>
<div align="right">',$StatsPower,' kW</div>
</div>
<div>
<div>',__("Heat Produced"),'</div>
<div align="right">',$StatsHeat,' Tons</div>
</div>
<div>
<div>',__("Virtual Machines"),'</div>
<div align="right">',$StatsVM,'</div>
</div>
<div>
<div>',__("VM Hosts"),'</div>
<div align="right">',$StatsHost,'</div>
</div>
<div>
<div>',__("Virtualization Ratio"),'</div>
<div align="right">',$StatsVirtualization,':1</div>
</div>
<div>
<div>',__("Total Cabinets"),'</div>
<div align="right">',$StatsCabinet,'</div>
</div>
</div> <!-- END div.table -->
<div>';
if( file_exists("assets/sitecontact.html") ) {
include( "assets/sitecontact.html" );
}
echo ' </div>
</div>
</div>
</div>
</body>
</html>';
?>