diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..7a20298 --- /dev/null +++ b/Admin/Activate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\ActivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Activate extends ActivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function activate(DatabasePool $dbPool, InfoManager $info) + { + parent::activate($dbPool, $info); + } +} diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php new file mode 100644 index 0000000..fbbce1f --- /dev/null +++ b/Admin/Deactivate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\DeactivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Deactivate extends DeactivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function deactivate(DatabasePool $dbPool, InfoManager $info) + { + parent::deactivate($dbPool, $info); + } +} diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json new file mode 100644 index 0000000..100b441 --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,48 @@ +[ + { + "id": 1000706001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Monitoring", + "uri": "/{/lang}/backend/admin/monitoring/general?{?}", + "target": "self", + "icon": null, + "order": 50, + "from": "Monitoring", + "permission": null, + "parent": 1000101001, + "children": [ + { + "id": 1000706101, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 3, + "subtype": 1, + "name": "Dashboard", + "uri": "/{/lang}/backend/admin/monitoring/general?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Monitoring", + "permission": null, + "parent": 1000706001, + "children": [] + }, + { + "id": 1000706102, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 3, + "subtype": 1, + "name": "Logs", + "uri": "/{/lang}/backend/admin/monitoring/log/list?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Monitoring", + "permission": null, + "parent": 1000706001, + "children": [] + } + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..5df5c8e --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin\Install; +use phpOMS\DataStorage\Database\DatabasePool; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install(string $path, DatabasePool $dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + /** @var $class \Modules\Navigation\Admin\Installer */ + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..d59342e --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,43 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin; + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InstallerAbstract; +use phpOMS\Module\InfoManager; + +/** + * Monitoring install class. + * + * @category Modules + * @package Modules\Monitoring + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) + { + parent::install($path, $dbPool, $info); + } +} diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..28449f3 --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,24 @@ + [ + [ + 'dest' => '\Modules\Monitoring\Controller:viewMonitoringGeneral', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/monitoring/log/list.*$' => [ + [ + 'dest' => '\Modules\Monitoring\Controller:viewMonitoringLogList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/monitoring/log/single.*$' => [ + [ + 'dest' => '\Modules\Monitoring\Controller:viewMonitoringLogEntry', + 'verb' => RouteVerb::GET, + ], + ], +]; diff --git a/Admin/Routes/console.php b/Admin/Routes/console.php new file mode 100644 index 0000000..1ecbfac --- /dev/null +++ b/Admin/Routes/console.php @@ -0,0 +1,3 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\UninstallAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Uninstall extends UninstallAbstract +{ + + /** + * {@inheritdoc} + */ + public static function uninstall(DatabasePool $dbPool, InfoManager $info) + { + parent::uninstall($dbPool, $info); + } +} diff --git a/Admin/Update.php b/Admin/Update.php new file mode 100644 index 0000000..844c0ec --- /dev/null +++ b/Admin/Update.php @@ -0,0 +1,46 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\UpdateAbstract; +use phpOMS\System\File\Directory; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Update extends UpdateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function update(DatabasePool $dbPool, array $info) + { + Directory::deletePath(__DIR__ . '/Update'); + mkdir('Update'); + parent::update($dbPool, $info); + } +} diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..7fc605f --- /dev/null +++ b/Controller.php @@ -0,0 +1,140 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Monitoring; + +use Modules\Navigation\Models\Navigation; +use Modules\Navigation\Views\NavigationView; +use phpOMS\Contract\RenderableInterface; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; +use phpOMS\Views\ViewLayout; + +/** + * Monitoring controller class. + * + * @category Modules + * @package Modules\Monitoring + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module path. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_PATH = __DIR__; + + /** + * Module version. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_VERSION = '1.0.0'; + + /** + * Module name. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_NAME = 'Monitoring'; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = []; + + /** + * Dependencies. + * + * @var string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewMonitoringGeneral(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Monitoring/Theme/Backend/monitoring-dashboard'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000706001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewMonitoringLogList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Monitoring/Theme/Backend/monitoring-logs'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000706001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewMonitoringLogEntry(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Monitoring/Theme/Backend/monitoring-logs-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000706001, $request, $response)); + + return $view; + } + +} diff --git a/Models/Log.php b/Models/Log.php new file mode 100644 index 0000000..b603add --- /dev/null +++ b/Models/Log.php @@ -0,0 +1,34 @@ +toArray(); + } +} \ No newline at end of file diff --git a/Models/LogMapper.php b/Models/LogMapper.php new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..7c5f574 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,20 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Navigation' => [ + 'List' => 'List', + 'Logs' => 'Logs', + 'Monitoring' => 'Monitoring', +]]; diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php new file mode 100644 index 0000000..a82e530 --- /dev/null +++ b/Theme/Backend/Lang/api.en.lang.php @@ -0,0 +1,18 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG[1] = [ + 'i:ModuleInstalled' => 'Installation of the module {$1} was successful.', +]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..5bfe3f0 --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,54 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Monitoring' => [ + 'Alerts' => 'Alerts', + 'All' => 'All', + 'Backtrace' => 'Backtrace', + 'CPUUsage' => 'CPU Usage', + 'Created' => 'Created', + 'CreatedBy' => 'Created By', + 'Criticals' => 'Criticals', + 'Debug' => 'Debug', + 'Description' => 'Description', + 'DiskUsage' => 'DiskUsage', + 'Emergencies' => 'Emergencies', + 'Errors' => 'Errors', + 'Exception' => 'Exception', + 'File' => 'File', + 'Info' => 'Info', + 'Level' => 'Level', + 'Line' => 'Line', + 'Logs' => 'Logs', + 'MemoryLimit' => 'Memory Limit', + 'Message' => 'Message', + 'Notices' => 'Notices', + 'Status' => 'Status', + 'System' => 'System', + 'Total' => 'Total', + 'OS' => 'OS', + 'Penetrators' => 'Penetrators', + 'RAMUsage' => 'RAM Usage', + 'Release' => 'Release', + 'Report' => 'Report', + 'Source' => 'Source', + 'SystemRAM' => 'System RAM', + 'Theme' => 'Theme', + 'Time' => 'Time', + 'Timestamp' => 'Timestamp', + 'Uri' => 'Uri', + 'Version' => 'Version', + 'Warnings' => 'Warnings', +]]; diff --git a/Theme/Backend/monitoring-dashboard.tpl.php b/Theme/Backend/monitoring-dashboard.tpl.php new file mode 100644 index 0000000..d9a2956 --- /dev/null +++ b/Theme/Backend/monitoring-dashboard.tpl.php @@ -0,0 +1,73 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$logs = $this->app->logger->countLogs(); +$penetrators = $this->app->logger->getHighestPerpetrator(); + +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('System') ?>

+
+ + +
getText('OS') ?> +
getText('Version') ?> +
getText('Release') ?> +
getText('RAMUsage') ?> MB +
getText('MemoryLimit') ?> +
getText('SystemRAM') ?> MB +
getText('CPUUsage') ?>% +
+
+
+
+ +
+
+

getText('Logs') ?>

+
+ + +
getText('Emergencies') ?> +
getText('Criticals') ?> +
getText('Errors') ?> +
getText('Warnings') ?> +
getText('Alerts') ?> +
getText('Notices') ?> +
getText('Info') ?> +
getText('Debug') ?> +
getText('Total') ?> +
+
+
+
+ +
+
+

getText('Penetrators') ?>

+
+ + + $count) : ?> +
+ +
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/monitoring-logs-single.tpl.php b/Theme/Backend/monitoring-logs-single.tpl.php new file mode 100644 index 0000000..72121f5 --- /dev/null +++ b/Theme/Backend/monitoring-logs-single.tpl.php @@ -0,0 +1,95 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$log = $this->app->logger->getByLine((int) $this->request->getData('id') ?? 1); +$temp = trim($log['backtrace']); +$log['backtrace'] = json_decode($temp, true); + +$details = '* Uri: `' . trim($log['path']) . "`\n" + . '* Level: `' . trim($log['level']) . "`\n" + . '* Message: `' . trim($log['message']) . "`\n" + . '* File: `' . trim($log['file']) . "`\n" + . '* Line: `' . trim($log['line']) . "`\n" + . '* Version: `' . trim($log['version']) . "`\n" + . '* OS: `' . trim($log['os']) . "`\n\n" + . "Backtrace: \n\n```\n" . json_encode($log['backtrace'], JSON_PRETTY_PRINT); + +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Logs'); ?>

+ +
+ + + + + + + + + + + + + + +
getText('ID', 0, 0); ?> + + request->getData('id') ?? 0; ?> +
getText('Time'); ?> + + +
getText('Uri'); ?> + + +
getText('Source'); ?> + + +
getText('Level'); ?> + + + +
getText('Message'); ?> + + +
getText('File'); ?> + + +
getText('Line'); ?> + + +
getText('Version'); ?> + + +
getText('OS'); ?> + + +
getText('Backtrace'); ?> +
+
+
getText('Report'); ?> +
+
+
+
+
diff --git a/Theme/Backend/monitoring-logs.tpl.php b/Theme/Backend/monitoring-logs.tpl.php new file mode 100644 index 0000000..5d26e70 --- /dev/null +++ b/Theme/Backend/monitoring-logs.tpl.php @@ -0,0 +1,59 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages(0 / 25); +$footerView->setPage(1); +$footerView->setResults(0); + +$logs = array_reverse($this->app->logger->get(25), true); + +echo $this->getData('nav')->render(); ?> + +
+
+ + + + + + + + $value) : + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/monitoring/logs/single?{?}&id=' . $key);?> + + +
getText('Logs'); ?>
getText('Timestamp'); ?> + getText('Level'); ?> + getText('Source'); ?> + getText('Message'); ?> +
render(); ?> +
> + > + > + > + +
+ +
+
+
diff --git a/img/module_teaser_small.png b/img/module_teaser_small.png new file mode 100644 index 0000000..f56e6ff Binary files /dev/null and b/img/module_teaser_small.png differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..3abd912 --- /dev/null +++ b/info.json @@ -0,0 +1,44 @@ +{ + "name": { + "id": 1000700000, + "internal": "Monitoring", + "external": "OMS Monitoring" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The administration module.", + "directory": "Monitoring", + "dependencies": { + "Admin" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Monitoring", + "for": "Navigation", + "file": "Navigation" + }, + { + "pid": [ + "c66e6604564259b087dc6db1e46de8cf6353c96d" + ], + "type": 4, + "for": "Content", + "file": "Monitoring", + "from": "Monitoring" + } + ] +}