CC-2750: Ability to query health status for pypo, liquidsoap, media monitor, and recorder
This commit is contained in:
parent
5a5430f468
commit
a11dba1469
3 changed files with 56 additions and 46 deletions
|
@ -22,7 +22,6 @@ class Application_Model_Systemstatus
|
|||
|
||||
public static function ExtractServiceInformation($p_docRoot, $p_serviceName){
|
||||
|
||||
$data = array();
|
||||
$starting = array("process_id"=>"STARTING...",
|
||||
"uptime_seconds"=>"STARTING...",
|
||||
"memory_perc"=>"UNKNOWN",
|
||||
|
@ -35,64 +34,66 @@ class Application_Model_Systemstatus
|
|||
"memory_kb"=>"UNKNOWN",
|
||||
"cpu_perc"=>"UNKNOWN"
|
||||
);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
$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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue