fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

serverinfo.class.php
Go to the documentation of this file.
1 <?php
22 class ServerInfo extends FOGPage
23 {
29  public $node = 'hwinfo';
37  public function __construct($name = '')
38  {
39  $this->name = 'Hardware Information';
40  parent::__construct($this->name);
41  global $id;
42  $this->obj = new StorageNode($id);
43  $this->menu = array(
44  "?node=storage&sub=edit&id={$id}" => _('Edit Node')
45  );
46  $this->notes = array(
47  sprintf(
48  '%s %s',
49  self::$foglang['Storage'],
50  self::$foglang['Node']
51  ) => $this->obj->get('name'),
52  _('Hostname / IP') => $this->obj->get('ip'),
53  self::$foglang['ImagePath'] => $this->obj->get('path'),
54  self::$foglang['FTPPath'] => $this->obj->get('ftppath')
55  );
56  }
62  public function index()
63  {
64  unset(
65  $this->data,
66  $this->form,
67  $this->headerData,
68  $this->templates,
69  $this->attributes
70  );
71  echo '<div class="col-xs-9">';
72  echo '<div class="panel panel-info">';
73  echo '<div class="panel-heading text-center">';
74  echo '<h4 class="title">';
75  echo _('Server information');
76  echo '</h4>';
77  echo '</div>';
78  echo '<div class="panel-body">';
79  if (!$this->obj->isValid()) {
80  echo _('Invalid Server Information!');
81  echo '</div>';
82  echo '</div>';
83  echo '</div>';
84  return;
85  }
86  $url = sprintf(
87  '%s://%s/fog/status/hw.php',
88  self::$httpproto,
89  $this->obj->get('ip')
90  );
91  $ret = self::$FOGURLRequests->process($url);
92  $ret = trim($ret[0]);
93  if (!$ret) {
94  echo _('Unable to get server infromation!');
95  echo '</div>';
96  echo '</div>';
97  echo '</div>';
98  return;
99  }
100  $this->attributes = array(
101  array('class' => 'col-xs-4'),
102  array('class' => 'col-xs-8'),
103  );
104  $this->templates = array(
105  '${field}',
106  '${input}',
107  );
108  $section = 0;
109  $arGeneral = array();
110  $arFS = array();
111  $arNIC = array();
112  $lines = explode("\n", $ret);
113  foreach ((array)$lines as &$line) {
114  $line = trim($line);
115  switch ($line) {
116  case '@@start':
117  case '@@end':
118  break;
119  case '@@general':
120  $section = 0;
121  break;
122  case '@@fs':
123  $section = 1;
124  break;
125  case '@@nic':
126  $section = 2;
127  break;
128  default:
129  switch ($section) {
130  case 0:
131  $arGeneral[] = $line;
132  break;
133  case 1:
134  $arFS[] = $line;
135  break;
136  case 2:
137  $arNIC[] = $line;
138  break;
139  }
140  break;
141  }
142  unset($line);
143  }
144  if (count($arGeneral) < 1) {
145  echo _('Unable to find basic information!');
146  echo '</div>';
147  echo '</div>';
148  echo '</div>';
149  return;
150  }
151  foreach ((array)$arNIC as &$nic) {
152  $nicparts = explode("$$", $nic);
153  if (count($nicparts) == 5) {
154  $NICTransSized[] = self::formatByteSize($nicparts[2]);
155  $NICRecSized[] = self::formatByteSize($nicparts[1]);
156  $NICErrInfo[] = $nicparts[3];
157  $NICDropInfo[] = $nicparts[4];
158  $NICTrans[] = sprintf('%s %s', $nicparts[0], _('TX'));
159  $NICRec[] = sprintf('%s %s', $nicparts[0], _('RX'));
160  $NICErr[] = sprintf('%s %s', $nicparts[0], _('Errors'));
161  $NICDro[] = sprintf('%s %s', $nicparts[0], _('Dropped'));
162  }
163  unset($nic);
164  }
165  $this->title = _('General Information');
166  $fields = array(
167  _('Storage Node') => $this->obj->get('name'),
168  _('IP') => self::resolveHostname(
169  $this->obj->get('ip')
170  ),
171  _('Kernel') => $arGeneral[0],
172  _('Hostname') => $arGeneral[1],
173  _('Uptime') => $arGeneral[2],
174  _('CPU Type') => $arGeneral[3],
175  _('CPU Count') => $arGeneral[4],
176  _('CPU Model') => $arGeneral[5],
177  _('CPU Speed') => $arGeneral[6],
178  _('CPU Cache') => $arGeneral[7],
179  _('Total Memory') => $arGeneral[8],
180  _('Used Memory') => $arGeneral[9],
181  _('Free Memory') => $arGeneral[10]
182  );
183  array_walk($fields, $this->fieldsToData);
184  echo '<div class="panel panel-info">';
185  echo '<div class="panel-heading text-center">';
186  echo '<h4 class="title">';
187  echo $this->title;
188  echo '</h4>';
189  echo '</div>';
190  echo '<div class="panel-body">';
191  $this->render(12);
192  echo '</div>';
193  echo '</div>';
194  unset(
195  $fields,
196  $this->form,
197  $this->data
198  );
199  $this->title = _('File System Information');
200  $fields = array(
201  _('Total Disk Space') => $arFS[0],
202  _('Used Disk Space') => $arFS[1],
203  _('Free Disk Space') => $arFS[2]
204  );
205  array_walk($fields, $this->fieldsToData);
206  echo '<div class="panel panel-info">';
207  echo '<div class="panel-heading text-center">';
208  echo '<h4 class="title">';
209  echo $this->title;
210  echo '</h4>';
211  echo '</div>';
212  echo '<div class="panel-body">';
213  $this->render(12);
214  echo '</div>';
215  echo '</div>';
216  unset(
217  $fields,
218  $this->data
219  );
220  $this->title = _('Network Information');
221  echo '<div class="panel panel-info">';
222  echo '<div class="panel-heading text-center">';
223  echo '<h4 class="title">';
224  echo $this->title;
225  echo '</h4>';
226  echo '</div>';
227  echo '<div class="panel-body">';
228  foreach ((array)$NICTrans as $index => &$txtran) {
229  unset(
230  $fields,
231  $this->data
232  );
233  $ethName = explode(' ', $txtran);
234  $fields = array(
235  $NICTrans[$index] => $NICTransSized[$index],
236  $NICRec[$index] => $NICRecSized[$index],
237  $NICErr[$index] => $NICErrInfo[$index],
238  $NICDro[$index] => $NICDropInfo[$index]
239  );
240  array_walk($fields, $this->fieldsToData);
241  echo '<div class="panel panel-info">';
242  echo '<div class="panel-heading text-center">';
243  echo '<h4 class="title">';
244  echo $ethName[0];
245  echo ' ';
246  echo _('Information');
247  echo '</h4>';
248  echo '</div>';
249  echo '<div class="panel-body">';
250  $this->render(12);
251  echo '</div>';
252  echo '</div>';
253  unset($txtran);
254  }
255  unset(
256  $arGeneral,
257  $arNIC,
258  $arFS,
259  $NICTransSized,
260  $NICRecSized,
261  $NICErrInfo,
262  $NICDropInfo,
263  $NICTrans,
264  $NICRec,
265  $NICErr,
266  $NICDro,
267  $this->data,
268  $fields,
269  $this->attributes,
270  $this->templates
271  );
272  echo '</div>';
273  echo '</div>';
274  echo '</div>';
275  echo '</div>';
276  echo '</div>';
277  }
278 }
FOGPage\render
render($colsize=9)
Definition: fogpage.class.php:605
FOGBase\formatByteSize
static formatByteSize($size)
Definition: fogbase.class.php:1025
FOGPage\$title
$title
Definition: fogpage.class.php:49
FOGPage\$name
$name
Definition: fogpage.class.php:31
$ret
$ret
Definition: bandwidth.php:112
StorageNode
Definition: storagenode.class.php:23
FOGPage
Definition: fogpage.class.php:25
FOGPage\$id
$id
Definition: fogpage.class.php:43
ServerInfo\$node
$node
Definition: serverinfo.class.php:29
$foglang
$foglang['Display']
Definition: text.php:22
ServerInfo\__construct
__construct($name='')
Definition: serverinfo.class.php:37
ServerInfo\index
index()
Definition: serverinfo.class.php:62
$url
$url
Definition: kernelvers.php:27
ServerInfo
Definition: serverinfo.class.php:23
$lines
$lines
Definition: logtoview.php:41