root/modules/branches/2.4/dashboard/page.index.php

Revision 5310, 21.6 kB (checked in by p_lindheimer, 5 years ago)

#2365 don't make readonly disk devices red when 100%

Line 
1 <?php /* $Id: page.parking.php 2243 2006-08-12 17:13:17Z p_lindheimer $ */
2 //Copyright (C) 2006 Astrogen LLC
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either version 2
7 //of the License, or (at your option) any later version.
8 //
9 //This program is distributed in the hope that it will be useful,
10 //but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //GNU General Public License for more details.
13
14 $dashboard_debug = false;
15
16 $dispnum = 'sysinfo'; //used for switch on config.php
17 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
18
19 $quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:'';
20 $info = isset($_REQUEST['info'])?$_REQUEST['info']:false;
21
22 $title="freePBX: Sysinfo Info";
23 $message="System Info";
24
25 if (isset($_REQUEST['showall'])) {
26     $_SESSION['syslog_showall'] = (bool)$_REQUEST['showall'];
27 }
28
29 //require_once('functions.inc.php');
30
31 define('BAR_WIDTH_LEFT', 400);
32 define('BAR_WIDTH_RIGHT', 200);
33
34 // AJAX update intervals (in seconds)
35 define('STATS_UPDATE_TIME', 6); // update interval for system uptime information
36 define('INFO_UPDATE_TIME', 30); // update interval for system uptime information
37
38 /** draw_graph
39  *  draw a bar graph
40  *
41  *  $text         Title of text
42  *  $real_units   Units to display
43  *  $val          Value to graph
44  *  $total        Total of graph
45  *  $classes      CSS classes to use based on value percent
46  *  $show_percent If results should be shown as percent
47  *  $total_width  Width of graph
48  */
49
50 function draw_graph($text, $real_units, $val, $total = 100, $classes = null, $show_percent = true, $total_width = 200) {
51     if ($classes == null) {
52         $classes = array(
53             0=>'graphok',
54             70=>'graphwarn',
55             90=>'grapherror',
56         );
57     }
58
59     $chars_per_pixel = 7;
60     if (strlen($text) * $chars_per_pixel > $total_width - 35) {
61         $text_trimmed = substr($text,0, floor(($total_width - 35) / $chars_per_pixel)).'..';
62     } else {
63         $text_trimmed = $text;
64     }
65
66     $clean_val = preg_replace("/[^0-9\.]*/","",$val);
67
68     if ($total == 0) {
69         $percent = ($clean_val == 0) ? 0 : 100;
70     } else {
71         $percent = round($clean_val/$total*100);
72     }
73     
74     $graph_class = false;
75     foreach ($classes as $limit=>$class) {
76         if (!$graph_class) {
77             $graph_class = $class;
78         }
79         if ($limit <= $percent) {
80             $graph_class = $class;
81         } else {
82             break;
83         }
84     }
85     $width = $total_width * ($percent/100);
86     if ($width > $total_width) {
87         $width = $total_width;
88     }
89     
90     $tooltip = $text.": ".$val.$real_units." / ".$total.$real_units." (".$percent."%)";
91     $display_value = ($show_percent ? $percent."%" : $val.$real_units);
92     
93     $out = "<div class=\"databox graphbox\" style=\"width:".$total_width."px;\" title=\"".$tooltip."\">\n";
94     $out .= " <div class=\"bargraph ".$graph_class."\" style=\"width:".$width."px;\"></div>\n";
95     $out .= " <div class=\"dataname\">".$text_trimmed."</div>\n";
96     $out .= " <div class=\"datavalue\">".$display_value."</div>\n";
97     $out .= "</div>\n";
98     
99     return $out;
100 }
101
102 function draw_status_box($text, $status, $tooltip = false, $total_width = 200) {
103     switch ($status) {
104         case "ok":
105             $status_text = _("OK");
106             $class = "graphok";
107         break;
108         case "warn":
109             $status_text = _("Warn");
110             $class = "graphwarn";
111         break;
112         case "error":
113             $status_text = _("ERROR");
114             $class = "grapherror";
115         break;
116         case "disabled":
117             $status_text = "Disabled";
118             $class = "";
119         break;
120     }
121     if ($tooltip !== false) {
122         $status_text = '<a href="#" title="'.$tooltip.'">'.$status_text.'</a>';
123     }
124     
125     $out = "<div class=\"databox statusbox\" style=\"width:".$total_width."px;\">\n";
126     $out .= " <div class=\"dataname\">".$text."</div>\n";
127     $out .= " <div id=\"datavalue_".str_replace(" ","_",$text)."\" class=\"datavalue ".$class."\">".$status_text."</div>\n";
128     $out .= "</div>\n";
129     
130     return $out;
131 }
132
133 function draw_box($text, $value, $total_width = 200) {
134     $tooltip = $text.": ".$value;
135     
136     $out = "<div class=\"databox\" style=\"width:".$total_width."px;\">\n";
137     $out .= " <div class=\"dataname\">".$text."</div>\n";
138     $out .= " <div class=\"datavalue\"><a href=\"#\" title=\"".$tooltip."\">".$value."</a></div>\n";
139     $out .= "</div>\n";
140     
141     return $out;
142 }
143
144 function time_string($seconds) {
145     if ($seconds == 0) {
146         return "0 "._("minutes");
147     }
148
149     $minutes = floor($seconds / 60);
150     $seconds = $seconds % 60;
151
152     $hours = floor($minutes / 60);
153     $minutes = $minutes % 60;
154
155     $days = floor($hours / 24);
156     $hours = $hours % 24;
157     
158     $weeks = floor($days / 7);
159     $days = $days % 7;
160     
161     $output = array();
162     if ($weeks) {
163         $output[] = $weeks." ".($weeks == 1 ? _("week") : _("weeks"));
164     }
165     if ($days) {
166         $output[] = $days." ".($days == 1 ? _("days") : _("days"));
167     }
168     if ($hours) {
169         $output[] = $hours." ".($hours == 1 ? _("hour") : _("hours"));
170     }
171     if ($minutes) {
172         $output[] = $minutes." ".($minutes == 1 ? _("minute") : _("minutes"));
173     }
174     
175     return implode(", ",$output);
176 }
177
178 function show_sysstats() {
179     global $sysinfo;
180     $out = '';
181     
182     $out .= "<h3>"._("System Statistics")."</h3>";
183     $out .= "<h4>"._("Processor")."</h4>";
184     $loadavg = $sysinfo->loadavg(true);
185     $out .= draw_box(_("Load Average"), $loadavg['avg'][0]);
186     $out .= draw_graph(_("CPU"), "", number_format($loadavg['cpupercent'],2), 100);
187     
188     $out .= "<h4>"._("Memory")."</h4>";
189     $memory = $sysinfo->memory();
190     $app_memory = isset($memory["ram"]["app"]) ? $memory["ram"]["app"] : $memory["ram"]["total"] - $memory["ram"]["t_free"];
191     $out .= draw_graph(_("App Memory"), "MB", number_format($app_memory/1024,2), $memory["ram"]["total"]/1024);
192     $out .= draw_graph(_("Swap"), "MB", number_format(($memory["swap"]["total"]-$memory["swap"]["free"])/1024,2), $memory["swap"]["total"]/1024);
193     
194     $out .= "<h4>"._("Disks")."</h4>";
195     foreach ($sysinfo->filesystems() as $fs) {
196         $out .= draw_graph($fs["mount"], "GB", number_format($fs["used"]/1024/1024, 2), $fs["size"]/1024/1024, strpos( $fs["options"],"ro" )!==false ? array(0=>"graphok"):null);
197     }
198     
199     $out .= "<h4>"._("Networks")."</h4>";
200     foreach ($sysinfo->network() as $net_name=>$net) {
201         $net_name = trim($net_name);
202         if ($net_name == 'lo' || $net_name == 'sit0') continue;
203         
204         $tx = new average_rate_calculator($_SESSION["netstats"][$net_name]["tx"], 10); // 30s max age
205         $rx = new average_rate_calculator($_SESSION["netstats"][$net_name]["rx"], 10); // 30s max age
206         
207         $rx->add( $net["rx_bytes"] );
208         $tx->add( $net["tx_bytes"] );
209         
210         $out .= draw_box($net_name." "._("receive"), number_format($rx->average()/1000,2)." KB/s");
211         $out .= draw_box($net_name." "._("transmit"), number_format($tx->average()/1000,2)." KB/s");
212     }
213     return $out;
214 }
215
216 function show_aststats() {
217     global $amp_conf;
218     global $astinfo;
219     $out = '';
220     
221     $channels = $astinfo->get_channel_totals();
222     // figure out max_calls
223     
224     // guess at the max calls: number of users
225     if (!isset($_SESSION["calculated_max_calls"])) {
226         // set max calls to either MAXCALLS in amportal.conf, or the number of users in the system
227         if (isset($amp_conf['MAXCALLS'])) {
228             $_SESSION["calculated_max_calls"] = $amp_conf["MAXCALLS"];
229         } else if (function_exists('core_users_list')) {
230             $_SESSION["calculated_max_calls"] = count(core_users_list());
231         } else {
232             $_SESSION["calculated_max_calls"] = 1;
233         }
234     }
235     // we currently see more calls than we guessed, increase it
236     if ($channels['total_calls'] > $_SESSION["calculated_max_calls"]) {
237         $_SESSION["calculated_max_calls"] = $channels['total_calls'];
238     }
239     $max_calls = $_SESSION["calculated_max_calls"];
240     
241     $classes = array(0=>'graphok');
242     $max_chans = $max_calls * 2;
243     
244     $out .= "<h3>"._("FreePBX Statistics")."</h3>";
245     $out .= draw_graph(_('Total active calls'), '', $channels['total_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT);
246     $out .= draw_graph(_('Internal calls'), '', $channels['internal_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT);
247     $out .= draw_graph(_('External calls'), '', $channels['external_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT);
248     $out .= draw_graph(_('Total active channels'), '', $channels['total_channels'], $max_chans, $classes , false, BAR_WIDTH_LEFT);
249     
250     $out .= "<h4>"._("FreePBX Connections")."</h4>";
251     
252     if (function_exists('core_trunks_list')) {
253         $trunks = core_trunks_list(true);
254     } else {
255         $trunks = false;
256     }
257     $conns = $astinfo->get_connections( $trunks );
258
259     if ($conns['users_total'] > 0) {
260         $out .= draw_graph(_('IP Phones Online'), '', $conns['users_online'], $conns['users_total'], $classes, false, BAR_WIDTH_LEFT);
261     }
262     if ($conns['trunks_total'] > 0) {
263         $out .= draw_graph(_('IP Trunks Online'), '', $conns['trunks_online'], $conns['trunks_total'], $classes, false, BAR_WIDTH_LEFT);
264     }
265     if ($conns['registrations_total'] > 0) {
266         $out .= draw_graph(_('IP Trunk Registrations'), '', $conns['registrations_online'], $conns['registrations_total'], $classes, false, BAR_WIDTH_LEFT);
267     }
268
269     return $out;
270 }
271
272 function show_sysinfo() {
273     global $sysinfo;
274     global $astinfo;
275     $out = "<h3>"._("Uptime")."</h3></br>";
276     $out .= '<table>';
277     /*
278     $out .= '<tr><th>Distro:</th><td>'.$sysinfo->distro().'</td></tr>';
279     $out .= '<tr><th>Kernel:</th><td>'.$sysinfo->kernel().'</td></tr>';
280     $cpu = $sysinfo->cpu_info();
281     $out .= '<tr><th>CPU:</th><td>'.$cpu['model'].' '.$cpu['cpuspeed'].'</td></tr>';
282     */
283     
284     $out .= '<tr><th>'._('System Uptime').':</th><td>'.time_string($sysinfo->uptime()).'</td></tr>';
285     $ast_uptime = $astinfo->get_uptime();
286     if (empty($ast_uptime['system'])) {
287         $ast_uptime['system'] = time_string(0);
288     }
289     if (empty($ast_uptime['reload'])) {
290         $ast_uptime['reload'] = time_string(0);
291     }
292     $out .= '<tr><th>'._('Asterisk Uptime').':</th><td>'.$ast_uptime['system'].'</td></tr>';
293     $out .= '<tr><th>'._('Last Reload').':</th><td>'.$ast_uptime['reload'].'</td></tr>';
294     
295     $out .= '</table>';
296     return $out;
297 }
298
299 function show_procinfo() {
300     global $procinfo;
301     global $astinfo;
302     global $amp_conf;
303     $out = '';
304     
305     $out .= "<h3>"._("Server Status")."</h3>";
306     // asterisk
307     if ($astver = $astinfo->check_asterisk()) {
308         $out .= draw_status_box(_("Asterisk"), "ok", _('Asterisk is running: '.$astver));
309     } else {
310         $out .= draw_status_box(_("Asterisk"), "error", _('Asterisk is not running, this is a critical service!'));
311     }
312     
313     // asterisk proxy (optionally)
314     if (isset($amp_conf['ASTMANAGERPROXYPORT'])) {
315         if ($procinfo->check_port($amp_conf['ASTMANAGERPROXYPORT'])) {
316             $out .= draw_status_box(_("Manager Proxy"), "ok", _('Asterisk Manager Proxy is running'));
317         } else {
318             $out .= draw_status_box(_("Manager Proxy"), "warn", _('Asterisk Manager Proxy is not running, FreePBX will fall back to using Asterisk directly, which may result in poor performance'));
319         }       
320     }
321     
322     // fop
323     if ($procinfo->check_fop_server()) {
324         $out .= draw_status_box(_("Op Panel"), "ok", _('FOP Operator Panel Server is running'));
325     } else {
326         if (isset($amp_conf['FOPRUN']) && $amp_conf['FOPRUN']) {
327             // it should be running
328             $out .= draw_status_box(_("Op Panel"), "warn", _('FOP Operator Panel Server is not running, you will not be able to use the operator panel, but the system will run fine without it.'));
329         } else {
330             $out .= draw_status_box(_("Op Panel"), "disabled", _('FOP Operator Panel is disabled in amportal.conf'));
331         }
332     }
333     
334     // mysql
335     if ($amp_conf['AMPDBENGINE'] == "mysql") {
336         /* this is silly- it's always running, if the web interface loads
337         if ($procinfo->check_mysql($amp_conf['AMPDBHOST'])) {
338             $out .= draw_status_box(_("MySQL"), "ok", _('MySQL Server is running'));
339         } else {
340             $out .= draw_status_box(_("MySQL"), "error", _('MySQL Server is not running, this is a critical service for the web interface and call logs!'));
341         }
342         */
343         $out .= draw_status_box(_("MySQL"), "ok", _('MySQL Server is running'));
344     }
345     
346     // web always runs .. HOWEVER, we can turn it off with dhtml
347     $out .= draw_status_box(_("Web Server"), "ok", _('Web Server is running'));
348     
349     // ssh   
350     $ssh_port = (isset($amp_conf['SSHPORT']) && ctype_digit($amp_conf['SSHPORT']) && ($amp_conf['SSHPORT'] > 0) && ($amp_conf['SSHPORT'] < 65536))?$amp_conf['SSHPORT']:22;
351     if ($procinfo->check_port($ssh_port)) {
352         $out .= draw_status_box(_("SSH Server"), "ok", _('SSH Server is running'));
353     } else {
354         $out .= draw_status_box(_("SSH Server"), "warn", _('SSH Server is not running, you will not be able to connect to the system console remotely'));
355     }
356     return $out;
357 }
358
359 function show_syslog(&$md5_checksum) {
360     global $db;
361     $out = '';
362     $checksum = '';
363
364     // notify_classes are also used as the image names
365     $notify_classes = array(
366         NOTIFICATION_TYPE_CRITICAL => 'notify_critical',
367         NOTIFICATION_TYPE_SECURITY => 'notify_security',
368         NOTIFICATION_TYPE_UPDATE => 'notify_update',
369         NOTIFICATION_TYPE_ERROR => 'notify_error',
370         NOTIFICATION_TYPE_WARNING => 'notify_warning',
371         NOTIFICATION_TYPE_NOTICE => 'notify_notice',
372     );
373     $notify_descriptions = array(
374         NOTIFICATION_TYPE_CRITICAL => _('Critical Error'),
375         NOTIFICATION_TYPE_SECURITY => _('Security Update'),
376         NOTIFICATION_TYPE_UPDATE => _('Update'),
377         NOTIFICATION_TYPE_ERROR => _('Error'),
378         NOTIFICATION_TYPE_WARNING => _('Warning'),
379         NOTIFICATION_TYPE_NOTICE => _('Notice'),
380     );
381     
382     $notify =& notifications::create($db);
383     
384     $showall = (isset($_SESSION['syslog_showall']) ? $_SESSION['syslog_showall'] : false);
385     
386     $items = $notify->list_all($showall);
387
388     $out .= "<h3>"._("FreePBX Notices")."</h3>";
389     
390     if (count($items)) {
391         $out .= '<ul>';
392         foreach ($items as $item) {
393             $checksum .= $item['module'].$item['id']; // checksum, so it is only updated on the page if this has changed
394             
395             $domid = "notify_item_".str_replace(' ','_',$item['module']).'_'.str_replace(' ','_',$item['id']);
396             
397             $out .= '<li id="'.$domid.'" ';
398             if (isset($notify_classes[$item['level']])) {
399                 $out .= ' class="'.$notify_classes[$item['level']].'"';
400             }
401             $out .= '><div>';
402
403             $out .= '<h4 class="syslog_text">';
404             $out .= '<span><img src="images/'.$notify_classes[$item['level']].'.png" alt="'.$notify_descriptions[$item['level']].'" title="'.$notify_descriptions[$item['level']].'" width="16" height="16" border="0" />&nbsp;';
405             $out .= $item['display_text'].'</span>';
406             $out .= '<div class="notification_buttons">';
407             if (isset($item['candelete']) && $item['candelete']) {
408                 $out .= '<a class="notify_ignore_btn" title="'._('Delete this').'" '.
409                         'onclick="delete_notification(\''.$domid.'\', \''.$item['module'].'\', \''.$item['id'].'\');">'.
410                         '<img src="images/cancel.png" width="16" height="16" border="0" alt="'._('Delete this').'" /></a>';
411             }
412             if (!$item['reset']) {
413                 $out .= '<a class="notify_ignore_btn" title="'._('Ignore this').'" '.
414                         'onclick="hide_notification(\''.$domid.'\', \''.$item['module'].'\', \''.$item['id'].'\');">'.
415                         '<img src="'.dirname($_SERVER['PHP_SELF']).'/images/notify_delete.png" width="16" height="16" border="0" alt="'._('Ignore this').'" /></a>';
416             }
417             $out .= '</div>';
418             $out .= '</h4>';
419             
420             $out .= '<div class="syslog_detail">';
421             $out .= nl2br($item['extended_text']);
422             $out .= '<br/><span>'.sprintf('Added %s ago', time_string(time() - $item['timestamp'])).'<br/>'.
423                     '('.$item['module'].'.'.$item['id'].')</span>';
424             $out .= '</div>';
425             
426             $out .= '</div></li>';
427         }
428         $out .= '</ul>';
429     } else {
430         if ($showall) {
431             $out .= _('No notifications');
432         } else {
433             $out .= _('No new notifications');
434         }
435     }
436     
437     $md5_checksum = md5($checksum);
438     
439     $out .= '<div id="syslog_button">';
440     if ($showall) {
441         $out .= '<a href="#" onclick="changeSyslog(0);">'._('show new').'</a>';
442     } else {
443         $out .= '<a href="#" onclick="changeSyslog(1);">'._('show all').'</a>';
444     }
445     $out .= '</div>';
446     return $out;
447 }
448
449 function do_syslog_ack() {   
450     global $db;
451     $notify =& notifications::create($db);
452     
453     if (isset($_REQUEST['module']) && $_REQUEST['id']) {
454         $notify->reset($_REQUEST['module'], $_REQUEST['id']);
455     }
456 }
457 function do_syslog_delete() {   
458     global $db;
459     $notify =& notifications::create($db);
460     
461     if (isset($_REQUEST['module']) && $_REQUEST['id']) {
462     var_dump($_REQUEST);
463         $notify->safe_delete($_REQUEST['module'], $_REQUEST['id']);
464     }
465 }
466
467 /********************************************************************************************/
468
469
470 define("IN_PHPSYSINFO", "1");
471 define("APP_ROOT", dirname(__FILE__).'/phpsysinfo');
472 include APP_ROOT."/common_functions.php";
473 include APP_ROOT."/class.".PHP_OS.".inc.php";
474 include_once "common/json.inc.php";
475 include dirname(__FILE__)."/class.astinfo.php";
476 include dirname(__FILE__)."/class.average_rate_calculator.php";
477 include dirname(__FILE__)."/class.procinfo.php";
478 include dirname(__FILE__)."/class.error.inc.php";
479
480 $error = new Error;
481
482
483 $sysinfo = new sysinfo;
484 $astinfo = new astinfo($astman);
485 $procinfo = new procinfo;
486
487
488 if (!$quietmode) {
489     ?>
490    
491     <script language="javascript">
492     $(document).ready(function(){
493         $.ajaxTimeout( 20000 );
494         scheduleInfoUpdate();
495         scheduleStatsUpdate();
496        
497         makeSyslogClickable();
498     });
499    
500     function makeSyslogClickable() {
501         $('#syslog h4 span').click(function() {
502             $(this).parent().next('div').slideToggle('fast');
503         });
504     }
505    
506     var syslog_md5;
507     var webserver_fail = 0;
508     var info_timer = null;
509     var stats_timer = null;
510
511     function updateFailed(reqObj, status) {
512         // stop updating
513         clearTimeout(stats_timer);
514         stats_timer = null;
515         clearTimeout(info_timer);
516         info_timer = null;
517
518         webserver_fail += 1;
519         webobj = $('#datavalue_Web_Server')
520
521         if (webserver_fail == 1) {
522             webobj.text("Timeout");
523             webobj.removeClass("graphok");
524             webobj.addClass("graphwarn");   
525         } else {
526             webobj.text("ERROR");
527             webobj.removeClass("graphok");
528             webobj.removeClass("graphwarn");
529             webobj.addClass("grapherror");
530         }
531         scheduleInfoUpdate();
532     }
533
534
535     function updateInfo() {
536         $.ajax({
537             type: 'GET',
538             url: "<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=info",
539             dataType: 'json',
540             success: function(data) {
541                 $('#procinfo').html(data.procinfo);
542                 $('#sysinfo').html(data.sysinfo);
543                 // only update syslog div if the md5 has changed
544                 if (syslog_md5 != data.syslog_md5) {
545                     $('#syslog').html(data.syslog);
546                     makeSyslogClickable();
547                     syslog_md5 = data.syslog_md5;
548                 }
549
550                 // webserver is ok
551                 webserver_fail = 0;
552
553                 scheduleInfoUpdate();
554                 if (stats_timer == null) {
555                     // restart stats updates
556                     scheduleStatsUpdate();
557                 }
558             },
559             error: updateFailed
560         });
561     }
562     function scheduleInfoUpdate() {
563         info_timer = setTimeout('updateInfo();',<?php echo INFO_UPDATE_TIME; ?>000);
564     }
565    
566    
567     function updateStats() {
568         $.ajax({
569             type: 'GET',
570             url: "<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=stats",
571             dataType: 'json',
572             success: function(data) {
573                 $('#sysstats').html(data.sysstats);
574                 $('#aststats').html(data.aststats);
575                 scheduleStatsUpdate();
576             },
577             error: updateFailed
578         });
579     }
580     function scheduleStatsUpdate() {
581         stats_timer = setTimeout('updateStats();',<?php echo STATS_UPDATE_TIME; ?>000);
582     }
583    
584    
585     function changeSyslog(showall) {
586         $('#syslog_button').text('<?php echo _('loading...'); ?>');
587         $('#syslog').load("<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=syslog&showall="+showall,{}, function() {
588             makeSyslogClickable();
589         });
590     }
591
592     function hide_notification(domid, module, id) {
593         $('#'+domid).fadeOut('slow');
594         $.post('config.php', {display:'<?php echo $module_page; ?>', quietmode:1, info:'syslog_ack', module:module, id:id});
595     }
596     function delete_notification(domid, module, id) {
597         $('#'+domid).fadeOut('slow');
598         $.post('config.php', {display:'<?php echo $module_page; ?>', quietmode:1, info:'syslog_delete', module:module, id:id});
599     }
600     </script>
601
602     <h2>FreePBX System Status</h2>
603     </div>
604     <div id="dashboard">
605     <?php
606     echo '<div id="sysinfo-left">';
607     
608     // regular page
609     echo '<div id="syslog" class="infobox">';
610     echo show_syslog($syslog_md5);
611     // syslog_md5 is used by javascript updateInfo() to determine if the syslog div contents have changed
612     echo '<script type="text/javascript"> syslog_md5 = "'.$syslog_md5.'"; </script>';
613     //echo "log goes here<br/><br/><br/>";
614     echo '</div>';
615     
616     echo '<div id="aststats" class="infobox">';
617     echo show_aststats();
618     echo '</div>';
619     
620     
621     echo '<div id="sysinfo" class="infobox">';
622     echo show_sysinfo();
623     echo '</div>';
624     
625     
626     
627     echo '</div><div id="sysinfo-right">';
628     
629     
630     
631     echo '<div id="sysstats" class="infobox">';
632     echo show_sysstats();
633     echo '</div>';
634     
635     echo '<div id="procinfo" class="infobox">';
636     echo show_procinfo();
637     echo '</div>';
638     
639     echo '<div style="clear:both;"></div>';
640     
641     echo '</div></div>'; // #sysinfo, #sysinfo-right
642     
643     echo '<div class="content">';
644
645     if($dashboard_debug && $error->ErrorsExist()) {
646         $fh = fopen($amp_conf['ASTLOGDIR']."/dashboard-error.log","a");
647         fwrite($fh, $error->ErrorsAsText());
648         fclose($fh);
649     }           
650
651 } else {
652     // Handle AJAX updates
653     
654     switch ($info) {
655         case "sysstats":
656             echo show_sysstats();
657         break;
658         case "aststats":
659             echo show_aststats();
660         break;
661         case "procinfo":
662             echo show_procinfo();
663         break;
664         case 'sysinfo':
665             echo show_sysinfo();
666         break;
667         case 'syslog':
668             echo show_syslog($syslog_md5);   
669             // syslog_md5 is used by javascript updateInfo() to determine if the syslog div contents have changed
670             echo '<script type="text/javascript"> syslog_md5 = "'.$syslog_md5.'"; </script>';
671         break;
672         case 'syslog_ack':
673             do_syslog_ack();
674         break;
675         case 'syslog_delete':
676             do_syslog_delete();
677         break;
678         
679         case 'info':
680             $json = new Services_JSON();
681             echo $json->encode(
682                 array(
683                     'procinfo'=>show_procinfo(),
684                     'sysinfo'=>show_sysinfo(),
685                     'syslog'=>show_syslog($syslog_md5),
686                     'syslog_md5'=>$syslog_md5,
687                 )
688             );
689         break;
690         case 'stats':
691             $json = new Services_JSON();
692             echo $json->encode(
693                 array(
694                     'sysstats'=>show_sysstats(),
695                     'aststats'=>show_aststats(),
696                 )
697             );
698         break;
699         case 'all':
700             $json = new Services_JSON();
701             echo $json->encode(
702                 array(
703                     'sysstats'=>show_sysstats(),
704                     'aststats'=>show_aststats(),
705                     'procinfo'=>show_procinfo(),
706                     'sysinfo'=>show_sysinfo(),
707                     'syslog'=>show_syslog(),
708                 )
709             );
710         break;
711     }
712 }
713
714 ?>
715
Note: See TracBrowser for help on using the browser.