2011-08-31 00:00:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Model_Systemstatus
|
|
|
|
{
|
|
|
|
|
2011-09-14 00:43:16 +02:00
|
|
|
public static function GetMonitStatus(){
|
|
|
|
|
|
|
|
$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);
|
2011-09-13 20:56:24 +02:00
|
|
|
|
2011-09-14 00:43:16 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2011-09-13 20:56:24 +02:00
|
|
|
|
2011-09-14 00:43:16 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetPypoStatus(){
|
|
|
|
$docRoot = self::GetMonitStatus();
|
|
|
|
$data = self::ExtractServiceInformation($docRoot, "airtime-playout");
|
|
|
|
|
2011-09-12 22:18:08 +02:00
|
|
|
return array(
|
2011-09-14 00:43:16 +02:00
|
|
|
"process_id"=>$data["pid"],
|
|
|
|
"uptime_seconds"=>$data["uptime"]
|
2011-09-12 22:18:08 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetLiquidsoapStatus(){
|
2011-09-14 00:43:16 +02:00
|
|
|
$docRoot = self::GetMonitStatus();
|
|
|
|
$data = self::ExtractServiceInformation($docRoot, "airtime-liquidsoap");
|
|
|
|
|
2011-09-12 22:18:08 +02:00
|
|
|
return array(
|
2011-09-14 00:43:16 +02:00
|
|
|
"process_id"=>$data["pid"],
|
|
|
|
"uptime_seconds"=>$data["uptime"]
|
2011-09-12 22:18:08 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetShowRecorderStatus(){
|
2011-09-14 00:43:16 +02:00
|
|
|
$docRoot = self::GetMonitStatus();
|
|
|
|
$data = self::ExtractServiceInformation($docRoot, "airtime-show-recorder");
|
|
|
|
|
2011-09-12 22:18:08 +02:00
|
|
|
return array(
|
2011-09-14 00:43:16 +02:00
|
|
|
"process_id"=>$data["pid"],
|
|
|
|
"uptime_seconds"=>$data["uptime"]
|
2011-09-12 22:18:08 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-14 00:43:16 +02:00
|
|
|
public static function GetMediaMonitorStatus(){
|
|
|
|
$docRoot = self::GetMonitStatus();
|
|
|
|
$data = self::ExtractServiceInformation($docRoot, "airtime-media-monitor");
|
|
|
|
|
2011-09-12 22:18:08 +02:00
|
|
|
return array(
|
2011-09-14 00:43:16 +02:00
|
|
|
"process_id"=>$data["pid"],
|
|
|
|
"uptime_seconds"=>$data["uptime"]
|
2011-09-12 22:18:08 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-09-14 00:43:16 +02:00
|
|
|
public static function GetIcecastStatus(){
|
|
|
|
$docRoot = self::GetMonitStatus();
|
|
|
|
$data = self::ExtractServiceInformation($docRoot, "icecast2");
|
|
|
|
|
2011-09-12 22:18:08 +02:00
|
|
|
return array(
|
2011-09-14 00:43:16 +02:00
|
|
|
"process_id"=>$data["pid"],
|
|
|
|
"uptime_seconds"=>$data["uptime"]
|
2011-09-12 22:18:08 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetAirtimeVersion(){
|
|
|
|
return AIRTIME_VERSION;
|
|
|
|
}
|
2011-09-14 00:43:16 +02:00
|
|
|
/*
|
2011-09-12 22:18:08 +02:00
|
|
|
|
|
|
|
|
2011-08-31 00:00:03 +02:00
|
|
|
private function getCheckSystemResults(){
|
2011-08-31 18:52:12 +02:00
|
|
|
//exec("airtime-check-system", $output);
|
2011-08-31 00:00:03 +02:00
|
|
|
|
2011-08-31 18:52:12 +02:00
|
|
|
require_once "/usr/lib/airtime/utils/airtime-check-system.php";
|
|
|
|
$arrs = AirtimeCheck::CheckAirtimeDaemons();
|
2011-08-31 00:00:03 +02:00
|
|
|
|
2011-08-31 18:52:12 +02:00
|
|
|
$status = array("AIRTIME_VERSION" => AIRTIME_VERSION);
|
|
|
|
foreach($arrs as $arr){
|
|
|
|
$status[$arr[0]] = $arr[1];
|
2011-08-31 00:00:03 +02:00
|
|
|
}
|
|
|
|
|
2011-08-31 18:52:12 +02:00
|
|
|
$storDir = MusicDir::getStorDir()->getDirectory();
|
|
|
|
|
|
|
|
$freeSpace = disk_free_space($storDir);
|
|
|
|
$totalSpace = disk_total_space($storDir);
|
|
|
|
|
|
|
|
$status["DISK_SPACE"] = sprintf("%01.3f%%", $freeSpace/$totalSpace*100);
|
|
|
|
|
2011-08-31 00:00:03 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-08-31 18:52:12 +02:00
|
|
|
$key = "DISK_SPACE";
|
|
|
|
$results[$key] = array("Disk Space Free: ", $keyValues[$key], false);
|
|
|
|
|
2011-08-31 00:00:03 +02:00
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function convertRunTimeToPassFail($runTime){
|
|
|
|
return $runTime > 3 ? "Pass" : "Fail";
|
|
|
|
}
|
2011-09-14 00:43:16 +02:00
|
|
|
|
|
|
|
*/
|
2011-08-31 00:00:03 +02:00
|
|
|
}
|