| 1 |
<?php |
|---|
| 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'; |
|---|
| 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 |
|
|---|
| 30 |
|
|---|
| 31 |
define('BAR_WIDTH_LEFT', 400); |
|---|
| 32 |
define('BAR_WIDTH_RIGHT', 200); |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
define('STATS_UPDATE_TIME', 6); |
|---|
| 36 |
define('INFO_UPDATE_TIME', 30); |
|---|
| 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 |
$clean_val = preg_replace("/[^0-9\.]*/","",$val); |
|---|
| 60 |
|
|---|
| 61 |
if ($total == 0) { |
|---|
| 62 |
$percent = ($clean_val == 0) ? 0 : 100; |
|---|
| 63 |
} else { |
|---|
| 64 |
$percent = round($clean_val/$total*100); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
$graph_class = false; |
|---|
| 68 |
foreach ($classes as $limit=>$class) { |
|---|
| 69 |
if (!$graph_class) { |
|---|
| 70 |
$graph_class = $class; |
|---|
| 71 |
} |
|---|
| 72 |
if ($limit <= $percent) { |
|---|
| 73 |
$graph_class = $class; |
|---|
| 74 |
} else { |
|---|
| 75 |
break; |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
$width = $total_width * ($percent/100); |
|---|
| 79 |
if ($width > $total_width) { |
|---|
| 80 |
$width = $total_width; |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
$tooltip = $text.": ".$val.$real_units." / ".$total.$real_units." (".$percent."%)"; |
|---|
| 84 |
$display_value = ($show_percent ? $percent."%" : $val.$real_units); |
|---|
| 85 |
|
|---|
| 86 |
$out = "<div class=\"databox graphbox\" style=\"width:".$total_width."px;\">\n"; |
|---|
| 87 |
$out .= " <div class=\"bargraph ".$graph_class."\" style=\"width:".$width."px;\"></div>\n"; |
|---|
| 88 |
$out .= " <div class=\"dataname\">".$text."</div>\n"; |
|---|
| 89 |
$out .= " <div class=\"datavalue\"><a href=\"#\" title=\"".$tooltip."\">".$display_value."</a></div>\n"; |
|---|
| 90 |
$out .= "</div>\n"; |
|---|
| 91 |
|
|---|
| 92 |
return $out; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
function draw_status_box($text, $status, $tooltip = false, $total_width = 200) { |
|---|
| 96 |
switch ($status) { |
|---|
| 97 |
case "ok": |
|---|
| 98 |
$status_text = _("OK"); |
|---|
| 99 |
$class = "graphok"; |
|---|
| 100 |
break; |
|---|
| 101 |
case "warn": |
|---|
| 102 |
$status_text = _("Warn"); |
|---|
| 103 |
$class = "graphwarn"; |
|---|
| 104 |
break; |
|---|
| 105 |
case "error": |
|---|
| 106 |
$status_text = _("ERROR"); |
|---|
| 107 |
$class = "grapherror"; |
|---|
| 108 |
break; |
|---|
| 109 |
case "disabled": |
|---|
| 110 |
$status_text = "Disabled"; |
|---|
| 111 |
$class = ""; |
|---|
| 112 |
break; |
|---|
| 113 |
} |
|---|
| 114 |
if ($tooltip !== false) { |
|---|
| 115 |
$status_text = '<a href="#" title="'.$tooltip.'">'.$status_text.'</a>'; |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
$out = "<div class=\"databox statusbox\" style=\"width:".$total_width."px;\">\n"; |
|---|
| 119 |
$out .= " <div class=\"dataname\">".$text."</div>\n"; |
|---|
| 120 |
$out .= " <div id=\"datavalue_".str_replace(" ","_",$text)."\" class=\"datavalue ".$class."\">".$status_text."</div>\n"; |
|---|
| 121 |
$out .= "</div>\n"; |
|---|
| 122 |
|
|---|
| 123 |
return $out; |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
function draw_box($text, $value, $total_width = 200) { |
|---|
| 127 |
$tooltip = $text.": ".$value; |
|---|
| 128 |
|
|---|
| 129 |
$out = "<div class=\"databox\" style=\"width:".$total_width."px;\">\n"; |
|---|
| 130 |
$out .= " <div class=\"dataname\">".$text."</div>\n"; |
|---|
| 131 |
$out .= " <div class=\"datavalue\"><a href=\"#\" title=\"".$tooltip."\">".$value."</a></div>\n"; |
|---|
| 132 |
$out .= "</div>\n"; |
|---|
| 133 |
|
|---|
| 134 |
return $out; |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
function time_string($seconds) { |
|---|
| 138 |
if ($seconds == 0) { |
|---|
| 139 |
return "0 "._("minutes"); |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
$minutes = floor($seconds / 60); |
|---|
| 143 |
$seconds = $seconds % 60; |
|---|
| 144 |
|
|---|
| 145 |
$hours = floor($minutes / 60); |
|---|
| 146 |
$minutes = $minutes % 60; |
|---|
| 147 |
|
|---|
| 148 |
$days = floor($hours / 24); |
|---|
| 149 |
$hours = $hours % 24; |
|---|
| 150 |
|
|---|
| 151 |
$weeks = floor($days / 7); |
|---|
| 152 |
$days = $days % 7; |
|---|
| 153 |
|
|---|
| 154 |
$output = array(); |
|---|
| 155 |
if ($weeks) { |
|---|
| 156 |
$output[] = $weeks." ".($weeks == 1 ? _("week") : _("weeks")); |
|---|
| 157 |
} |
|---|
| 158 |
if ($days) { |
|---|
| 159 |
$output[] = $days." ".($days == 1 ? _("days") : _("days")); |
|---|
| 160 |
} |
|---|
| 161 |
if ($hours) { |
|---|
| 162 |
$output[] = $hours." ".($hours == 1 ? _("hour") : _("hours")); |
|---|
| 163 |
} |
|---|
| 164 |
if ($minutes) { |
|---|
| 165 |
$output[] = $minutes." ".($minutes == 1 ? _("minute") : _("minutes")); |
|---|
| 166 |
} |
|---|
| 167 |
|
|---|
| 168 |
return implode(", ",$output); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
function show_sysstats() { |
|---|
| 172 |
global $sysinfo; |
|---|
| 173 |
$out = ''; |
|---|
| 174 |
|
|---|
| 175 |
$out .= "<h3>"._("System Statistics")."</h3>"; |
|---|
| 176 |
$out .= "<h4>"._("Processor")."</h4>"; |
|---|
| 177 |
$loadavg = $sysinfo->loadavg(true); |
|---|
| 178 |
$out .= draw_box(_("Load Average"), $loadavg['avg'][0]); |
|---|
| 179 |
$out .= draw_graph(_("CPU"), "", number_format($loadavg['cpupercent'],2), 100); |
|---|
| 180 |
|
|---|
| 181 |
$out .= "<h4>"._("Memory")."</h4>"; |
|---|
| 182 |
$memory = $sysinfo->memory(); |
|---|
| 183 |
$app_memory = isset($memory["ram"]["app"]) ? $memory["ram"]["app"] : $memory["ram"]["total"] - $memory["ram"]["t_free"]; |
|---|
| 184 |
$out .= draw_graph(_("App Memory"), "MB", number_format($app_memory/1024,2), $memory["ram"]["total"]/1024); |
|---|
| 185 |
$out .= draw_graph(_("Swap"), "MB", number_format(($memory["swap"]["total"]-$memory["swap"]["free"])/1024,2), $memory["swap"]["total"]/1024); |
|---|
| 186 |
|
|---|
| 187 |
$out .= "<h4>"._("Disks")."</h4>"; |
|---|
| 188 |
foreach ($sysinfo->filesystems() as $fs) { |
|---|
| 189 |
$out .= draw_graph($fs["mount"], "GB", number_format($fs["used"]/1024/1024, 2), $fs["size"]/1024/1024); |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
$out .= "<h4>"._("Networks")."</h4>"; |
|---|
| 193 |
foreach ($sysinfo->network() as $net_name=>$net) { |
|---|
| 194 |
$net_name = trim($net_name); |
|---|
| 195 |
if ($net_name == 'lo' || $net_name == 'sit0') continue; |
|---|
| 196 |
|
|---|
| 197 |
$tx = new average_rate_calculator($_SESSION["netstats"][$net_name]["tx"], 10); |
|---|
| 198 |
$rx = new average_rate_calculator($_SESSION["netstats"][$net_name]["rx"], 10); |
|---|
| 199 |
|
|---|
| 200 |
$rx->add( $net["rx_bytes"] ); |
|---|
| 201 |
$tx->add( $net["tx_bytes"] ); |
|---|
| 202 |
|
|---|
| 203 |
$out .= draw_box($net_name." "._("receive"), number_format($rx->average()/1000,2)." KB/s"); |
|---|
| 204 |
$out .= draw_box($net_name." "._("transmit"), number_format($tx->average()/1000,2)." KB/s"); |
|---|
| 205 |
} |
|---|
| 206 |
return $out; |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
function show_aststats() { |
|---|
| 210 |
global $amp_conf; |
|---|
| 211 |
global $astinfo; |
|---|
| 212 |
$out = ''; |
|---|
| 213 |
|
|---|
| 214 |
$channels = $astinfo->get_channel_totals(); |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
// guess at the max calls: number of users |
|---|
| 218 |
if (!isset($_SESSION["calculated_max_calls"])) { |
|---|
| 219 |
|
|---|
| 220 |
if (isset($amp_conf['MAXCALLS'])) { |
|---|
| 221 |
$_SESSION["calculated_max_calls"] = $amp_conf["MAXCALLS"]; |
|---|
| 222 |
} else if (function_exists('core_users_list')) { |
|---|
| 223 |
$_SESSION["calculated_max_calls"] = count(core_users_list()); |
|---|
| 224 |
} else { |
|---|
| 225 |
$_SESSION["calculated_max_calls"] = 1; |
|---|
| 226 |
} |
|---|
| 227 |
} |
|---|
| 228 |
|
|---|
| 229 |
if ($channels['total_calls'] > $_SESSION["calculated_max_calls"]) { |
|---|
| 230 |
$_SESSION["calculated_max_calls"] = $channels['total_calls']; |
|---|
| 231 |
} |
|---|
| 232 |
$max_calls = $_SESSION["calculated_max_calls"]; |
|---|
| 233 |
|
|---|
| 234 |
$classes = array(0=>'graphok'); |
|---|
| 235 |
$max_chans = $max_calls * 2; |
|---|
| 236 |
|
|---|
| 237 |
$out .= "<h3>"._("FreePBX Statistics")."</h3>"; |
|---|
| 238 |
$out .= draw_graph(_('Total active calls'), '', $channels['total_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT); |
|---|
| 239 |
$out .= draw_graph(_('Internal calls'), '', $channels['internal_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT); |
|---|
| 240 |
$out .= draw_graph(_('External calls'), '', $channels['external_calls'], $max_calls, $classes , false, BAR_WIDTH_LEFT); |
|---|
| 241 |
$out .= draw_graph(_('Total active channels'), '', $channels['total_channels'], $max_chans, $classes , false, BAR_WIDTH_LEFT); |
|---|
| 242 |
|
|---|
| 243 |
$out .= "<h3>"._("FreePBX Connections")."</h3>"; |
|---|
| 244 |
|
|---|
| 245 |
$peers = $astinfo->get_peers(); |
|---|
| 246 |
$out .= draw_graph(_('IP Phones Online'), '', $peers['sip_online']+$peers['iax2_online'], $peers['sip_total']+$peers['iax2_total'], $classes, false, BAR_WIDTH_LEFT); |
|---|
| 247 |
|
|---|
| 248 |
$regs = $astinfo->get_registrations(); |
|---|
| 249 |
if ($regs['total'] > 0) { |
|---|
| 250 |
$out .= draw_graph(_('Provider Registrations'), '', $regs['registered'], $regs['total'], $classes , false, BAR_WIDTH_LEFT); |
|---|
| 251 |
} |
|---|
| 252 |
return $out; |
|---|
| 253 |
} |
|---|
| 254 |
|
|---|
| 255 |
function show_sysinfo() { |
|---|
| 256 |
global $sysinfo; |
|---|
| 257 |
global $astinfo; |
|---|
| 258 |
$out = '<table>'; |
|---|
| 259 |
|
|---|
| 260 |
$out .= '<tr><th>Distro:</th><td>'.$sysinfo->distro().'</td></tr>'; |
|---|
| 261 |
$out .= '<tr><th>Kernel:</th><td>'.$sysinfo->kernel().'</td></tr>'; |
|---|
| 262 |
$cpu = $sysinfo->cpu_info(); |
|---|
| 263 |
$out .= '<tr><th>CPU:</th><td>'.$cpu['model'].' '.$cpu['cpuspeed'].'</td></tr>'; |
|---|
| 264 |
*/ |
|---|
| 265 |
|
|---|
| 266 |
$out .= "<h3>"._("  ")."</h3></br>"; |
|---|
| 267 |
$out .= '<tr><th>'._('System Uptime').':</th><td>'.time_string($sysinfo->uptime()).'</td></tr>'; |
|---|
| 268 |
$ast_uptime = $astinfo->get_uptime(); |
|---|
| 269 |
if (empty($ast_uptime['system'])) { |
|---|
| 270 |
$ast_uptime['system'] = time_string(0); |
|---|
| 271 |
} |
|---|
| 272 |
if (empty($ast_uptime['reload'])) { |
|---|
| 273 |
$ast_uptime['reload'] = time_string(0); |
|---|
| 274 |
} |
|---|
| 275 |
$out .= '<tr><th>'._('Asterisk Uptime').':</th><td>'.$ast_uptime['system'].'</td></tr>'; |
|---|
| 276 |
$out .= '<tr><th>'._('Last Reload').':</th><td>'.$ast_uptime['reload'].'</td></tr>'; |
|---|
| 277 |
|
|---|
| 278 |
$out .= '</table>'; |
|---|
| 279 |
return $out; |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
function show_procinfo() { |
|---|
| 283 |
global $procinfo; |
|---|
| 284 |
global $astinfo; |
|---|
| 285 |
global $amp_conf; |
|---|
| 286 |
$out = ''; |
|---|
| 287 |
|
|---|
| 288 |
$out .= "<h3>"._("Server Status")."</h3>"; |
|---|
| 289 |
|
|---|
| 290 |
if ($astver = $astinfo->check_asterisk()) { |
|---|
| 291 |
$out .= draw_status_box(_("Asterisk"), "ok", _('Asterisk is running: '.$astver)); |
|---|
| 292 |
} else { |
|---|
| 293 |
$out .= draw_status_box(_("Asterisk"), "error", _('Asterisk is not running, this is a critical service!')); |
|---|
| 294 |
} |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
if (isset($amp_conf['ASTMANAGERPROXYPORT'])) { |
|---|
| 298 |
if ($procinfo->check_port($amp_conf['ASTMANAGERPROXYPORT'])) { |
|---|
| 299 |
$out .= draw_status_box(_("Manager Proxy"), "ok", _('Asterisk Manager Proxy is running')); |
|---|
| 300 |
} else { |
|---|
| 301 |
$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')); |
|---|
| 302 |
} |
|---|
| 303 |
} |
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
if ($procinfo->check_fop_server()) { |
|---|
| 307 |
$out .= draw_status_box(_("Op Panel"), "ok", _('FOP Operator Panel Server is running')); |
|---|
| 308 |
} else { |
|---|
| 309 |
if (isset($amp_conf['FOPRUN']) && $amp_conf['FOPRUN']) { |
|---|
| 310 |
|
|---|
| 311 |
$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.')); |
|---|
| 312 |
} else { |
|---|
| 313 |
$out .= draw_status_box(_("Op Panel"), "disabled", _('FOP Operator Panel is disabled in amportal.conf')); |
|---|
| 314 |
} |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
if ($amp_conf['AMPDBENGINE'] == "mysql") { |
|---|
| 319 |
if ($procinfo->check_mysql()) { |
|---|
| 320 |
$out .= draw_status_box(_("MySQL"), "ok", _('MySQL Server is running')); |
|---|
| 321 |
} else { |
|---|
| 322 |
$out .= draw_status_box(_("MySQL"), "error", _('MySQL Server is not running, this is a critical service for the web interface and call logs!')); |
|---|
| 323 |
} |
|---|
| 324 |
} |
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
$out .= draw_status_box(_("Web Server"), "ok", _('Web Server is running')); |
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
if ($procinfo->check_port(22)) { |
|---|
| 331 |
$out .= draw_status_box(_("SSH Server"), "ok", _('SSH Server is running')); |
|---|
| 332 |
} else { |
|---|
| 333 |
$out .= draw_status_box(_("SSH Server"), "warn", _('SSH Server is not running, you will not be able to connect to the system console remotely')); |
|---|
| 334 |
} |
|---|
| 335 |
return $out; |
|---|
| 336 |
} |
|---|
| 337 |
|
|---|
| 338 |
function show_syslog(&$md5_checksum) { |
|---|
| 339 |
global $db; |
|---|
| 340 |
$out = ''; |
|---|
| 341 |
$checksum = ''; |
|---|
| 342 |
|
|---|
| 343 |
$notify_classes = array( |
|---|
| 344 |
NOTIFICATION_TYPE_CRITICAL => 'notify_critical', |
|---|
| 345 |
NOTIFICATION_TYPE_SECURITY => 'notify_security', |
|---|
| 346 |
NOTIFICATION_TYPE_UPDATE => 'notify_update', |
|---|
| 347 |
NOTIFICATION_TYPE_ERROR => 'notify_error', |
|---|
| 348 |
NOTIFICATION_TYPE_WARNING => 'notify_warning', |
|---|
| 349 |
NOTIFICATION_TYPE_NOTICE => 'notify_notice', |
|---|
| 350 |
); |
|---|
| 351 |
|
|---|
| 352 |
$notify =& notifications::create($db); |
|---|
| 353 |
|
|---|
| 354 |
$showall = (isset($_SESSION['syslog_showall']) ? $_SESSION['syslog_showall'] : false); |
|---|
| 355 |
|
|---|
| 356 |
$items = $notify->list_all($showall); |
|---|
| 357 |
|
|---|
| 358 |
$out .= "<h3>"._("FreePBX Notices")."</h3>"; |
|---|
| 359 |
|
|---|
| 360 |
if (count($items)) { |
|---|
| 361 |
$out .= '<ul>'; |
|---|
| 362 |
foreach ($items as $item) { |
|---|
| 363 |
$checksum .= $item['module'].$item['id']; |
|---|
| 364 |
|
|---|
| 365 |
$domid = "notify_item_".str_replace(' ','_',$item['module']).'_'.str_replace(' ','_',$item['id']); |
|---|
| 366 |
|
|---|
| 367 |
$out .= '<li id="'.$domid.'" '; |
|---|
| 368 |
if (isset($notify_classes[$item['level']])) { |
|---|
| 369 |
$out .= ' class="'.$notify_classes[$item['level']].'"'; |
|---|
| 370 |
} |
|---|
| 371 |
$out .= '><div>'; |
|---|
| 372 |
|
|---|
| 373 |
$out .= '<h4 class="syslog_text"><span>'.$item['display_text'].'</span>'; |
|---|
| 374 |
$out .= '<div class="notification_buttons">'; |
|---|
| 375 |
if (isset($item['candelete']) && $item['candelete']) { |
|---|
| 376 |
$out .= '<a class="notify_ignore_btn" title="'._('Delete this').'" '. |
|---|
| 377 |
'onclick="delete_notification(\''.$domid.'\', \''.$item['module'].'\', \''.$item['id'].'\');">'. |
|---|
| 378 |
'<img src="images/cancel.png" width="16" height="16" border="0" alt="'._('Delete this').'" /></a>'; |
|---|
| 379 |
} |
|---|
| 380 |
if (!$item['reset']) { |
|---|
| 381 |
$out .= '<a class="notify_ignore_btn" title="'._('Ignore this').'" '. |
|---|
| 382 |
'onclick="hide_notification(\''.$domid.'\', \''.$item['module'].'\', \''.$item['id'].'\');">'. |
|---|
| 383 |
'<img src="'.dirname($_SERVER['PHP_SELF']).'/images/notify_delete.png" width="16" height="16" border="0" alt="'._('Ignore this').'" /></a>'; |
|---|
| 384 |
} |
|---|
| 385 |
$out .= '</div>'; |
|---|
| 386 |
$out .= '</h4>'; |
|---|
| 387 |
|
|---|
| 388 |
$out .= '<div class="syslog_detail">'; |
|---|
| 389 |
$out .= nl2br($item['extended_text']); |
|---|
| 390 |
$out .= '<br/><span>'.sprintf('Added %s ago', time_string(time() - $item['timestamp'])).'<br/>'. |
|---|
| 391 |
'('.$item['module'].'.'.$item['id'].')</span>'; |
|---|
| 392 |
$out .= '</div>'; |
|---|
| 393 |
|
|---|
| 394 |
$out .= '</div></li>'; |
|---|
| 395 |
} |
|---|
| 396 |
$out .= '</ul>'; |
|---|
| 397 |
} else { |
|---|
| 398 |
if ($showall) { |
|---|
| 399 |
$out .= _('No notifications'); |
|---|
| 400 |
} else { |
|---|
| 401 |
$out .= _('No new notifications'); |
|---|
| 402 |
} |
|---|
| 403 |
} |
|---|
| 404 |
|
|---|
| 405 |
$md5_checksum = md5($checksum); |
|---|
| 406 |
|
|---|
| 407 |
$out .= '<div id="syslog_button">'; |
|---|
| 408 |
if ($showall) { |
|---|
| 409 |
$out .= '<a href="#" onclick="changeSyslog(0);">'._('show new').'</a>'; |
|---|
| 410 |
} else { |
|---|
| 411 |
$out .= '<a href="#" onclick="changeSyslog(1);">'._('show all').'</a>'; |
|---|
| 412 |
} |
|---|
| 413 |
$out .= '</div>'; |
|---|
| 414 |
return $out; |
|---|
| 415 |
} |
|---|
| 416 |
|
|---|
| 417 |
function do_syslog_ack() { |
|---|
| 418 |
global $db; |
|---|
| 419 |
$notify =& notifications::create($db); |
|---|
| 420 |
|
|---|
| 421 |
if (isset($_REQUEST['module']) && $_REQUEST['id']) { |
|---|
| 422 |
$notify->reset($_REQUEST['module'], $_REQUEST['id']); |
|---|
| 423 |
} |
|---|
| 424 |
} |
|---|
| 425 |
function do_syslog_delete() { |
|---|
| 426 |
global $db; |
|---|
| 427 |
$notify =& notifications::create($db); |
|---|
| 428 |
|
|---|
| 429 |
if (isset($_REQUEST['module']) && $_REQUEST['id']) { |
|---|
| 430 |
var_dump($_REQUEST); |
|---|
| 431 |
$notify->safe_delete($_REQUEST['module'], $_REQUEST['id']); |
|---|
| 432 |
} |
|---|
| 433 |
} |
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
|
|---|
| 437 |
|
|---|
| 438 |
define("IN_PHPSYSINFO", "1"); |
|---|
| 439 |
define("APP_ROOT", dirname(__FILE__).'/phpsysinfo'); |
|---|
| 440 |
include APP_ROOT."/common_functions.php"; |
|---|
| 441 |
include APP_ROOT."/class.".PHP_OS.".inc.php"; |
|---|
| 442 |
include_once "common/json.inc.php"; |
|---|
| 443 |
include dirname(__FILE__)."/class.astinfo.php"; |
|---|
| 444 |
include dirname(__FILE__)."/class.average_rate_calculator.php"; |
|---|
| 445 |
include dirname(__FILE__)."/class.procinfo.php"; |
|---|
| 446 |
include dirname(__FILE__)."/class.error.inc.php"; |
|---|
| 447 |
|
|---|
| 448 |
$error = new Error; |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
$sysinfo = new sysinfo; |
|---|
| 452 |
$astinfo = new astinfo($astman); |
|---|
| 453 |
$procinfo = new procinfo; |
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
if (!$quietmode) { |
|---|
| 457 |
?> |
|---|
| 458 |
|
|---|
| 459 |
<script language="javascript"> |
|---|
| 460 |
$(document).ready(function(){ |
|---|
| 461 |
$.ajaxTimeout( 20000 ); |
|---|
| 462 |
scheduleInfoUpdate(); |
|---|
| 463 |
scheduleStatsUpdate(); |
|---|
| 464 |
|
|---|
| 465 |
makeSyslogClickable(); |
|---|
| 466 |
}); |
|---|
| 467 |
|
|---|
| 468 |
function makeSyslogClickable() { |
|---|
| 469 |
$('#syslog h4 span').click(function() { |
|---|
| 470 |
$(this).parent().next('div').slideToggle('fast'); |
|---|
| 471 |
}); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
var syslog_md5; |
|---|
| 475 |
function updateInfo() { |
|---|
| 476 |
$.ajax({ |
|---|
| 477 |
type: 'GET', |
|---|
| 478 |
url: "<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=info", |
|---|
| 479 |
dataType: 'json', |
|---|
| 480 |
success: function(data) { |
|---|
| 481 |
$('#procinfo').html(data.procinfo); |
|---|
| 482 |
$('#sysinfo').html(data.sysinfo); |
|---|
| 483 |
// only update syslog div if the md5 has changed |
|---|
| 484 |
if (syslog_md5 != data.syslog_md5) { |
|---|
| 485 |
$('#syslog').html(data.syslog); |
|---|
| 486 |
makeSyslogClickable(); |
|---|
| 487 |
syslog_md5 = data.syslog_md5; |
|---|
| 488 |
} |
|---|
| 489 |
scheduleInfoUpdate(); |
|---|
| 490 |
}, |
|---|
| 491 |
error: function(reqObj, status) { |
|---|
| 492 |
$('#datavalue_Web_Server').text("ERROR"); |
|---|
| 493 |
$('#datavalue_Web_Server').removeClass("graphok"); |
|---|
| 494 |
$('#datavalue_Web_Server').addClass("grapherror"); |
|---|
| 495 |
}, |
|---|
| 496 |
}); |
|---|
| 497 |
} |
|---|
| 498 |
function scheduleInfoUpdate() { |
|---|
| 499 |
setTimeout('updateInfo();',<?php echo INFO_UPDATE_TIME; ?>000); |
|---|
| 500 |
} |
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
function updateStats() { |
|---|
| 504 |
$.ajax({ |
|---|
| 505 |
type: 'GET', |
|---|
| 506 |
url: "<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=stats", |
|---|
| 507 |
dataType: 'json', |
|---|
| 508 |
success: function(data) { |
|---|
| 509 |
$('#sysstats').html(data.sysstats); |
|---|
| 510 |
$('#aststats').html(data.aststats); |
|---|
| 511 |
scheduleStatsUpdate(); |
|---|
| 512 |
}, |
|---|
| 513 |
error: function(reqObj, status) { |
|---|
| 514 |
$('#datavalue_Web_Server').text("ERROR"); |
|---|
| 515 |
$('#datavalue_Web_Server').removeClass("graphok"); |
|---|
| 516 |
$('#datavalue_Web_Server').addClass("grapherror"); |
|---|
| 517 |
$('#syslog').prepend('<div class="warning">Warning: Update timed out<br/></div>'); |
|---|
| 518 |
}, |
|---|
| 519 |
}); |
|---|
| 520 |
} |
|---|
| 521 |
function scheduleStatsUpdate() { |
|---|
| 522 |
setTimeout('updateStats();',<?php echo STATS_UPDATE_TIME; ?>000); |
|---|
| 523 |
} |
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
function changeSyslog(showall) { |
|---|
| 527 |
$('#syslog_button').text('<?php echo _('loading...'); ?>'); |
|---|
| 528 |
$('#syslog').load("<?php echo $_SERVER["PHP_SELF"]; ?>?type=tool&display=<?php echo $module_page; ?>&quietmode=1&info=syslog&showall="+showall,{}, function() { |
|---|
| 529 |
makeSyslogClickable(); |
|---|
| 530 |
}); |
|---|
| 531 |
} |
|---|
| 532 |
|
|---|
| 533 |
function hide_notification(domid, module, id) { |
|---|
| 534 |
$('#'+domid).fadeOut('slow'); |
|---|
| 535 |
$.post('config.php', {display:'<?php echo $module_page; ?>', quietmode:1, info:'syslog_ack', module:module, id:id}); |
|---|
| 536 |
} |
|---|
| 537 |
function delete_notification(domid, module, id) { |
|---|
| 538 |
$('#'+domid).fadeOut('slow'); |
|---|
| 539 |
$.post('config.php', {display:'<?php echo $module_page; ?>', quietmode:1, info:'syslog_delete', module:module, id:id}); |
|---|
| 540 |
} |
|---|
| 541 |
</script> |
|---|
| 542 |
|
|---|
| 543 |
<h2>FreePBX System Status</h2> |
|---|
| 544 |
</div> |
|---|
| 545 |
<div id="dashboard"> |
|---|
| 546 |
<?php |
|---|
| 547 |
echo '<div id="sysinfo-left">'; |
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
echo '<div id="syslog" class="infobox">'; |
|---|
| 551 |
echo show_syslog($syslog_md5); |
|---|
| 552 |
|
|---|
| 553 |
echo '<script type="text/javascript"> syslog_md5 = "'.$syslog_md5.'"; </script>'; |
|---|
| 554 |
|
|---|
| 555 |
echo '</div>'; |
|---|
| 556 |
|
|---|
| 557 |
echo '<div id="aststats" class="infobox">'; |
|---|
| 558 |
echo show_aststats(); |
|---|
| 559 |
echo '</div>'; |
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
echo '<div id="sysinfo" class="infobox">'; |
|---|
| 563 |
echo show_sysinfo(); |
|---|
| 564 |
echo '</div>'; |
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
echo '</div><div id="sysinfo-right">'; |
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
echo '<div id="sysstats" class="infobox">'; |
|---|
| 573 |
echo show_sysstats(); |
|---|
| 574 |
echo '</div>'; |
|---|
| 575 |
|
|---|
| 576 |
echo '<div id="procinfo" class="infobox">'; |
|---|
| 577 |
echo show_procinfo(); |
|---|
| 578 |
echo '</div>'; |
|---|
| 579 |
|
|---|
| 580 |
echo '<div style="clear:both;"></div>'; |
|---|
| 581 |
|
|---|
| 582 |
echo '</div></div>'; |
|---|
| 583 |
|
|---|
| 584 |
echo '<div class="content">'; |
|---|
| 585 |
|
|---|
| 586 |
if($dashboard_debug && $error->ErrorsExist()) { |
|---|
| 587 |
$fh = fopen($amp_conf['ASTLOGDIR']."/dashboard-error.log","a"); |
|---|
| 588 |
fwrite($fh, $error->ErrorsAsText()); |
|---|
| 589 |
fclose($fh); |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
} else { |
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
switch ($info) { |
|---|
| 596 |
case "sysstats": |
|---|
| 597 |
echo show_sysstats(); |
|---|
| 598 |
break; |
|---|
| 599 |
case "aststats": |
|---|
| 600 |
echo show_aststats(); |
|---|
| 601 |
break; |
|---|
| 602 |
case "procinfo": |
|---|
| 603 |
echo show_procinfo(); |
|---|
| 604 |
break; |
|---|
| 605 |
case 'sysinfo': |
|---|
| 606 |
echo show_sysinfo(); |
|---|
| 607 |
break; |
|---|
| 608 |
case 'syslog': |
|---|
| 609 |
echo show_syslog($syslog_md5); |
|---|
| 610 |
|
|---|
| 611 |
echo '<script type="text/javascript"> syslog_md5 = "'.$syslog_md5.'"; </script>'; |
|---|
| 612 |
break; |
|---|
| 613 |
case 'syslog_ack': |
|---|
| 614 |
do_syslog_ack(); |
|---|
| 615 |
break; |
|---|
| 616 |
case 'syslog_delete': |
|---|
| 617 |
do_syslog_delete(); |
|---|
| 618 |
break; |
|---|
| 619 |
|
|---|
| 620 |
case 'info': |
|---|
| 621 |
$json = new Services_JSON(); |
|---|
| 622 |
echo $json->encode( |
|---|
| 623 |
array( |
|---|
| 624 |
'procinfo'=>show_procinfo(), |
|---|
| 625 |
'sysinfo'=>show_sysinfo(), |
|---|
| 626 |
'syslog'=>show_syslog($syslog_md5), |
|---|
| 627 |
'syslog_md5'=>$syslog_md5, |
|---|
| 628 |
) |
|---|
| 629 |
); |
|---|
| 630 |
break; |
|---|
| 631 |
case 'stats': |
|---|
| 632 |
$json = new Services_JSON(); |
|---|
| 633 |
echo $json->encode( |
|---|
| 634 |
array( |
|---|
| 635 |
'sysstats'=>show_sysstats(), |
|---|
| 636 |
'aststats'=>show_aststats(), |
|---|
| 637 |
) |
|---|
| 638 |
); |
|---|
| 639 |
break; |
|---|
| 640 |
case 'all': |
|---|
| 641 |
$json = new Services_JSON(); |
|---|
| 642 |
echo $json->encode( |
|---|
| 643 |
array( |
|---|
| 644 |
'sysstats'=>show_sysstats(), |
|---|
| 645 |
'aststats'=>show_aststats(), |
|---|
| 646 |
'procinfo'=>show_procinfo(), |
|---|
| 647 |
'sysinfo'=>show_sysinfo(), |
|---|
| 648 |
'syslog'=>show_syslog(), |
|---|
| 649 |
) |
|---|
| 650 |
); |
|---|
| 651 |
break; |
|---|
| 652 |
} |
|---|
| 653 |
} |
|---|
| 654 |
|
|---|
| 655 |
?> |
|---|
| 656 |
|
|---|