public function getContent($section) { if (!class_exists('\\CPUInfo')) { include dirname(__DIR__) . '/classes/CPUInfo.class.php'; } if (!class_exists('\\TimeUtils')) { include dirname(__DIR__) . '/classes/TimeUtils.class.php'; } $cpu = new \CPUInfo(); $time = \TimeUtils::getReadable($this->getUptimeSecs()); return load_view(dirname(__DIR__) . '/views/sections/uptime.php', array("cpu" => $cpu->getAll(), "time" => $time)); }
private function getNotifications($showall = false) { if (!class_exists('TimeUtils')) { include dirname(__DIR__) . '/classes/TimeUtils.class.php'; } $final['nots'] = array(); $items = \FreePBX::create()->Notifications->list_all($showall); $allItems = \FreePBX::create()->Notifications->list_all(true); $final['showAllMessage'] = count($items) != count($allItems); // This is where we map the Notifications priorities to Bootstrap priorities. // define("NOTIFICATION_TYPE_CRITICAL", 100) -> 'danger' (red) // define("NOTIFICATION_TYPE_SECURITY", 200) -> 'danger' (red) // define("NOTIFICATION_TYPE_UPDATE", 300) -> 'warning' (orange) // define("NOTIFICATION_TYPE_ERROR", 400) -> 'danger' (red) // define("NOTIFICATION_TYPE_WARNING" , 500) -> 'warning' -> (orange) // define("NOTIFICATION_TYPE_NOTICE", 600) -> 'success' -> (green) $alerts = array(100 => "danger", 200 => "danger", 250 => 'warning', 300 => "warning", 400 => "danger", 500 => "warning", 600 => "success"); foreach ($items as $notification) { $final['nots'][] = array("id" => $notification['id'], "rawlevel" => $notification['level'], "level" => !isset($alerts[$notification['level']]) ? 'danger' : $alerts[$notification['level']], "candelete" => $notification['candelete'], "title" => $notification['display_text'], "time" => \TimeUtils::getReadable(time() - $notification['timestamp']), "text" => nl2br($notification['extended_text']), "module" => $notification['module'], "link" => $notification['link'], "reset" => $notification['reset']); } return $final; }
public function getGraphDataUptime($period) { $si = FreePBX::create()->Dashboard->getSysInfoPeriod($period); if (!class_exists('TimeUtils')) { include 'TimeUtils.class.php'; } $tooltips = array(); $sysuptime = array(); $astuptime = array(); $astreload = array(); foreach ($si as $key => $row) { if (!isset($row['ast.uptime.system-seconds'])) { $us = 0; $rs = 0; $ut = 0; } else { $us = $row['ast.uptime.system-seconds']; $rs = $row['ast.uptime.reload-seconds']; $ut = $row['*****@*****.**']; } $ttip = date('c', $key) . "<br>"; $ttip .= _("System") . ":<br> " . TimeUtils::getReadable($ut, 3) . "<br>"; $ttip .= "Asterisk:<br> " . TimeUtils::getReadable($us, 3) . "<br>"; $ttip .= _("Since Reload") . ":<br> " . TimeUtils::getReadable($rs, 3); $tooltips[] = $ttip; $sysuptime[] = $ut; $astuptime[] = $us; $astreload[] = $rs; } $retarr['template'] = 'aststat'; $retarr['tooltips'] = $tooltips; $retarr['values'] = array("sysuptime" => $sysuptime, "astuptime" => $astuptime, "astreload" => $astreload); $retarr['series'] = array("sysuptime" => array("color" => "red", "axis" => "l"), "astuptime" => array("color" => "green", "axis" => "l"), "astreload" => array("color" => "blue", "axis" => "r")); $retarr['axis'] = array("r" => array("title" => _("Reload"), "titleDistance" => 8), "l" => array("title" => _("System"), "titleDistance" => 8)); $retarr['legend'] = array("sysuptime" => _('System Uptime'), "astuptime" => _('Asterisk Uptime'), "astreload" => _('Since Reload')); return $retarr; }
public function get_uptime() { $output = array('system' => 'Unknown', 'reload' => 'Unknown', 'system-seconds' => '-2', 'reload-seconds' => '-2'); // If we can't connect to astman for some reason.. if (!$this->astman) { return $output; } $response = $this->astman->send_request('Command', array('Command' => "core show uptime seconds")); $astout = explode("\n", $response['data']); if (!class_exists('TimeUtils')) { include 'TimeUtils.class.php'; } // Second line: // System uptime: 922134 $words = explode(" ", $astout[1]); $output['system'] = TimeUtils::getReadable($words[2]); $output['system-seconds'] = $words[2]; // Third line: // Last reload: 4157 $words = explode(" ", $astout[2]); $output['reload'] = TimeUtils::getReadable($words[2]); $output['reload-seconds'] = $words[2]; return $output; }