diff --git a/airtime_mvc/application/configs/ACL.php b/airtime_mvc/application/configs/ACL.php index 5fa4b7a05..72187e4e9 100644 --- a/airtime_mvc/application/configs/ACL.php +++ b/airtime_mvc/application/configs/ACL.php @@ -19,6 +19,7 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('api')) ->add(new Zend_Acl_Resource('nowplaying')) + ->add(new Zend_Acl_Resource('systemstatus')) ->add(new Zend_Acl_Resource('search')) ->add(new Zend_Acl_Resource('dashboard')) ->add(new Zend_Acl_Resource('preference')) @@ -40,6 +41,7 @@ $ccAcl->allow('G', 'index') ->allow('H', 'search') ->allow('H', 'playlist') ->allow('A', 'user') + ->allow('A', 'systemstatus') ->allow('A', 'preference'); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index a2af6d9fe..0aad75da0 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -75,10 +75,24 @@ $pages = array( ), array( 'label' => 'Help', - 'module' => 'default', - 'controller' => 'dashboard', - 'action' => 'help', - 'resource' => 'dashboard' + 'uri' => '#', + 'resource' => 'dashboard', + 'pages' => array( + array( + 'label' => 'About', + 'module' => 'default', + 'controller' => 'dashboard', + 'action' => 'help', + 'resource' => 'dashboard' + ), + array( + 'label' => 'System Status', + 'module' => 'default', + 'controller' => 'systemstatus', + 'action' => 'index', + 'resource' => 'systemstatus' + ) + ) ) ); diff --git a/airtime_mvc/application/controllers/SystemstatusController.php b/airtime_mvc/application/controllers/SystemstatusController.php new file mode 100644 index 000000000..7059fad0f --- /dev/null +++ b/airtime_mvc/application/controllers/SystemstatusController.php @@ -0,0 +1,49 @@ +view->status = $ss->getResults(); + } + + public function getLogFileAction() + { + $log_files = array("PLAYOUT_ENGINE_RUNNING_SECONDS"=>"/var/log/airtime/pypo/pypo.log", + "LIQUIDSOAP_RUNNING_SECONDS"=>"/var/log/airtime/pypo-liquidsoap/ls_script.log", + "MEDIA_MONITOR_RUNNING_SECONDS"=>"/var/log/airtime/media-monitor/media-monitor.log", + "SHOW_RECORDER_RUNNING_SECONDS"=>"/var/log/airtime/show-recorder/show-recorder.log"); + + $id = $this->_getParam('id'); + Logging::log($id); + + if (array_key_exists($id, $log_files)){ + $filepath = $log_files[$id]; + $filename = basename($filepath); + header("Content-Disposition: attachment; filename=$filename"); + header("Content-Length: " . filesize($filepath)); + // !! binary mode !! + $fp = fopen($filepath, 'rb'); + + //We can have multiple levels of output buffering. Need to + //keep looping until all have been disabled!!! + //http://www.php.net/manual/en/function.ob-end-flush.php + while (@ob_end_flush()); + + fpassthru($fp); + fclose($fp); + + //make sure to exit here so that no other output is sent. + exit; + } + } +} diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php new file mode 100644 index 000000000..116bfa5c8 --- /dev/null +++ b/airtime_mvc/application/models/Systemstatus.php @@ -0,0 +1,53 @@ + AIRTIME_VERSION); + foreach($arrs as $arr){ + $status[$arr[0]] = $arr[1]; + } + + $storDir = MusicDir::getStorDir()->getDirectory(); + + $freeSpace = disk_free_space($storDir); + $totalSpace = disk_total_space($storDir); + + $status["DISK_SPACE"] = sprintf("%01.3f%%", $freeSpace/$totalSpace*100); + + 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); + } + + $key = "DISK_SPACE"; + $results[$key] = array("Disk Space Free: ", $keyValues[$key], false); + + return $results; + } + + private function convertRunTimeToPassFail($runTime){ + return $runTime > 3 ? "Pass" : "Fail"; + } +} diff --git a/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml b/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/airtime_mvc/application/views/scripts/systemstatus/get-log-file.phtml @@ -0,0 +1 @@ + diff --git a/airtime_mvc/application/views/scripts/systemstatus/index.phtml b/airtime_mvc/application/views/scripts/systemstatus/index.phtml new file mode 100644 index 000000000..9b48f5c7f --- /dev/null +++ b/airtime_mvc/application/views/scripts/systemstatus/index.phtml @@ -0,0 +1,10 @@ +status as $key=>$value): ?> + +
+ + + + Log file + +
+ diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index 754e4c269..1119db3e0 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -359,6 +359,10 @@ class AirtimeInstall echo "* Installing airtime-user".PHP_EOL; $dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-user"; exec("ln -s $dir /usr/bin/airtime-user"); + + echo "* Installing airtime-log".PHP_EOL; + $dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log"; + exec("ln -s $dir /usr/bin/airtime-log"); } public static function RemoveSymlinks() @@ -366,6 +370,8 @@ class AirtimeInstall exec("rm -f /usr/bin/airtime-import"); exec("rm -f /usr/bin/airtime-update-db-settings"); exec("rm -f /usr/bin/airtime-check-system"); + exec("rm -f /usr/bin/airtime-user"); + exec("rm -f /usr/bin/airtime-log"); } public static function InstallPhpCode() diff --git a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php index 2f06e8d51..3bab0586f 100644 --- a/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-2.0.0/airtime-upgrade.php @@ -17,7 +17,8 @@ require_once 'propel/runtime/lib/Propel.php'; Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php"); class AirtimeInstall{ - + const CONF_DIR_BINARIES = "/usr/lib/airtime"; + public static function SetDefaultTimezone() { global $CC_DBC; @@ -32,6 +33,20 @@ class AirtimeInstall{ return true; } + public static function GetUtilsSrcDir() + { + return __DIR__."/../../../utils"; + } + + public static function CreateSymlinksToUtils() + { + echo "* Installing airtime-log".PHP_EOL; + $dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log"; + copy(AirtimeInstall::GetUtilsSrcDir()."/airtime-log.php", AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-log.php"); + + exec("ln -s $dir /usr/bin/airtime-log"); + } + public static function SetDefaultStreamSetting() { global $CC_DBC; @@ -386,6 +401,7 @@ class AirtimeIni200{ Airtime200Upgrade::connectToDatabase(); AirtimeInstall::SetDefaultTimezone(); +AirtimeInstall::CreateSymlinksToUtils(); /* Airtime 2.0.0 starts interpreting all database times in UTC format. Prior to this, all the times * were stored using the local time zone. Let's convert to UTC time. */ diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 27fd527a0..c9023de3e 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -1,52 +1,59 @@ "/var/log/airtime/media-monitor/media-monitor.log", "recorder" => "/var/log/airtime/show-recorder/show-recorder.log", "playout" => "/var/log/airtime/pypo/pypo.log", + "liquidsoap" => "/var/log/airtime/pypo-liquidsoap/ls_script.log", "web" => "/var/log/airtime/zendphp.log"); array_filter($log_files, "file_exists"); @@ -39,7 +43,7 @@ function viewSpecificLog($key){ function dumpAllLogs(){ $dateStr = gmdate("Y-m-d-H-i-s"); - $filename = __DIR__."/airtime-log-all-$dateStr.tgz"; + $filename = "/tmp/airtime-log-all-$dateStr.tgz"; echo "Creating Airtime logs tgz file at $filename"; $command = "tar cfz $filename /var/log/airtime 2>/dev/null"; exec($command); @@ -50,7 +54,7 @@ function dumpSpecificLog($key){ if (isKeyValid($key)){ $dateStr = gmdate("Y-m-d-H-i-s"); - $filename = __DIR__."/airtime-log-$key-$dateStr.tgz"; + $filename = "/tmp/airtime-log-$key-$dateStr.tgz"; echo "Creating Airtime logs tgz file at $filename"; $dir = dirname($log_files[$key]); $command = "tar cfz $filename $dir 2>/dev/null"; @@ -75,6 +79,18 @@ function tailSpecificLog($key){ } else printUsage(); } +function getAirtimeConf() +{ + $ini = parse_ini_file("/etc/airtime/airtime.conf", true); + + if ($ini === false){ + echo "Error reading /etc/airtime/airtime.conf.".PHP_EOL; + exit; + } + + return $ini; +} + try { $keys = implode("|", array_keys($log_files)); $opts = new Zend_Console_Getopt( @@ -113,6 +129,9 @@ if (isset($opts->v)){ } else { tailSpecificLog($opts->t); } +} else { + printUsage(); + exit; } echo PHP_EOL;