From 2588b8dbb6a9fdd428cf47a9d6b7aa35e66f236e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 10 Oct 2013 14:40:13 +0200 Subject: [PATCH] Add monitoring controller class refs #4823 --- .../library/Monitoring/Controller.php | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Controller.php diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php new file mode 100644 index 000000000..762cc2a58 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -0,0 +1,93 @@ +_request, + $columns + )->getQuery(); + } else { + $params['backend'] = $this->_request->getParam('backend'); + $query = HostAndServiceStatusView::fromParams( + $params, + $columns + )->getQuery(); + } + $this->handleFormatRequest($query); + return $query->paginate(); + } + + private function handleFormatRequest($query) + { + if ($this->_getParam('format') === 'sql' + && IcingaConfig::app()->global->get('environment', 'production') === 'development') { + echo '
'
+                . htmlspecialchars(wordwrap($query->dump()))
+                . '
'; + exit; + } + if ($this->_getParam('format') === 'json' + || $this->_request->getHeader('Accept') === 'application/json') + { + header('Content-type: application/json'); + echo json_encode($query->fetchAll()); + exit; + } + if ($this->_getParam('format') === 'csv' + || $this->_request->getHeader('Accept') === 'text/csv') { + Csv::fromQuery($query)->dump(); + exit; + } + } +} +// @codingStandardsIgnoreEnd