requireExtraFiles(): require_once() is the word
[racktables] / wwwroot / inc / interface-reports.php
CommitLineData
069689de
DO
1<?php
2
3function renderSystemReports ()
4{
5 $tmp = array
6 (
7 array
8 (
9 'title' => 'Dictionary/objects',
10 'type' => 'counters',
11 'func' => 'getDictStats'
12 ),
13 array
14 (
15 'title' => 'Rackspace',
16 'type' => 'counters',
17 'func' => 'getRackspaceStats'
18 ),
19 array
20 (
21 'title' => 'Files',
22 'type' => 'counters',
23 'func' => 'getFileStats'
24 ),
25 array
26 (
27 'title' => 'Tags top list',
28 'type' => 'custom',
29 'func' => 'renderTagStats'
30 ),
31 );
32 renderReports ($tmp);
33}
34
35function renderLocalReports ()
36{
37 global $localreports;
38 renderReports ($localreports);
39}
40
41function renderRackCodeReports ()
42{
43 $tmp = array
44 (
45 array
46 (
47 'title' => 'Stats',
48 'type' => 'counters',
49 'func' => 'getRackCodeStats',
069689de
DO
50 ),
51 array
52 (
53 'title' => 'Warnings',
54 'type' => 'messages',
55 'func' => 'getRackCodeWarnings',
069689de
DO
56 ),
57 );
58 renderReports ($tmp);
59}
60
61function renderIPv4Reports ()
62{
63 $tmp = array
64 (
65 array
66 (
67 'title' => 'Stats',
68 'type' => 'counters',
69 'func' => 'getIPv4Stats'
70 ),
71 );
72 renderReports ($tmp);
73}
74
75function renderIPv6Reports ()
76{
77 $tmp = array
78 (
79 array
80 (
81 'title' => 'Stats',
82 'type' => 'counters',
83 'func' => 'getIPv6Stats'
84 ),
85 );
86 renderReports ($tmp);
87}
88
89function renderPortsReport ()
90{
91 $tmp = array();
92 foreach (getPortIIFOptions() as $iif_id => $iif_name)
93 if (count (getPortIIFStats ($iif_id)))
94 $tmp[] = array
95 (
96 'title' => $iif_name,
97 'type' => 'meters',
98 'func' => 'getPortIIFStats',
99 'args' => $iif_id,
100 );
101 renderReports ($tmp);
102}
103
104function render8021QReport ()
105{
106 if (!count ($domains = getVLANDomainOptions()))
107 {
108 echo '<center><h3>(no VLAN configuration exists)</h3></center>';
109 return;
110 }
111 $vlanstats = array();
112 for ($i = VLAN_MIN_ID; $i <= VLAN_MAX_ID; $i++)
113 $vlanstats[$i] = array();
114 $header = '<tr><th>&nbsp;</th>';
115 foreach ($domains as $domain_id => $domain_name)
116 {
117 foreach (getDomainVLANList ($domain_id) as $vlan_id => $vlan_info)
118 $vlanstats[$vlan_id][$domain_id] = $vlan_info;
119 $header .= '<th>' . mkA ($domain_name, 'vlandomain', $domain_id) . '</th>';
120 }
121 $header .= '</tr>';
122 $output = $available = array();
123 for ($i = VLAN_MIN_ID; $i <= VLAN_MAX_ID; $i++)
124 if (!count ($vlanstats[$i]))
125 $available[] = $i;
126 else
127 $output[$i] = FALSE;
128 foreach (listToRanges ($available) as $span)
129 {
130 if ($span['to'] - $span['from'] < 4)
131 for ($i = $span['from']; $i <= $span['to']; $i++)
132 $output[$i] = FALSE;
133 else
134 {
135 $output[$span['from']] = TRUE;
136 $output[$span['to']] = FALSE;
137 }
138 }
139 ksort ($output, SORT_NUMERIC);
140 $header_delay = 0;
141 startPortlet ('VLAN existence per domain');
142 echo '<table border=1 cellspacing=0 cellpadding=5 align=center class=rackspace>';
143 foreach ($output as $vlan_id => $tbc)
144 {
145 if (--$header_delay <= 0)
146 {
147 echo $header;
148 $header_delay = 25;
149 }
150 echo '<tr class="state_' . (count ($vlanstats[$vlan_id]) ? 'T' : 'F');
151 echo '"><th class=tdright>' . $vlan_id . '</th>';
152 foreach (array_keys ($domains) as $domain_id)
153 {
154 echo '<td class=tdcenter>';
155 if (array_key_exists ($domain_id, $vlanstats[$vlan_id]))
156 echo mkA ('&exist;', 'vlan', "${domain_id}-${vlan_id}");
157 else
158 echo '&nbsp;';
159 echo '</td>';
160 }
161 echo '</tr>';
162 if ($tbc)
163 echo '<tr class="state_A"><th>...</th><td colspan=' . count ($domains) . '>&nbsp;</td></tr>';
164 }
165 echo '</table>';
166 finishPortlet();
167}
168
169function renderReports ($what)
170{
171 if (!count ($what))
172 return;
173 echo "<table align=center>\n";
174 foreach ($what as $item)
175 {
069689de
DO
176 echo "<tr><th colspan=2><h3>${item['title']}</h3></th></tr>\n";
177 switch ($item['type'])
178 {
179 case 'counters':
180 if (array_key_exists ('args', $item))
181 $data = $item['func'] ($item['args']);
182 else
183 $data = $item['func'] ();
184 foreach ($data as $header => $data)
185 echo "<tr><td class=tdright>${header}:</td><td class=tdleft>${data}</td></tr>\n";
186 break;
187 case 'messages':
188 if (array_key_exists ('args', $item))
189 $data = $item['func'] ($item['args']);
190 else
191 $data = $item['func'] ();
192 foreach ($data as $msg)
193 echo "<tr class='msg_${msg['class']}'><td class=tdright>${msg['header']}:</td><td class=tdleft>${msg['text']}</td></tr>\n";
194 break;
195 case 'meters':
196 if (array_key_exists ('args', $item))
197 $data = $item['func'] ($item['args']);
198 else
199 $data = $item['func'] ();
200 foreach ($data as $meter)
201 {
202 echo "<tr><td class=tdright>${meter['title']}:</td><td class=tdcenter>";
203 renderProgressBar ($meter['max'] ? $meter['current'] / $meter['max'] : 0);
204 echo '<br><small>' . ($meter['max'] ? $meter['current'] . '/' . $meter['max'] : '0') . '</small></td></tr>';
205 }
206 break;
207 case 'custom':
208 echo "<tr><td colspan=2>";
209 $item['func'] ();
210 echo "</td></tr>\n";
211 break;
212 default:
213 throw new InvalidArgException ('type', $item['type']);
214 }
215 echo "<tr><td colspan=2><hr></td></tr>\n";
216 }
217 echo "</table>\n";
218}
219
220function renderTagStats ()
221{
222 global $taglist;
223 echo '<table border=1><tr><th>tag</th><th>total</th><th>objects</th><th>IPv4 nets</th><th>IPv6 nets</th>';
224 echo '<th>racks</th><th>IPv4 VS</th><th>IPv4 RS pools</th><th>users</th><th>files</th></tr>';
225 $pagebyrealm = array
226 (
227 'file' => 'files&tab=default',
228 'ipv4net' => 'ipv4space&tab=default',
229 'ipv6net' => 'ipv6space&tab=default',
230 'ipv4vs' => 'ipv4slb&tab=default',
231 'ipv4rspool' => 'ipv4slb&tab=rspools',
232 'object' => 'depot&tab=default',
233 'rack' => 'rackspace&tab=default',
234 'user' => 'userlist&tab=default'
235 );
236 foreach (getTagChart (getConfigVar ('TAGS_TOPLIST_SIZE')) as $taginfo)
237 {
238 echo "<tr><td>${taginfo['tag']}</td><td>" . $taginfo['refcnt']['total'] . "</td>";
239 foreach (array ('object', 'ipv4net', 'ipv6net', 'rack', 'ipv4vs', 'ipv4rspool', 'user', 'file') as $realm)
240 {
241 echo '<td>';
242 if (!isset ($taginfo['refcnt'][$realm]))
243 echo '&nbsp;';
244 else
245 {
246 echo "<a href='index.php?page=" . $pagebyrealm[$realm] . "&cft[]=${taginfo['id']}'>";
247 echo $taginfo['refcnt'][$realm] . '</a>';
248 }
249 echo '</td>';
250 }
251 echo '</tr>';
252 }
253 echo '</table>';
254}
255
256?>