2014-04-01 11:48:44 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-04-01 11:48:44 +02:00
|
|
|
|
|
|
|
use Icinga\Module\Monitoring\Controller;
|
|
|
|
use Icinga\Web\Url;
|
2014-10-31 10:27:17 +01:00
|
|
|
use Icinga\Application\Logger;
|
2014-11-18 13:11:52 +01:00
|
|
|
use Icinga\Data\ConfigObject;
|
2014-09-04 15:29:11 +02:00
|
|
|
use Icinga\Protocol\File\FileReader;
|
2014-09-05 15:28:39 +02:00
|
|
|
use \Zend_Controller_Action_Exception as ActionError;
|
2014-04-01 11:48:44 +02:00
|
|
|
|
2014-04-02 13:23:18 +02:00
|
|
|
/**
|
|
|
|
* Class ListController
|
|
|
|
*
|
|
|
|
* Application wide controller for various listing actions
|
|
|
|
*/
|
2014-04-01 11:48:44 +02:00
|
|
|
class ListController extends Controller
|
|
|
|
{
|
2014-04-02 13:23:18 +02:00
|
|
|
/**
|
|
|
|
* Add title tab
|
|
|
|
*
|
|
|
|
* @param string $action
|
|
|
|
*/
|
2014-04-01 11:48:44 +02:00
|
|
|
protected function addTitleTab($action)
|
|
|
|
{
|
|
|
|
$this->getTabs()->add($action, array(
|
2015-02-23 17:00:30 +01:00
|
|
|
'label' => ucfirst($action),
|
2014-04-02 13:23:18 +02:00
|
|
|
'url' => Url::fromPath(
|
|
|
|
'list/'
|
|
|
|
. str_replace(' ', '', $action)
|
|
|
|
)
|
2014-04-01 11:48:44 +02:00
|
|
|
))->activate($action);
|
|
|
|
}
|
|
|
|
|
2014-04-02 13:23:18 +02:00
|
|
|
/**
|
|
|
|
* Display the application log
|
|
|
|
*/
|
2014-04-01 11:48:44 +02:00
|
|
|
public function applicationlogAction()
|
|
|
|
{
|
2014-09-05 15:28:39 +02:00
|
|
|
if (! Logger::writesToFile()) {
|
|
|
|
throw new ActionError('Site not found', 404);
|
|
|
|
}
|
|
|
|
|
2014-04-01 11:48:44 +02:00
|
|
|
$this->addTitleTab('application log');
|
2014-09-05 15:28:39 +02:00
|
|
|
$pattern = '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
|
|
|
|
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
|
|
|
|
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
|
2014-09-05 15:33:34 +02:00
|
|
|
. ' - (?<message>.*)$/'; // message
|
2014-09-03 13:12:22 +02:00
|
|
|
|
|
|
|
$loggerWriter = Logger::getInstance()->getWriter();
|
2014-11-18 13:11:52 +01:00
|
|
|
$resource = new FileReader(new ConfigObject(array(
|
2014-09-05 15:28:39 +02:00
|
|
|
'filename' => $loggerWriter->getPath(),
|
|
|
|
'fields' => $pattern
|
|
|
|
)));
|
|
|
|
$this->view->logData = $resource->select()->order('DESC')->paginate();
|
2014-04-01 11:48:44 +02:00
|
|
|
}
|
|
|
|
}
|