CC-2363: Diagnostic screen in Web UI

-everything working
This commit is contained in:
martin 2011-09-22 10:45:43 -04:00
parent 3a2eaecad8
commit 046f98db8f
9 changed files with 345 additions and 102 deletions

View file

@ -657,13 +657,14 @@ class ApiController extends Zend_Controller_Action
"platform"=>Application_Model_Systemstatus::GetPlatformInfo(),
"airtime_version"=>Application_Model_Systemstatus::GetAirtimeVersion(),
"services"=>array(
Application_Model_Systemstatus::GetIcecastStatus(),
Application_Model_Systemstatus::GetRabbitMqStatus(),
Application_Model_Systemstatus::GetPypoStatus(),
Application_Model_Systemstatus::GetLiquidsoapStatus(),
Application_Model_Systemstatus::GetShowRecorderStatus(),
Application_Model_Systemstatus::GetMediaMonitorStatus()
)
"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;

View file

@ -8,11 +8,12 @@ class SystemstatusController extends Zend_Controller_Action
$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(
$services = array(
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
"show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),
@ -20,8 +21,13 @@ class SystemstatusController extends Zend_Controller_Action
"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()

View file

@ -222,8 +222,7 @@ class MusicDir {
->find();
foreach($dirs as $dir) {
$tmp = new MusicDir($dir);
$result[] = $tmp;
$result[] = new MusicDir($dir);
}
return $result;

View file

@ -14,10 +14,14 @@ 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){
@ -25,20 +29,20 @@ class Application_Model_Systemstatus
$starting = array(
"name"=>"",
"process_id"=>"STARTING...",
"uptime_seconds"=>"STARTING...",
"uptime_seconds"=>"-1",
"status"=>true,
"memory_perc"=>"UNKNOWN",
"memory_kb"=>"UNKNOWN",
"cpu_perc"=>"UNKNOWN");
"memory_perc"=>"0%",
"memory_kb"=>"0",
"cpu_perc"=>"0%");
$notRunning = array(
"name"=>"",
"name"=>$p_serviceName,
"process_id"=>"FAILED",
"uptime_seconds"=>"FAILED",
"uptime_seconds"=>"-1",
"status"=>false,
"memory_perc"=>"UNKNOWN",
"memory_kb"=>"UNKNOWN",
"cpu_perc"=>"UNKNOWN"
"memory_perc"=>"0%",
"memory_kb"=>"0",
"cpu_perc"=>"0%"
);
$data = $notRunning;
@ -174,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);
}
/*

View file

@ -1,23 +1,11 @@
<!--
<?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>
@ -29,46 +17,17 @@
</tr>
-->
<?php $i=0; ?>
<?php foreach($this->status as $key=>$value): ?>
<?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 class="<?php echo $value["status"] ? "checked-icon" : "not-available-icon" ?>">&nbsp;</span></td>
<td><?php echo $value["uptime_seconds"]; ?></td>
<td><span></span></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php endforeach; ?>
<tr class="even">
<th colspan="3">Disk Space</th>
</tr>
<tr>
<td><span class="strong">Disk #1</span> (/dev/sda)
<ul>
<li>/home/bob</li>
<li>/srv/airtime/stor</li>
</ul>
</td>
<td>12GB of 128GB</td>
<td>
<div class="big">
<div class="diskspace" style="width:10%;">
</div>
</div>
<div>10% in use</div>
</td>
</tr>
<tr>
<td><span class="strong">Disk #2</span> (/dev/sdb)
<ul>
<li>/home/external/audio</li>
</ul>
</td>
<td>90GB of 450GB</td>
<td>
<div class="big">
<div class="diskspace" style="width:20%;">
</div>
</div>
<div>20% in use</div>
</td>
<tr id="partitions" class="even">
<th colspan="5">Disk Space</th>
</tr>
</tbody>
</table>