Fix: Change Libvirt::node_get_cpu_stats() output
[php-virt-control.git] / pages / info.php
1 <?php
2         ob_start();
3         PHPInfo();
4         $c = ob_get_contents();
5         ob_end_clean();
6
7         $c = substr($c, strpos($c, 'module_libvirt'));
8         $c = substr($c, strpos($c, 'h2') + 3);
9
10         $p = strpos($c, 'module') - 3;
11         $out = substr($c, 0, $p);
12
13         $out = str_replace('<tr>', '<div class="item">', $out);
14         $out = str_replace('<td class="e">', '<div class="label">', $out);
15         $out = str_replace('</td><td class="v">', '</div><div class="value">', $out);
16         $out = str_replace('</td></tr>', '</div><div class="nl" /></div>', $out);
17
18         $tmp = explode("\n", $out);
19         $start_el = false;
20         $last_el = false;
21         for ($i = 0; $i < sizeof($tmp); $i++) {
22                 if (strpos('.'.$tmp[$i], '</table'))
23                         $last_el = $i;
24                 if (strpos('.'.$tmp[$i], '<table'))
25                         $start_el = $i + 1;
26         }
27
28         $tmp2 = array();
29         for ($i = $start_el; $i < $last_el; $i++)
30                 $tmp2[] = $tmp[$i];
31         unset($tmp);
32
33         $out = join("\n", $tmp2);
34 ?>
35
36 <div id="content">
37
38 <div class="section"><?php echo $lang->get('title_vmc').' '.$lang->get('for_php') ?></div>
39
40 <div class="item">
41         <div class="label"><?php echo $lang->get('version') ?></div>
42         <div class="value"><?php echo PHPVIRTCONTROL_VERSION ?></div>
43         <div class="nl">
44 </div>
45
46 <div class="item">
47         <div class="label"><?php echo $lang->get('website') ?></div>
48         <div class="value"><a target="_blank" href="<?php echo PHPVIRTCONTROL_WEBSITE ?>"><?php echo PHPVIRTCONTROL_WEBSITE ?></a></div>
49         <div class="nl">
50 </div>
51
52 <div class="section"><?php echo $lang->get('conn_details') ?></div>
53
54 <?php
55         $tmp  = $lv->get_connect_information();
56 ?>
57
58 <div class="item">
59         <div class="label"><?php echo $lang->get('hypervisor') ?></div>
60         <div class="value"><?php echo (array_key_exists('hypervisor_string', $tmp) ? $tmp['hypervisor_string'] : '<i>'.$lang->get('error').'</i>' ) ?></div>
61         <div class="nl">
62 </div>
63
64 <div class="item">
65         <div class="label"><?php echo $lang->get('conn_uri') ?></div>
66         <div class="value"><?php echo $tmp['uri'] ?></div>
67         <div class="nl">
68 </div>
69
70 <div class="item">
71         <div class="label"><?php echo $lang->get('hostname') ?></div>
72         <div class="value"><?php echo $tmp['hostname'] ?></div>
73         <div class="nl">
74 </div>
75
76 <div class="item">
77         <div class="label"><?php echo $lang->get('conn_encrypted') ?></div>
78         <div class="value"><?php echo $lang->get($tmp['encrypted']) ?></div>
79         <div class="nl">
80 </div>
81
82 <div class="item">
83         <div class="label"><?php echo $lang->get('conn_secure') ?></div>
84         <div class="value"><?php echo $lang->get($tmp['secure']) ?></div>
85         <div class="nl">
86 </div>
87
88 <div class="item">
89         <div class="label"><?php echo $lang->get('hypervisor_limit') ?></div>
90         <div class="value"><?php echo $tmp['hypervisor_maxvcpus'] ?> vCPUs per guest</div>
91         <div class="nl">
92 </div>
93
94 <?php
95         unset($tmp);
96         $tmp = $lv->host_get_node_info();
97 ?>
98 <div class="section"><?php echo $lang->get('host_details') ?></div>
99 <div class="item">
100         <div class="label"><?php echo $lang->get('model') ?></div>
101         <div class="value"><?php echo $tmp['model'] ?></div>
102         <div class="nl">
103 </div>
104
105 <div class="item">
106         <div class="label"><?php echo $lang->get('mem') ?></div>
107         <div class="value"><?php echo (int)($tmp['memory'] / 1024) ?> MiB</div>
108         <div class="nl">
109 </div>
110
111 <div class="item">
112         <div class="label"><?php echo $lang->get('pcpus') ?></div>
113         <div class="value"><?php echo $tmp['cpus'].' ('.$tmp['nodes'].' nodes, '.$tmp['sockets'].' sockets, '.$tmp['cores'].' cores)' ?></div>
114         <div class="nl">
115 </div>
116
117 <div class="item">
118         <div class="label"><?php echo $lang->get('cpu_speed') ?></div>
119         <div class="value"><?php echo $tmp['mhz'] ?> MHz</div>
120         <div class="nl">
121 </div>
122 <?php unset($tmp) ?>
123 <div class="section"><?php echo $lang->get('modinfo') ?></div>
124 <?php echo $out ?>
125 </div>
126
127 <div class="section"><?php echo $lang->get('cpu_stats'); ?></div>
128 <?php
129 $tmp = $lv->node_get_cpu_stats();
130 if (is_array($tmp)) foreach ($tmp as $name => $value) {
131     echo '<div class="label">'.$name.'</div>';
132     echo '<div class="value">'.$value.'</div><div class="nl">';
133 }
134 ?>
135 <div style="clear:both"></div>
136 <div class="section"><?php echo $lang->get('mem_stats'); ?></div>
137 <?php
138 $tmp = $lv->node_get_mem_stats();
139 if (is_array($tmp)) foreach ($tmp as $name => $value) {
140     echo '<div class="label">'.$name.'</div>';
141     echo '<div class="value">'.$value.'</div><div class="nl">';
142 }
143 ?>
144 <div style="clear:both"></div>
145 <div class="section"><?php echo $lang->get('system_information'); ?></div>
146 <pre>
147 <?php
148     $tmp = $lv->connect_get_sysinfo();
149     echo htmlentities($tmp);
150 ?>
151 </pre>