Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2011-08-31 16:28:40 -04:00
commit ed5b7bca5f
10 changed files with 286 additions and 74 deletions

View file

@ -19,6 +19,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
->add(new Zend_Acl_Resource('schedule'))
->add(new Zend_Acl_Resource('api'))
->add(new Zend_Acl_Resource('nowplaying'))
->add(new Zend_Acl_Resource('systemstatus'))
->add(new Zend_Acl_Resource('search'))
->add(new Zend_Acl_Resource('dashboard'))
->add(new Zend_Acl_Resource('preference'))
@ -40,6 +41,7 @@ $ccAcl->allow('G', 'index')
->allow('H', 'search')
->allow('H', 'playlist')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);

View file

@ -75,10 +75,24 @@ $pages = array(
),
array(
'label' => 'Help',
'module' => 'default',
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard'
'uri' => '#',
'resource' => 'dashboard',
'pages' => array(
array(
'label' => 'About',
'module' => 'default',
'controller' => 'dashboard',
'action' => 'help',
'resource' => 'dashboard'
),
array(
'label' => 'System Status',
'module' => 'default',
'controller' => 'systemstatus',
'action' => 'index',
'resource' => 'systemstatus'
)
)
)
);

View file

@ -0,0 +1,49 @@
<?php
class SystemstatusController extends Zend_Controller_Action
{
public function init()
{
}
public function indexAction()
{
$ss = new Application_Model_Systemstatus();
$stats = array("Total R");
$this->view->status = $ss->getResults();
}
public function getLogFileAction()
{
$log_files = array("PLAYOUT_ENGINE_RUNNING_SECONDS"=>"/var/log/airtime/pypo/pypo.log",
"LIQUIDSOAP_RUNNING_SECONDS"=>"/var/log/airtime/pypo-liquidsoap/ls_script.log",
"MEDIA_MONITOR_RUNNING_SECONDS"=>"/var/log/airtime/media-monitor/media-monitor.log",
"SHOW_RECORDER_RUNNING_SECONDS"=>"/var/log/airtime/show-recorder/show-recorder.log");
$id = $this->_getParam('id');
Logging::log($id);
if (array_key_exists($id, $log_files)){
$filepath = $log_files[$id];
$filename = basename($filepath);
header("Content-Disposition: attachment; filename=$filename");
header("Content-Length: " . filesize($filepath));
// !! binary mode !!
$fp = fopen($filepath, 'rb');
//We can have multiple levels of output buffering. Need to
//keep looping until all have been disabled!!!
//http://www.php.net/manual/en/function.ob-end-flush.php
while (@ob_end_flush());
fpassthru($fp);
fclose($fp);
//make sure to exit here so that no other output is sent.
exit;
}
}
}

View file

@ -0,0 +1,53 @@
<?php
class Application_Model_Systemstatus
{
private function getCheckSystemResults(){
//exec("airtime-check-system", $output);
require_once "/usr/lib/airtime/utils/airtime-check-system.php";
$arrs = AirtimeCheck::CheckAirtimeDaemons();
$status = array("AIRTIME_VERSION" => AIRTIME_VERSION);
foreach($arrs as $arr){
$status[$arr[0]] = $arr[1];
}
$storDir = MusicDir::getStorDir()->getDirectory();
$freeSpace = disk_free_space($storDir);
$totalSpace = disk_total_space($storDir);
$status["DISK_SPACE"] = sprintf("%01.3f%%", $freeSpace/$totalSpace*100);
return $status;
}
public function getResults(){
$keyValues = $this->getCheckSystemResults();
$results = array();
$key = "AIRTIME_VERSION";
$results[$key] = array("Airtime Version", $keyValues[$key], false);
$triplets = array(array("PLAYOUT_ENGINE_RUNNING_SECONDS", "Playout Engine Status", true),
array("LIQUIDSOAP_RUNNING_SECONDS", "Liquidsoap Status", true),
array("MEDIA_MONITOR_RUNNING_SECONDS", "Media-Monitor Status", true),
array("SHOW_RECORDER_RUNNING_SECONDS", "Show-Recorder Status", true));
foreach($triplets as $triple){
list($key, $desc, $downloadLog) = $triple;
$results[$key] = array($desc, $this->convertRunTimeToPassFail($keyValues[$key]), $downloadLog);
}
$key = "DISK_SPACE";
$results[$key] = array("Disk Space Free: ", $keyValues[$key], false);
return $results;
}
private function convertRunTimeToPassFail($runTime){
return $runTime > 3 ? "Pass" : "Fail";
}
}

View file

@ -0,0 +1,10 @@
<?php foreach($this->status as $key=>$value): ?>
<?php list($desc, $status, $downloadLog) = $value;?>
<div>
<?php echo $desc; ?>
<?php echo $status; ?>
<?php if ($downloadLog): ?>
<a href="systemstatus/get-log-file/id/<?php echo $key ?>">Log file</a>
<?php endif; ?>
</div>
<?php endforeach; ?>