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;
|
||||
|
|
|
@ -37,6 +37,15 @@ elif [ "$result" -ne "0" ]; then
|
|||
fi
|
||||
set -e
|
||||
|
||||
# Need to ensure monit is running before Airtime daemons are run. This is
|
||||
# so we can ensure they can register with monit to monitor them when they start.
|
||||
/etc/init.d/monit start
|
||||
|
||||
# We may have updated the monit config files, and monit was already running.
|
||||
# In this case the previous "start" command didn't do anything, and we need
|
||||
# to reload the config files instead.
|
||||
/etc/init.d/monit force-reload
|
||||
|
||||
echo -e "\n*** API Client Installation ***"
|
||||
python ${SCRIPTPATH}/../python_apps/api_clients/install/api_client_install.py
|
||||
|
||||
|
@ -49,11 +58,11 @@ python ${SCRIPTPATH}/../python_apps/show-recorder/install/recorder-install.py
|
|||
echo -e "\n*** Media Monitor Installation ***"
|
||||
python ${SCRIPTPATH}/../python_apps/media-monitor/install/media-monitor-install.py
|
||||
|
||||
monit monitor icecast2 >/dev/null 2>&1
|
||||
monit monitor rabbitmq-server >/dev/null 2>&1
|
||||
monit monitor icecast2
|
||||
monit monitor rabbitmq-server
|
||||
|
||||
echo -e "\n*** Verifying your system environment ***"
|
||||
sleep 5
|
||||
sleep 10
|
||||
airtime-check-system
|
||||
|
||||
echo -e "\n******************************* Install Complete *******************************"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
set daemon 10 # Poll at 10 second intervals
|
||||
set daemon 10 # Poll at 5 second intervals
|
||||
#set logfile syslog facility log_daemon
|
||||
set logfile /var/log/monit.log
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue