Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
b3654c62bc
22 changed files with 524 additions and 152 deletions
|
@ -656,12 +656,15 @@ class ApiController extends Zend_Controller_Action
|
|||
$status = array(
|
||||
"platform"=>Application_Model_Systemstatus::GetPlatformInfo(),
|
||||
"airtime_version"=>Application_Model_Systemstatus::GetAirtimeVersion(),
|
||||
"icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(),
|
||||
"rabbitmq"=>Application_Model_Systemstatus::GetRabbitMqStatus(),
|
||||
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
|
||||
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
|
||||
"show_recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),
|
||||
"media_monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus()
|
||||
"services"=>array(
|
||||
"icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(),
|
||||
"rabbitmq"=>Application_Model_Systemstatus::GetRabbitMqStatus(),
|
||||
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
|
||||
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
|
||||
"show_recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),
|
||||
"media_monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus()
|
||||
),
|
||||
"partitions"=>Application_Model_Systemstatus::GetDiskInfo()
|
||||
);
|
||||
|
||||
$this->view->status = $status;
|
||||
|
|
|
@ -4,20 +4,30 @@ class SystemstatusController extends Zend_Controller_Action
|
|||
{
|
||||
public function init()
|
||||
{
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/status/status.js','text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/sprintf/sprintf-0.7-beta1.js','text/javascript');
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$status = array(
|
||||
"icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(),
|
||||
$services = array(
|
||||
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
|
||||
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
|
||||
"show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),
|
||||
"media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus()
|
||||
"media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus(),
|
||||
"rabbitmq-server"=>Application_Model_Systemstatus::GetRabbitMqStatus(),
|
||||
"icecast2"=>Application_Model_Systemstatus::GetIcecastStatus()
|
||||
);
|
||||
|
||||
$partitions = Application_Model_Systemstatus::GetDiskInfo();
|
||||
|
||||
$this->view->status = $status;
|
||||
$this->view->status = new StdClass;
|
||||
$this->view->status->services = $services;
|
||||
$this->view->status->partitions = $partitions;
|
||||
|
||||
}
|
||||
|
||||
public function getLogFileAction()
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
</div>
|
||||
|
||||
<div class="wrapper">
|
||||
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded"><?php echo $this->layout()->library ?></div>
|
||||
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
|
||||
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow omega-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
|
||||
<div id="side_playlist" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->spl ?></div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -222,8 +222,7 @@ class MusicDir {
|
|||
->find();
|
||||
|
||||
foreach($dirs as $dir) {
|
||||
$tmp = new MusicDir($dir);
|
||||
$result[] = $tmp;
|
||||
$result[] = new MusicDir($dir);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -14,85 +14,102 @@ class Application_Model_Systemstatus
|
|||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$xmlDoc = new DOMDocument();
|
||||
$xmlDoc->loadXML($result);
|
||||
$docRoot = null;
|
||||
if ($result != ""){
|
||||
$xmlDoc = new DOMDocument();
|
||||
$xmlDoc->loadXML($result);
|
||||
$docRoot = $xmlDoc->documentElement;
|
||||
}
|
||||
|
||||
return $xmlDoc->documentElement;
|
||||
return $docRoot;
|
||||
}
|
||||
|
||||
public static function ExtractServiceInformation($p_docRoot, $p_serviceName){
|
||||
|
||||
$data = array();
|
||||
$starting = array("process_id"=>"STARTING...",
|
||||
"uptime_seconds"=>"STARTING...",
|
||||
"memory_perc"=>"UNKNOWN",
|
||||
"memory_kb"=>"UNKNOWN",
|
||||
"cpu_perc"=>"UNKNOWN");
|
||||
$starting = array(
|
||||
"name"=>"",
|
||||
"process_id"=>"STARTING...",
|
||||
"uptime_seconds"=>"-1",
|
||||
"status"=>true,
|
||||
"memory_perc"=>"0%",
|
||||
"memory_kb"=>"0",
|
||||
"cpu_perc"=>"0%");
|
||||
|
||||
$notRunning = array("process_id"=>"FAILED",
|
||||
"uptime_seconds"=>"FAILED",
|
||||
"memory_perc"=>"UNKNOWN",
|
||||
"memory_kb"=>"UNKNOWN",
|
||||
"cpu_perc"=>"UNKNOWN"
|
||||
$notRunning = array(
|
||||
"name"=>$p_serviceName,
|
||||
"process_id"=>"FAILED",
|
||||
"uptime_seconds"=>"-1",
|
||||
"status"=>false,
|
||||
"memory_perc"=>"0%",
|
||||
"memory_kb"=>"0",
|
||||
"cpu_perc"=>"0%"
|
||||
);
|
||||
$data = $notRunning;
|
||||
|
||||
|
||||
if (!is_null($p_docRoot)){
|
||||
foreach ($p_docRoot->getElementsByTagName("service") AS $item)
|
||||
{
|
||||
if ($item->getElementsByTagName("name")->item(0)->nodeValue == $p_serviceName){
|
||||
|
||||
foreach ($p_docRoot->getElementsByTagName("service") AS $item)
|
||||
{
|
||||
if ($item->getElementsByTagName("name")->item(0)->nodeValue == $p_serviceName){
|
||||
|
||||
$monitor = $item->getElementsByTagName("monitor");
|
||||
if ($monitor->length > 0){
|
||||
$status = $monitor->item(0)->nodeValue;
|
||||
if ($status == "2"){
|
||||
$data = $starting;
|
||||
} else if ($status == 0){
|
||||
$data = $notRunning;
|
||||
$monitor = $item->getElementsByTagName("monitor");
|
||||
if ($monitor->length > 0){
|
||||
$status = $monitor->item(0)->nodeValue;
|
||||
if ($status == "2"){
|
||||
$data = $starting;
|
||||
} else if ($status == 0){
|
||||
$data = $notRunning;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$process_id = $item->getElementsByTagName("pid");
|
||||
if ($process_id->length > 0){
|
||||
$data["process_id"] = $process_id->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$uptime = $item->getElementsByTagName("uptime");
|
||||
if ($uptime->length > 0){
|
||||
$data["uptime_seconds"] = $uptime->item(0)->nodeValue;
|
||||
$process_id = $item->getElementsByTagName("name");
|
||||
if ($process_id->length > 0){
|
||||
$data["name"] = $process_id->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$process_id = $item->getElementsByTagName("pid");
|
||||
if ($process_id->length > 0){
|
||||
$data["process_id"] = $process_id->item(0)->nodeValue;
|
||||
$data["status"] = true;
|
||||
}
|
||||
|
||||
$uptime = $item->getElementsByTagName("uptime");
|
||||
if ($uptime->length > 0){
|
||||
$data["uptime_seconds"] = $uptime->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$memory = $item->getElementsByTagName("memory");
|
||||
if ($memory->length > 0){
|
||||
$data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%";
|
||||
$data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$cpu = $item->getElementsByTagName("cpu");
|
||||
if ($cpu->length > 0){
|
||||
$data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$memory = $item->getElementsByTagName("memory");
|
||||
if ($memory->length > 0){
|
||||
$data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%";
|
||||
$data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$cpu = $item->getElementsByTagName("cpu");
|
||||
if ($cpu->length > 0){
|
||||
$data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function GetPlatformInfo(){
|
||||
$docRoot = self::GetMonitStatus("localhost");
|
||||
|
||||
$data = array("release"=>"UNKNOWN",
|
||||
"machine"=>"UNKNOWN",
|
||||
"memory"=>"UNKNOWN",
|
||||
"swap"=>"UNKNOWN");
|
||||
|
||||
foreach ($docRoot->getElementsByTagName("platform") AS $item)
|
||||
{
|
||||
$data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue;
|
||||
$data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue;
|
||||
$data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue;
|
||||
$data["swap"] = $item->getElementsByTagName("swap")->item(0)->nodeValue;
|
||||
$docRoot = self::GetMonitStatus("localhost");
|
||||
if (!is_null($docRoot)){
|
||||
foreach ($docRoot->getElementsByTagName("platform") AS $item)
|
||||
{
|
||||
$data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue;
|
||||
$data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue;
|
||||
$data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue;
|
||||
$data["swap"] = $item->getElementsByTagName("swap")->item(0)->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -161,6 +178,32 @@ class Application_Model_Systemstatus
|
|||
public static function GetAirtimeVersion(){
|
||||
return AIRTIME_VERSION;
|
||||
}
|
||||
|
||||
public static function GetDiskInfo(){
|
||||
/* First lets get all the watched directories. Then we can group them
|
||||
* into the same paritions by comparing the partition sizes. */
|
||||
$musicDirs = MusicDir::getWatchedDirs();
|
||||
$musicDirs[] = MusicDir::getStorDir();
|
||||
|
||||
|
||||
$partions = array();
|
||||
|
||||
foreach($musicDirs as $md){
|
||||
$totalSpace = disk_total_space($md->getDirectory());
|
||||
|
||||
if (!isset($partitions[$totalSpace])){
|
||||
$partitions[$totalSpace] = new StdClass;
|
||||
$partitions[$totalSpace]->totalSpace = $totalSpace;
|
||||
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
|
||||
}
|
||||
|
||||
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
|
||||
}
|
||||
|
||||
return array_values($partitions);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,33 @@
|
|||
<?php foreach($this->status as $key=>$value): ?>
|
||||
<div>
|
||||
<?php echo $key; ?>
|
||||
<?php echo "PID: ".$value["process_id"]; ?>
|
||||
<?php echo "UPTIME: ".$value["uptime_seconds"]; ?>
|
||||
|
||||
<?php if (true): ?>
|
||||
<a href="systemstatus/get-log-file/id/<?php echo $key ?>">Log file</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<table width="60%" cellpadding="0" cellspacing="0" border="0" class="statustable">
|
||||
<thead>
|
||||
<tr class="ui-state-default strong">
|
||||
<td>Service</td>
|
||||
<td>Status</td>
|
||||
<td>Uptime</td>
|
||||
<td>CPU</td>
|
||||
<td>Memory</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!--
|
||||
<tr class="odd">
|
||||
<td>Airtime Version</td>
|
||||
<td>1.9.3</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
-->
|
||||
<?php $i=0; ?>
|
||||
<?php foreach($this->status->services as $key=>$value): ?>
|
||||
<tr class="<?php echo ($i&1) == 0 ? "even":"odd"; $i++; ?>" id="<?php echo $value["name"]; ?>">
|
||||
<td><?php echo $value["name"]; ?></td>
|
||||
<td><span></span></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr id="partitions" class="even">
|
||||
<th colspan="5">Disk Space</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue