studiosite / monitoring-bundle
Bundle for monitoring the simple parameters in yours projects
Installs: 438
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.5.9 || ^7.0
- symfony/framework-bundle: ^2.7 || ^3.0 || ^4.0
- symfony/templating: ^2.7 || ^3.0 || ^4.0
- symfony/twig-bundle: ^2.7 || ^3.0 || ^4.0
- twig/twig: ^1.28 || ^2.0
Requires (Dev)
- phpunit/phpunit: ^6.0
- symfony/yaml: ^4.0
This package is not auto-updated.
Last update: 2024-11-10 03:46:31 UTC
README
Sometimes it becomes necessary to monitor some parameters using external monitoring systems (for example, zabbix). The bundle makes it very easy
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require studiosite/monitoring-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new StudioSite\MonitoringBundle\StudioSiteMonitoringBundle(), ); } }
Step 3: Configuration
studio_site_monitoring: # path to console file for zabbix config generator # usually the bundle finds the desired path console: "%kernel.root_dir%/../bin/console"
Example of use
Consider an example service that provides values of parameters
<?php // AppBundle/Service/SomeService.php class SomeService { // Your magic... public function getSomeValue() { return 'teststring'; } public function getCount() { return 100; } public function getSum($a, $b) { return $a + $b; } }
The service description in DI
services: app_bundle.some_service: class: AppBundle\Service\SomeService tags: - { name: studiosite_monitoring.parameter, method: getSomeValue, key: app.some_value } - { name: studiosite_monitoring.parameter, method: getCount, key: app.count } - { name: studiosite_monitoring.parameter, method: getSum, key: app.sum }
Now you can get parameter values
# To see a list of available parameters: $ php bin/console studiosite:monitoring:get The list of available parameters: app.some_value app.count app.sum <a> <b> # To get the value of the parameter: $ php bin/console studiosite:monitoring:get app.some_value teststring $ php bin/console studiosite:monitoring:get app.sum 100 100 200
Generate zabbix user parameter config
The bundle can generate a configuration for all the collected parameters in zabbix userparameter format
$ php bin/console studiosite:monitoring:zabbix /etc/zabbix/conf.d/symfony.conf Write config to /etc/zabbix/conf.d/symfony.conf? y $ cat /etc/zabbix/conf.d/symfony.conf UserParameter=app.some_value[*], /var/www/dev/bin/console studiosite:monitoring:get app.some_value --no-debug -e prod UserParameter=app.count[*], /var/www/dev/bin/console studiosite:monitoring:get app.count --no-debug -e prod UserParameter=app.sum[*], /var/www/dev/bin/console studiosite:monitoring:get app.sum $1 $2 --no-debug -e prod