CC-2750: Ability to query health status for pypo, liquidsoap, media monitor, and recorder

This commit is contained in:
martin 2011-09-19 15:46:15 -04:00
parent 5a5430f468
commit a11dba1469
3 changed files with 56 additions and 46 deletions

View file

@ -22,7 +22,6 @@ class Application_Model_Systemstatus
public static function ExtractServiceInformation($p_docRoot, $p_serviceName){ public static function ExtractServiceInformation($p_docRoot, $p_serviceName){
$data = array();
$starting = array("process_id"=>"STARTING...", $starting = array("process_id"=>"STARTING...",
"uptime_seconds"=>"STARTING...", "uptime_seconds"=>"STARTING...",
"memory_perc"=>"UNKNOWN", "memory_perc"=>"UNKNOWN",
@ -35,64 +34,66 @@ class Application_Model_Systemstatus
"memory_kb"=>"UNKNOWN", "memory_kb"=>"UNKNOWN",
"cpu_perc"=>"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) $monitor = $item->getElementsByTagName("monitor");
{ if ($monitor->length > 0){
if ($item->getElementsByTagName("name")->item(0)->nodeValue == $p_serviceName){ $status = $monitor->item(0)->nodeValue;
if ($status == "2"){
$monitor = $item->getElementsByTagName("monitor"); $data = $starting;
if ($monitor->length > 0){ } else if ($status == 0){
$status = $monitor->item(0)->nodeValue; $data = $notRunning;
if ($status == "2"){ }
$data = $starting;
} else if ($status == 0){
$data = $notRunning;
} }
}
$process_id = $item->getElementsByTagName("pid"); $process_id = $item->getElementsByTagName("pid");
if ($process_id->length > 0){ if ($process_id->length > 0){
$data["process_id"] = $process_id->item(0)->nodeValue; $data["process_id"] = $process_id->item(0)->nodeValue;
} }
$uptime = $item->getElementsByTagName("uptime"); $uptime = $item->getElementsByTagName("uptime");
if ($uptime->length > 0){ if ($uptime->length > 0){
$data["uptime_seconds"] = $uptime->item(0)->nodeValue; $data["uptime_seconds"] = $uptime->item(0)->nodeValue;
} }
$memory = $item->getElementsByTagName("memory"); $memory = $item->getElementsByTagName("memory");
if ($memory->length > 0){ if ($memory->length > 0){
$data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%"; $data["memory_perc"] = $memory->item(0)->getElementsByTagName("percenttotal")->item(0)->nodeValue."%";
$data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue; $data["memory_kb"] = $memory->item(0)->getElementsByTagName("kilobytetotal")->item(0)->nodeValue;
} }
$cpu = $item->getElementsByTagName("cpu"); $cpu = $item->getElementsByTagName("cpu");
if ($cpu->length > 0){ if ($cpu->length > 0){
$data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%"; $data["cpu_perc"] = $cpu->item(0)->getElementsByTagName("percent")->item(0)->nodeValue."%";
}
break;
} }
break;
} }
} }
return $data; return $data;
} }
public static function GetPlatformInfo(){ public static function GetPlatformInfo(){
$docRoot = self::GetMonitStatus("localhost");
$data = array("release"=>"UNKNOWN", $data = array("release"=>"UNKNOWN",
"machine"=>"UNKNOWN", "machine"=>"UNKNOWN",
"memory"=>"UNKNOWN", "memory"=>"UNKNOWN",
"swap"=>"UNKNOWN"); "swap"=>"UNKNOWN");
foreach ($docRoot->getElementsByTagName("platform") AS $item) $docRoot = self::GetMonitStatus("localhost");
{ if (!is_null($docRoot)){
$data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue; foreach ($docRoot->getElementsByTagName("platform") AS $item)
$data["machine"] = $item->getElementsByTagName("machine")->item(0)->nodeValue; {
$data["memory"] = $item->getElementsByTagName("memory")->item(0)->nodeValue; $data["release"] = $item->getElementsByTagName("release")->item(0)->nodeValue;
$data["swap"] = $item->getElementsByTagName("swap")->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; return $data;

View file

@ -37,6 +37,15 @@ elif [ "$result" -ne "0" ]; then
fi fi
set -e 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 ***" echo -e "\n*** API Client Installation ***"
python ${SCRIPTPATH}/../python_apps/api_clients/install/api_client_install.py 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 ***" echo -e "\n*** Media Monitor Installation ***"
python ${SCRIPTPATH}/../python_apps/media-monitor/install/media-monitor-install.py python ${SCRIPTPATH}/../python_apps/media-monitor/install/media-monitor-install.py
monit monitor icecast2 >/dev/null 2>&1 monit monitor icecast2
monit monitor rabbitmq-server >/dev/null 2>&1 monit monitor rabbitmq-server
echo -e "\n*** Verifying your system environment ***" echo -e "\n*** Verifying your system environment ***"
sleep 5 sleep 10
airtime-check-system airtime-check-system
echo -e "\n******************************* Install Complete *******************************" echo -e "\n******************************* Install Complete *******************************"

View file

@ -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 syslog facility log_daemon
set logfile /var/log/monit.log set logfile /var/log/monit.log