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

This commit is contained in:
James 2011-09-14 16:00:17 -04:00
commit e2ebda6351
6 changed files with 87 additions and 36 deletions

View File

@ -653,8 +653,8 @@ class ApiController extends Zend_Controller_Action
*/ */
$status = array( $status = array(
"airtime_version"=>Application_Model_Systemstatus::GetAirtimeVersion(), //"airtime_version"=>Application_Model_Systemstatus::GetAirtimeVersion(),
"icecast"=>Application_Model_Systemstatus::GetIcecastStatus(), "icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(),
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(), "pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(), "liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
"show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(), "show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),

View File

@ -9,19 +9,24 @@ class SystemstatusController extends Zend_Controller_Action
public function indexAction() public function indexAction()
{ {
$ss = new Application_Model_Systemstatus(); $status = array(
"icecast2"=>Application_Model_Systemstatus::GetIcecastStatus(),
$stats = array("Total R"); "pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),
"show-recorder"=>Application_Model_Systemstatus::GetShowRecorderStatus(),
"media-monitor"=>Application_Model_Systemstatus::GetMediaMonitorStatus()
);
$this->view->status = $ss->getResults(); $this->view->status = $status;
} }
public function getLogFileAction() public function getLogFileAction()
{ {
$log_files = array("PLAYOUT_ENGINE_RUNNING_SECONDS"=>"/var/log/airtime/pypo/pypo.log", $log_files = array("pypo"=>"/var/log/airtime/pypo/pypo.log",
"LIQUIDSOAP_RUNNING_SECONDS"=>"/var/log/airtime/pypo-liquidsoap/ls_script.log", "liquidsoap"=>"/var/log/airtime/pypo-liquidsoap/ls_script.log",
"MEDIA_MONITOR_RUNNING_SECONDS"=>"/var/log/airtime/media-monitor/media-monitor.log", "media-monitor"=>"/var/log/airtime/media-monitor/media-monitor.log",
"SHOW_RECORDER_RUNNING_SECONDS"=>"/var/log/airtime/show-recorder/show-recorder.log"); "show-recorder"=>"/var/log/airtime/show-recorder/show-recorder.log",
"icecast2"=>"/var/log/icecast2/error.log");
$id = $this->_getParam('id'); $id = $this->_getParam('id');
Logging::log($id); Logging::log($id);

View File

@ -3,48 +3,93 @@
class Application_Model_Systemstatus class Application_Model_Systemstatus
{ {
public static function GetPypoStatus(){ public static function GetMonitStatus(){
RabbitMq::SendMessageToPypo("get_status", array()); $url = "http://localhost:2812/_status?format=xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "admin:monit");
$result = curl_exec($ch);
curl_close($ch);
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($result);
return $xmlDoc->documentElement;
}
public static function ExtractServiceInformation($p_docRoot, $p_serviceName){
$data = array("pid"=>"UNKNOWN",
"uptime"=>"UNKNOWN");
foreach ($p_docRoot->getElementsByTagName("service") AS $item)
{
if ($item->getElementsByTagName("name")->item(0)->nodeValue == $p_serviceName){
$data["pid"] = $item->getElementsByTagName("pid")->item(0)->nodeValue;
$data["uptime"] = $item->getElementsByTagName("uptime")->item(0)->nodeValue."s";
break;
}
}
return $data;
}
public static function GetPypoStatus(){
$docRoot = self::GetMonitStatus();
$data = self::ExtractServiceInformation($docRoot, "airtime-playout");
return array( return array(
"process_id"=>500, "process_id"=>$data["pid"],
"uptime_seconds"=>3600 "uptime_seconds"=>$data["uptime"]
); );
} }
public static function GetLiquidsoapStatus(){ public static function GetLiquidsoapStatus(){
$docRoot = self::GetMonitStatus();
$data = self::ExtractServiceInformation($docRoot, "airtime-liquidsoap");
return array( return array(
"process_id"=>500, "process_id"=>$data["pid"],
"uptime_seconds"=>3600 "uptime_seconds"=>$data["uptime"]
); );
} }
public static function GetShowRecorderStatus(){ public static function GetShowRecorderStatus(){
$docRoot = self::GetMonitStatus();
$data = self::ExtractServiceInformation($docRoot, "airtime-show-recorder");
return array( return array(
"process_id"=>500, "process_id"=>$data["pid"],
"uptime_seconds"=>3600 "uptime_seconds"=>$data["uptime"]
); );
} }
public static function GetMediaMonitorStatus(){ public static function GetMediaMonitorStatus(){
$docRoot = self::GetMonitStatus();
$data = self::ExtractServiceInformation($docRoot, "airtime-media-monitor");
return array( return array(
"process_id"=>500, "process_id"=>$data["pid"],
"uptime_seconds"=>3600 "uptime_seconds"=>$data["uptime"]
); );
} }
public static function GetIcecastStatus(){ public static function GetIcecastStatus(){
$docRoot = self::GetMonitStatus();
$data = self::ExtractServiceInformation($docRoot, "icecast2");
return array( return array(
"process_id"=>500, "process_id"=>$data["pid"],
"uptime_seconds"=>3600 "uptime_seconds"=>$data["uptime"]
); );
} }
public static function GetAirtimeVersion(){ public static function GetAirtimeVersion(){
return AIRTIME_VERSION; return AIRTIME_VERSION;
} }
/*
private function getCheckSystemResults(){ private function getCheckSystemResults(){
@ -94,4 +139,6 @@ class Application_Model_Systemstatus
private function convertRunTimeToPassFail($runTime){ private function convertRunTimeToPassFail($runTime){
return $runTime > 3 ? "Pass" : "Fail"; return $runTime > 3 ? "Pass" : "Fail";
} }
*/
} }

View File

@ -1,9 +1,10 @@
<?php foreach($this->status as $key=>$value): ?> <?php foreach($this->status as $key=>$value): ?>
<?php list($desc, $status, $downloadLog) = $value;?>
<div> <div>
<?php echo $desc; ?> <?php echo $key; ?>
<?php echo $status; ?> <?php echo "PID: ".$value["process_id"]; ?>
<?php if ($downloadLog): ?> <?php echo "UPTIME: ".$value["uptime_seconds"]; ?>
<?php if (true): ?>
<a href="systemstatus/get-log-file/id/<?php echo $key ?>">Log file</a> <a href="systemstatus/get-log-file/id/<?php echo $key ?>">Log file</a>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@ -22,3 +22,7 @@
with pidfile "/var/run/airtime-show-recorder.pid" with pidfile "/var/run/airtime-show-recorder.pid"
start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-show-recorder stop" stop program = "/etc/init.d/airtime-show-recorder stop"
check process icecast2
matching "/usr/bin/icecast2"
start program = "/etc/init.d/icecast2 start" with timeout 10 seconds
stop program = "/etc/init.d/icecast2 stop"

View File

@ -90,8 +90,6 @@ class PypoFetch(Thread):
elif command == 'cancel_current_show': elif command == 'cancel_current_show':
logger.info("Cancel current show command received...") logger.info("Cancel current show command received...")
self.stop_current_show() self.stop_current_show()
elif command == 'get_status':
self.get_status()
except Exception, e: except Exception, e:
logger.error("Exception in handling RabbitMQ message: %s", e) logger.error("Exception in handling RabbitMQ message: %s", e)
finally: finally:
@ -99,11 +97,7 @@ class PypoFetch(Thread):
try: try:
message.ack() message.ack()
except MessageStateError, m: except MessageStateError, m:
logger.error("Message ACK error: %s", m); logger.error("Message ACK error: %s", m)
def get_status(self):
logger = logging.getLogger('fetch')
logger.debug("get_status")
def stop_current_show(self): def stop_current_show(self):
logger = logging.getLogger('fetch') logger = logging.getLogger('fetch')