diff --git a/CHANGELOG.md b/CHANGELOG.md index 186cc0c..768b8cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,421 +1,10 @@ # Change Log -## [v1.3.6](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.6) (2019-09-07) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.5...v1.3.6) +## [v2.0.0](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v2.0.0) (2023-02-23) -**Closed issues:** +**BREAKING CHANGES:** +- Only [icingadb](https://github.com/Icinga/icingadb) backend for [icingadb-web](https://github.com/Icinga/icingadb-web) will be supported from now on. -- Some services not shown in Icingaweb2 2.7.1 when grafana module enabled [\#221](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/221) -- 'No data points' on host objects with spaces in the name [\#219](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/219) -- Question concerning the 2 dashboards [\#216](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/216) -- Timelegend is shown UTC and not Browser / php time [\#215](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/215) -- Icinga2 not get all the graphs from grafana , got only ping4 graph [\#197](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/197) - -## [v1.3.5](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.5) (2019-05-12) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.4...v1.3.5) - -**Implemented enhancements:** - -- Disable autorefresh for grafana iframe [\#209](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/209) ([friesoft](https://github.com/friesoft)) - -**Fixed bugs:** - -- Problems using spaces in command name [\#210](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/210) -- Problem with unknown Datasource [\#208](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/208) -- customVars in grafana URLs not working anymore [\#202](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/202) - -**Closed issues:** - -- var-hostname with newest files from repo not working with graphite [\#204](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/204) - -## [v1.3.4](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.4) (2018-12-17) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.3...v1.3.4) - -**Fixed bugs:** - -- Icingaweb2-Dashlet with Grafana-Graphs needs permisison for grafana/graph, which doesn't exists [\#191](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/191) - -**Closed issues:** - -- Graphs broken with 1.3.3 version together with Grafana 5 and Enable link = Yes [\#194](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/194) - -## [v1.3.3](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.3) (2018-12-16) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.2...v1.3.3) - -**Implemented enhancements:** - -- support multiple custom vars [\#189](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/189) ([cxcv](https://github.com/cxcv)) - -**Fixed bugs:** - -- Custom Vars don't get escaped when send over to grafana [\#186](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/186) - -**Closed issues:** - -- No Graph shown on master since commits from 10.12.2018 [\#192](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/192) -- support multiple custom variables [\#188](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/188) -- Help creating dashboard template parsing metrics [\#185](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/185) -- Time used by graphs in Icingaweb2 [\#107](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/107) - -**Merged pull requests:** - -- Update 02-installation.md [\#190](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/190) ([Eifoen](https://github.com/Eifoen)) - -## [v1.3.2](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.2) (2018-09-14) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.1...v1.3.2) - -**Fixed bugs:** - -- Selecting any "Special" timerange breaks graph in module but following link to Grafana works [\#182](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/182) -- Variable timerange is missing host on post request. [\#180](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/180) -- No graphs for unavailable services [\#177](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/177) - -**Closed issues:** - -- Changing timerange is missing the parameter host. [\#181](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/181) -- Is it possible to use Regex in Grafana Config [\#179](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/179) - -## [v1.3.1](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.1) (2018-08-14) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.3.0...v1.3.1) - -**Fixed bugs:** - -- Indirectproxy multiple panels show one panel multiple times [\#178](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/178) - -## [v1.3.0](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.3.0) (2018-08-14) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.5...v1.3.0) - -**Implemented enhancements:** - -- added field to configure timeranges by hand [\#176](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/176) ([neubi4](https://github.com/neubi4)) -- Move permission test to the HostActions Hook [\#173](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/173) ([lippserd](https://github.com/lippserd)) - -**Fixed bugs:** - -- View all graphs and grafana\_graph\_disable [\#172](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/172) -- The default timerange for graphs does not work [\#164](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/164) - -**Closed issues:** - -- Host Action "Show all Graphs" - No Data Ppoints [\#175](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/175) -- How to with "check\_by\_ssh" ???? [\#174](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/174) -- No data points even performance\_data shows data [\#169](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/169) -- Same graph for all checks with same name [\#163](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/163) - -**Merged pull requests:** - -- Graphs on dashboard [\#154](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/154) ([nbuchwitz](https://github.com/nbuchwitz)) - -## [v1.2.5](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.5) (2018-05-31) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.4...v1.2.5) - -**Fixed bugs:** - -- failure if grafana\_graph\_disable is not set [\#157](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/157) -- Indirect-proxy-mode not working when using FQDN as hostname [\#156](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/156) -- "Disable Graph" feature seems broken [\#111](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/111) - -**Closed issues:** - -- Config parsing inconsistency regarding 'indirectproxyrefresh' [\#153](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/153) -- indirectproxy mode - default dashboard [\#152](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/152) -- indirect proxy mode uses http:// links [\#136](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/136) -- Indirect-Proxy mode crops redered images [\#127](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/127) - -## [v1.2.4](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.4) (2018-04-30) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.3...v1.2.4) - -**Fixed bugs:** - -- Module fails if no cutom variable is set to disable graph [\#151](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/151) - -## [v1.2.3](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.3) (2018-04-29) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.2...v1.2.3) - -## [v1.2.2](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.2) (2018-04-29) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.1...v1.2.2) - -**Implemented enhancements:** - -- indirectproxy mode refreshes graphs [\#142](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/142) -- Fix behavior of disabling the Grafana Graph [\#140](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/140) ([mcktr](https://github.com/mcktr)) - -**Fixed bugs:** - -- indirectproxy mode - custom variables [\#145](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/145) -- Error creating or updating Grafana Graphs on Icinga Web [\#138](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/138) - -**Closed issues:** - -- Passive checks performance counters not showed in grafana [\#144](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/144) -- Error Integrating Grafana to Icinga2 Host Overview [\#143](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/143) -- Group by value based on timeframe [\#139](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/139) -- graphs are not saved -\> uncaught error [\#137](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/137) - -## [v1.2.1](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.1) (2018-03-21) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.2.0...v1.2.1) - -**Implemented enhancements:** - -- \[Feature request\] Indirect Proxy: Reserve space to prevent jumps when graphs appear [\#131](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/131) -- Idea: How to speed up proxy mode [\#126](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/126) -- Proposal: Issue Milestones, Labels, Styleguide, Contributing, Changelog [\#34](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/34) -- add permission for enableLink [\#135](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/135) ([xam-stephan](https://github.com/xam-stephan)) - -**Fixed bugs:** - -- Undefined index: grafana\_version [\#134](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/134) -- Print link has nasty & in url which causes timerange not honored [\#130](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/130) -- Module does not load first graph \(panelId=1\) from dashboard [\#129](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/129) - -**Closed issues:** - -- Optional use host\_display\_name instead of host\_name in call to Grafana [\#133](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/133) -- Scope of Custom Variables [\#132](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/132) -- Indirect Proxy Mode: If one panel fails to render the previous gets duplicated [\#128](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/128) -- Grafana 5 compatibility [\#116](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/116) - -## [v1.2.0](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.2.0) (2018-03-06) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.10...v1.2.0) - -**Implemented enhancements:** - -- Create new dashboards for ITL plugins [\#105](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/105) -- Support grafana API token [\#97](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/97) -- Feature request - grafana graphs names wildcards specifications [\#39](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/39) -- Feature request: Show all graphs from host [\#30](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/30) -- Fullscreen view for default dashboard panels [\#119](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/119) ([jonbulica99](https://github.com/jonbulica99)) - -**Fixed bugs:** - -- Using a dashboard with spaces in between words [\#108](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/108) - -**Closed issues:** - -- Document host -\> all graphs action [\#125](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/125) -- Make panel id for default dashboard configurable [\#122](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/122) -- Grafana ApiKey and iFrame [\#121](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/121) -- custom variables in graphs [\#120](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/120) -- Using "hostdisplayname" as a parameter for graph generation [\#109](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/109) -- Service performance graph shows wrong graph of another service [\#103](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/103) -- Explain the purpose of Grafana dashboards & how to enhance them [\#75](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/75) - -**Merged pull requests:** - -- Add Changelog for 1.2.0; update release docs [\#124](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/124) ([dnsmichi](https://github.com/dnsmichi)) -- Update GraphForm.php [\#123](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/123) ([nbuchwitz](https://github.com/nbuchwitz)) -- 1.2.0 [\#118](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/118) ([Mikesch-mp](https://github.com/Mikesch-mp)) -- Update 02-installation.md [\#117](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/117) ([nbuchwitz](https://github.com/nbuchwitz)) - -## [v1.1.10](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.10) (2017-12-17) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.8...v1.1.10) - -**Implemented enhancements:** - -- Feature request: All panels [\#42](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/42) - -**Fixed bugs:** - -- Possibility to define organization ID [\#84](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/84) -- Proxy Mode: Show a better error message if PHP CURL is not installed/loaded [\#89](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/89) ([dnsmichi](https://github.com/dnsmichi)) - -**Closed issues:** - -- Update releases [\#104](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/104) -- Error after upgrading to icingaweb2 2.4.1 [\#101](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/101) -- Graph per metric [\#96](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/96) -- curl timeout [\#94](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/94) -- Error importing dashboard grafana [\#93](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/93) -- Error viewing host after enable grafana module [\#92](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/92) -- no upgrade instructions [\#87](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/87) -- Move installation, configuration, etc. to doc/ and link over there. [\#76](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/76) - -**Merged pull requests:** - -- Update 04-graph-configuration.md [\#91](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/91) ([nbuchwitz](https://github.com/nbuchwitz)) -- Update module.info [\#90](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/90) ([nbuchwitz](https://github.com/nbuchwitz)) -- Docs: Make it more clear to enable the module [\#86](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/86) ([dnsmichi](https://github.com/dnsmichi)) - -## [v1.1.8](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.8) (2017-07-17) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.7...v1.1.8) - -**Implemented enhancements:** - -- Add contribution guide & add license/support info [\#74](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/74) ([dnsmichi](https://github.com/dnsmichi)) -- Add GitHub issue template [\#73](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/73) ([dnsmichi](https://github.com/dnsmichi)) -- Add RELEASE.md for release workflow help [\#72](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/72) ([dnsmichi](https://github.com/dnsmichi)) - -**Fixed bugs:** - -- Hard-Coded InfluxDB/HostAlive in icinga2-default.json [\#82](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/82) -- Graph is not displayed if service status UNKNOWN [\#71](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/71) -- Add support for multiple Grafana Organization [\#79](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/79) ([epinter](https://github.com/epinter)) - -## [v1.1.7](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.7) (2017-06-03) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.6...v1.1.7) - -**Implemented enhancements:** - -- Remove outline \(on-click\) from image [\#69](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/69) ([epinter](https://github.com/epinter)) - -**Merged pull requests:** - -- Add the defaultdashboard option 'none' to README [\#70](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/70) ([epinter](https://github.com/epinter)) - -## [v1.1.6](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.6) (2017-06-01) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.5...v1.1.6) - -**Implemented enhancements:** - -- 1.1.5 - No more scaling of the graph size ? [\#67](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/67) -- Proposal/Wish: Add a configuration switch for the theme/style [\#50](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/50) -- Fix CSS menu on webkit browsers [\#65](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/65) ([epinter](https://github.com/epinter)) -- Set image width and height to auto [\#64](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/64) ([epinter](https://github.com/epinter)) -- Use icinga color for timerange menu [\#62](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/62) ([epinter](https://github.com/epinter)) - -**Fixed bugs:** - -- 1.1.6 - Undefined variable: imgClass [\#68](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/68) -- No Graph while Status Unknown [\#66](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/66) -- Parse error: syntax error, unexpected '\[' in Grapher.php [\#55](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/55) - -## [v1.1.5](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.5) (2017-05-23) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.4...v1.1.5) - -**Implemented enhancements:** - -- disable graphs at service manually or automatic? [\#9](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/9) -- Move styles to css file [\#53](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/53) ([epinter](https://github.com/epinter)) - -**Merged pull requests:** - -- Remove executable bit from files [\#52](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/52) ([dnsmichi](https://github.com/dnsmichi)) - -## [v1.1.4](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.4) (2017-05-20) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.3...v1.1.4) - -**Implemented enhancements:** - -- Add theme selection, light by default [\#57](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/57) ([epinter](https://github.com/epinter)) - -**Fixed bugs:** - -- master broken due to typo [\#43](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/43) - -## [v1.1.3](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.3) (2017-05-01) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.2...v1.1.3) - -## [v1.1.2](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.2) (2017-04-30) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.1...v1.1.2) - -**Implemented enhancements:** - -- Add a GitHub description [\#38](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/38) -- Proxy mode with curl might fail with SELinux enabled [\#35](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/35) -- Timeout for proxy mode [\#40](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/40) - -**Fixed bugs:** - -- Proxy mode error handling with curl is buggy and not verbose enough [\#32](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/32) -- Proxy mode always returns 401 [\#31](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/31) -- multiple panelid's give error [\#29](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/29) -- Graphs don't refresh when Grafana access mode is direct [\#41](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/41) -- custom vars missing in link url [\#36](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/36) - -**Merged pull requests:** - -- Fix curl error handling and format error string [\#37](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/37) ([dnsmichi](https://github.com/dnsmichi)) -- Better error handling for proxy access mode [\#33](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/33) ([dnsmichi](https://github.com/dnsmichi)) - -## [v1.1.1](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.1) (2017-04-22) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.1.0...v1.1.1) - -**Implemented enhancements:** - -- Graph render performance slow [\#21](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/21) - -## [v1.1.0](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.1.0) (2017-04-21) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.11...v1.1.0) - -**Fixed bugs:** - -- Missing Grafana host configuration results in Undefined property: Icinga\Module\Grafana\ProvidedHook\Grapher::$view [\#26](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/26) -- Timerange menu - Service not found [\#24](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/24) - -**Merged pull requests:** - -- Fix view exception if Grafana host is not configured [\#28](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/28) ([dnsmichi](https://github.com/dnsmichi)) -- Enhance the documentation, add screenshots [\#27](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/27) ([dnsmichi](https://github.com/dnsmichi)) - -## [v1.0.11](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.11) (2017-04-20) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.10...v1.0.11) - -## [v1.0.10](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.10) (2017-04-20) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.9...v1.0.10) - -**Implemented enhancements:** - -- Possibility to change time in the view [\#4](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/4) - -## [v1.0.9](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.9) (2017-04-20) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.8...v1.0.9) - -## [v1.0.8](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.8) (2017-04-05) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.7...v1.0.8) - -**Implemented enhancements:** - -- Change graph size when adding new Graphana Graphs [\#19](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/19) -- New features [\#20](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/20) ([xbulat](https://github.com/xbulat)) - -## [v1.0.7](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.7) (2017-03-31) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.6...v1.0.7) - -**Merged pull requests:** - -- Add file backend for dashboards [\#18](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/18) ([dh-harald](https://github.com/dh-harald)) - -## [v1.0.6](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.6) (2017-03-30) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.5...v1.0.6) - -## [v1.0.5](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.5) (2017-03-27) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.4...v1.0.5) - -**Implemented enhancements:** - -- Possibility to add more then one graph [\#12](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/12) - -**Closed issues:** - -- Grafana did not show the configuration Menu [\#16](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/16) -- png preview files not generated... [\#13](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/13) - -## [v1.0.4](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.4) (2017-03-17) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.3...v1.0.4) - -**Implemented enhancements:** - -- "default rendering" options in configuration [\#3](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/3) -- Sample dashboard works for InfluxDB but not Graphite [\#1](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/1) - -**Merged pull requests:** - -- fixed dashboard default value [\#8](https://github.com/Mikesch-mp/icingaweb2-module-grafana/pull/8) ([mkayontour](https://github.com/mkayontour)) - -## [v1.0.3](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.3) (2017-03-03) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.2...v1.0.3) - -**Implemented enhancements:** - -- Docs: Provide a code snippet for config.ini [\#2](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues/2) - -## [v1.0.2](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.2) (2017-02-13) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.1...v1.0.2) - -## [v1.0.1](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.1) (2017-02-08) -[Full Changelog](https://github.com/mikesch-mp/icingaweb2-module-grafana/compare/v1.0.0...v1.0.1) - -## [v1.0.0](https://github.com/mikesch-mp/icingaweb2-module-grafana/tree/v1.0.0) (2017-02-07) - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* +**Open Issues* +- PDF export does not load the panels +- Documentation needs to be rewritten diff --git a/README.md b/README.md index 04d5cdc..0d7842d 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,10 @@ Join the [Icinga community channels](https://icinga.com/community/) for question ## Requirements -* [Icinga Web 2](https://www.icinga.com/products/icinga-web-2/) (>= 2.8.2) +* [Icinga Web 2](https://www.icinga.com/products/icinga-web-2/) (>= 2.11) * [Grafana](https://grafana.com/) (>= 7.0) * [InfluxDB](https://docs.influxdata.com/influxdb/) (>= 1.0) [Graphite](https://graphiteapp.org) as backend for Grafana -* [PHP 7](https://www.php.net) **with curl enabled** (for proxy mode) +* [PHP 8.1](https://www.php.net) **with curl and gd enabled** ## Documentation @@ -61,6 +61,3 @@ updating the documentation. Every contribution is appreciated! Please continue reading in the [contributing chapter](CONTRIBUTING.md). -## Donations -This module is and will always be free of charge. But if you feel the urge to make the developer happy, you can donate item(s) from his [Amazon wishlist](https://www.amazon.de/hz/wishlist/ls/1QS5BHOL5V7AE?&sort=default) :) - diff --git a/application/controllers/IcingadbimgController.php b/application/controllers/IcingadbimgController.php index 41f6fea..72bcc3a 100644 --- a/application/controllers/IcingadbimgController.php +++ b/application/controllers/IcingadbimgController.php @@ -268,8 +268,8 @@ private function getServiceObject() 'host', 'host.state' ]); - $query->filter(Filter::equal('name', $this->getParam('service'))); - $query->filter(Filter::equal('host.name', $this->getParam('host'))); + $query->filter(Filter::equal('name', urldecode($this->getParam('service')))); + $query->filter(Filter::equal('host.name', urldecode($this->getParam('host')))); $this->applyRestrictions($query); diff --git a/application/controllers/IcingadbshowController.php b/application/controllers/IcingadbshowController.php index b491edc..d59d404 100644 --- a/application/controllers/IcingadbshowController.php +++ b/application/controllers/IcingadbshowController.php @@ -24,6 +24,7 @@ use ipl\Stdlib\Filter; use ipl\Web\Url; + class IcingadbshowController extends IcingadbGrafanaController { /** @var bool */ @@ -52,6 +53,7 @@ public function indexAction() } $this->disableAutoRefresh(); + /* if (!$this->showFullscreen) { $this->getTabs()->add( 'graphs', @@ -63,6 +65,7 @@ public function indexAction() $this->getTabs()->extend(new PrintAction()); } + */ $this->addControl( HtmlElement::create( @@ -168,4 +171,4 @@ public function getServiceObject($service, $host) return $service; } -} \ No newline at end of file +} diff --git a/application/controllers/ImgController.php b/application/controllers/ImgController.php deleted file mode 100644 index 4fe7efb..0000000 --- a/application/controllers/ImgController.php +++ /dev/null @@ -1,365 +0,0 @@ -getParam('host'))) - { - throw new \Error('No host given!'); - } - - /* save timerange from params for later use */ - $this->timerange = $this->hasParam('timerange') ? urldecode($this->getParam('timerange')) : null; - if($this->hasParam('timerangeto')) { - $this->timerangeto = urldecode($this->getParam('timerangeto')); - } else { - $this->timerangeto = strpos($this->timerange, '/') ? 'now-' . $this->timerange : "now"; - } - $this->cacheTime = $this->hasParam('cachetime') ? $this->getParam('cachetime') : 300; - - /* load global configuration */ - $this->myConfig = Config::module('grafana')->getSection('grafana'); - $this->grafanaHost = $this->myConfig->get('host', $this->grafanaHost); - if ($this->grafanaHost == null) { - throw new ConfigurationError( - 'No Grafana host configured!' - ); - } - $this->protocol = $this->myConfig->get('protocol', $this->protocol); - - $this->defaultDashboard = $this->myConfig->get('defaultdashboard', $this->defaultDashboard); - $this->defaultdashboarduid = $this->myConfig->get('defaultdashboarduid', NULL); - if (is_null($this->defaultdashboarduid)) { - throw new ConfigurationError( - 'Usage of Grafana 5 is configured but no UID for default dashboard found!' - ); - } - $this->defaultDashboardPanelId = $this->myConfig->get('defaultdashboardpanelid', $this->defaultDashboardPanelId); - $this->defaultOrgId = $this->myConfig->get('defaultorgid', $this->defaultOrgId); - $this->grafanaTheme = $this->myConfig->get('theme', $this->grafanaTheme); - $this->defaultDashboardStore = $this->myConfig->get('defaultdashboardstore', $this->defaultDashboardStore); - $this->height = $this->myConfig->get('height', $this->height); - $this->width = $this->myConfig->get('width', $this->width); - $this->proxyTimeout = $this->myConfig->get('proxytimeout', $this->proxyTimeout); - $this->refresh = $this->myConfig->get('indirectproxyrefresh', $this->refresh); - /** - * Read the global default timerange - */ - if($this->timerange == null) { - $this->timerange = $this->config->get('timerange', $this->timerange); - } - /** - * Datasource needed to regex special chars - */ - $this->dataSource = $this->myConfig->get('datasource', $this->dataSource); - /** - * Display shadows around graph - */ - $this->shadows = $this->myConfig->get('shadows', $this->shadows); - /** - * Name of the custom varibale for graph config - */ - $this->custvarconfig = ($this->myConfig->get('custvarconfig', $this->custvarconfig)); - /** - * Verify the certificate's name against host - */ - $this->SSLVerifyHost = ($this->myConfig->get('ssl_verifyhost', $this->SSLVerifyHost)); - /** - * Verify the peer's SSL certificate - */ - $this->SSLVerifyPeer = ($this->myConfig->get('ssl_verifypeer', $this->SSLVerifyPeer)); - - /** - * Username & Password or token - */ - - $this->apiToken = $this->myConfig->get('apitoken', $this->apiToken); - $this->authentication = $this->myConfig->get('authentication'); - if ($this->apiToken == null && $this->authentication == "token") { - throw new ConfigurationError( - 'API token usage configured, but no token given!' - ); - } else { - $this->username = $this->myConfig->get('username', $this->username); - $this->password = $this->myConfig->get('password', $this->password); - if ($this->username != null) { - if ($this->password != null) { - $this->myAuth = $this->username . ":" . $this->password; - } else { - $this->myAuth = $this->username; - } - } else { - $this->myAuth = ""; - } - } - - } - - public function indexAction() - { - if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) { - $this->redirectNow(Url::fromPath('grafana/icingadbimg')->setQueryString($this->params)); - } - - if ($this->hasParam('service') && ! is_null($this->getParam('service'))) - { - $service = $this->getServiceObject(); - $this->object = $service; - $serviceName = $this->object->service_description; - $hostName = $this->object->host_name; - } else { - $host = $this->getHostObject(); - $this->object = $host; - $serviceName = $this->object->check_command; - $hostName = $this->object->getName(); - } - - if (array_key_exists($this->custvarconfig, $this->object->customvars) && ! empty($this->object->customvars[$this->custvarconfig])) { - $this->setGraphConf($this->object->customvars[$this->custvarconfig]); - } else { - $this->setGraphConf($serviceName, $this->object->check_command); - } - - if (!empty($this->customVars)) { - // replace template to customVars from Icinga2 - $customVars = $this->object->fetchCustomvars()->customvars; - foreach ($customVars as $k => $v) { - $search[] = "\$$k\$"; - $replace[] = is_string($v) ? $v : null; - $this->customVars = str_replace($search, $replace, $this->customVars); - } - - // urlencodee values - $customVars = ""; - foreach (preg_split('/\&/', $this->customVars, -1, PREG_SPLIT_NO_EMPTY) as $param) { - $arr = explode("=", $param); - if (preg_match('/^\$.*\$$/', $arr[1])) { - $arr[1] = ''; - } - if ($this->dataSource == "graphite") { - $arr[1] = Util::graphiteReplace($arr[1]); - } - $customVars .= '&' . $arr[0] . '=' . rawurlencode($arr[1]); - } - $this->customVars = $customVars; - } - // replace special chars for graphite - if ($this->dataSource == "graphite") { - $serviceName = Util::graphiteReplace($serviceName); - $hostName = Util::graphiteReplace($hostName); - } - - $imageHtml = ""; - $res = $this->getMyimageHtml($serviceName, $hostName, $imageHtml); - header('Pragma: public'); - /* makes trouble with IcingaDB or php8.1 - if($this->refresh == "yes") { - header("Expires: ".gmdate("D, d M Y H:i:s", time() + $this->cacheTime)." GMT"); - header('Cache-Control: max-age='.$this->cacheTime).', public'; - } else { - header("Expires: ".gmdate("D, d M Y H:i:s", time() + 365*86440)." GMT"); - header('Cache-Control: max-age='. (365*86440)); - } - */ - header("Content-type: image/png"); - if (! $res) - { - // set expire to now and max age to 1 minute - header("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT"); - header('Cache-Control: max-age='. 120); - $string = wordwrap($this->translate('Error'). ': ' . $imageHtml,40,"\n"); - $lines = explode("\n", $string); - $im = @imagecreate ($this->width, $this->height); - $background_color = imagecolorallocate ($im, 255, 255, 255); //white background - $text_color = imagecolorallocate ($im, 255, 0,0);//black text - foreach ($lines as $i => $line) { - imagestring($im, 5, 0, 5 + $i * 15, $line, $text_color); - } - - ob_start(); - imagepng($im); - $img = ob_get_contents(); - ob_end_clean(); - imagedestroy($im); - - print $img; - } else { - print $imageHtml; - } - exit; - } - - private function getHostObject() - { - $myHost = new Host( - $this->backend, - urldecode($this->getParam('host')) - ); - $this->applyRestriction('monitoring/filter/objects', $myHost); - if ($myHost->fetch() === false) { - $this->httpNotFound($this->translate('Host not found')); - } - - return $myHost; - } - - private function getServiceObject() - { - $myService = new Service( - $this->backend, - urldecode($this->getParam('host')), - rawurldecode($this->getParam('service')) - ); - $this->applyRestriction('monitoring/filter/objects', $myService); - if ($myService->fetch() === false) { - $this->httpNotFound($this->translate('Service not found')); - } - return $myService; - } - - private function setGraphConf($serviceName, $serviceCommand = NULL) - { - $graphConfig = Config::module('grafana', 'graphs'); - - if ($graphConfig->hasSection(strtok($serviceName, ' ')) && ($graphConfig->hasSection($serviceName) == False)) { - $serviceName = strtok($serviceName, ' '); - } - if ($graphConfig->hasSection(strtok($serviceName, ' ')) == False && ($graphConfig->hasSection($serviceName) == False)) { - $serviceName = $serviceCommand; - if($graphConfig->hasSection($serviceCommand) == False && $this->defaultDashboard == 'none') { - return NULL; - } - } - - $this->dashboard = $graphConfig->get($serviceName, 'dashboard', $this->defaultDashboard); - $this->dashboarduid = $graphConfig->get($serviceName, 'dashboarduid', $this->defaultdashboarduid); - $this->panelId = $this->hasParam('panelid') ? $this->getParam('panelid') : $graphConfig->get($serviceName, 'panelId', $this->defaultDashboardPanelId); - $this->orgId = $graphConfig->get($serviceName, 'orgId', $this->defaultOrgId); - $this->customVars = $graphConfig->get($serviceName, 'customVars', ''); - $this->height = $graphConfig->get($serviceName, 'height', $this->height); - $this->width = $graphConfig->get($serviceName, 'width', $this->width); - - } - private function getMyimageHtml($serviceName, $hostName, &$imageHtml) - { - $imgClass = $this->shadows ? "grafana-img grafana-img-shadows" : "grafana-img"; - // Test whether curl is loaded - if (extension_loaded('curl') === false) { - $imageHtml = $this->translate('CURL extension is missing. Please install CURL for PHP and ensure it is loaded.'); - return false; - } - $this->pngUrl = sprintf( - '%s://%s/render/d-solo/%s/%s?var-hostname=%s&var-service=%s&var-command=%s%s&panelId=%s&orgId=%s&width=%s&height=%s&theme=%s&from=%s&to=%s', - $this->protocol, - $this->grafanaHost, - $this->dashboarduid, - $this->dashboard, - rawurlencode($hostName), - rawurlencode($serviceName), - rawurlencode($this->object->check_command), - $this->customVars, - $this->panelId, - $this->orgId, - $this->width, - $this->height, - $this->grafanaTheme, - urlencode($this->timerange), - urlencode($this->timerangeto) - ); - - // fetch image with curl - $curl_handle = curl_init(); - $curl_opts = array( - CURLOPT_URL => $this->pngUrl, - CURLOPT_CONNECTTIMEOUT => 2, - CURLOPT_FOLLOWLOCATION => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_SSL_VERIFYPEER => $this->SSLVerifyPeer, - CURLOPT_SSL_VERIFYHOST => ($this->SSLVerifyHost) ? 2 : 0, - CURLOPT_TIMEOUT => $this->proxyTimeout, - ); - - if ($this->authentication == "token") { - $curl_opts[CURLOPT_HTTPHEADER] = array('Content-Type: application/json' , "Authorization: Bearer ". $this->apiToken); - } else { - $curl_opts[CURLOPT_USERPWD] = "$this->myAuth"; - } - - curl_setopt_array($curl_handle, $curl_opts); - $res = curl_exec($curl_handle); - - $statusCode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); - - if ($res === false) { - $imageHtml .=$this->translate('Cannot fetch graph with curl') .': '. curl_error($curl_handle). '.'; - - //provide a hint for 'Failed to connect to ...: Permission denied' - if (curl_errno($curl_handle) == 7) { - $imageHtml .= $this->translate(' Check SELinux/Firewall.'); - } - return false; - } - - if ($statusCode > 299) { - $error = @json_decode($res); - $imageHtml .= $this->translate('Cannot fetch Grafana graph'). ": " . Util::httpStatusCodeToString($statusCode) . - " ". $statusCode .": " . ($error !== null && property_exists($error, 'message') ? $error->message : ""); - return false; - } - - curl_close($curl_handle); - $imageHtml = $res; - return true; - } -} diff --git a/application/controllers/ShowController.php b/application/controllers/ShowController.php deleted file mode 100644 index 2f3d490..0000000 --- a/application/controllers/ShowController.php +++ /dev/null @@ -1,140 +0,0 @@ -assertPermission('grafana/showall'); - $this->view->showFullscreen - = $this->showFullscreen - = (bool)$this->_helper->layout()->showFullscreen; - $this->host = $this->getParam('host'); - $this->config = Config::module('grafana')->getSection('grafana'); - /** - * Name of the custom varibale to disable graph - */ - $this->custvardisable = ($this->config->get('custvardisable', $this->custvardisable)); - } - - public function indexAction() - { - if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) { - $this->redirectNow(Url::fromPath('grafana/icingadbshow')->setQueryString($this->params)); - } - - $this->disableAutoRefresh(); - $this->view->host = $this->host; - - if (!$this->showFullscreen) { - $tabs = $this->getTabs(); - $tabs->add('graphs', array( - 'label' => $this->translate('Grafana Graphs'), - 'url' => $this->getRequest()->getUrl() - ))->activate('graphs'); - - $fullscreen = new Tab(array( - 'title' => $this->translate('Print'), - 'icon' => 'print', - 'url' => ((string)htmlspecialchars_decode($this->getRequest()->getUrl())) . '&showFullscreen' - )); - $fullscreen->setTargetBlank(); - $tabs->addAsDropdown('fullscreen', $fullscreen); - - $this->view->title = sprintf( - $this->translate('Performance graphs for %s'), - $this->host - ); - } - - // Preserve timerange if selected - $parameters = ['host' => $this->host]; - if ($this->hasParam('timerange')) { - $parameters['timerange'] = $this->getParam('timerange'); - } - - /* The timerange menu */ - $menu = new Timeranges($parameters, 'grafana/show'); - $this->view->menu = $menu->getTimerangeMenu(); - - /* first host object for host graph */ - $this->object = $this->getHostObject($this->host); - $customvars= $this->object->fetchCustomvars()->customvars; - if ($this->object->process_perfdata || !(isset($customvars[$this->custvardisable]) && json_decode(strtolower($customvars[$this->custvardisable])) !== false)) { - $objects[] = $this->object; - } - /* Get all services for this host */ - $query = $this->backend->select()->from('servicestatus', [ - 'service_description', - ]); - $this->applyRestriction('monitoring/filter/objects', $query); - - foreach ($query->where('host_name', $this->host) as $service) { - $this->object = $this->getServiceObject($service->service_description, $this->host); - $customvars= $this->object->fetchCustomvars()->customvars; - if ($this->object->process_perfdata && !(isset($customvars[$this->custvardisable]) && json_decode(strtolower($customvars[$this->custvardisable])) !== false)) { - $objects[] = $this->object; - } - } - unset($this->object); - unset($customvars); - $this->view->objects = $objects; - $this->view->grapher = Hook::first('grapher'); - } - - - public function getHostObject($host) - { - - $myHost = new Host($this->backend, $host); - $this->applyRestriction('monitoring/filter/objects', $myHost); - - if ($myHost->fetch() === false) { - $this->httpNotFound($this->translate('Host not found')); - } - - return $myHost; - } - - public function getServiceObject($service, $host) - { - $myService = new Service( - $this->backend, - $host, - $service - ); - $this->applyRestriction('monitoring/filter/objects', $myService); - - if ($myService->fetch() === false) { - $this->httpNotFound($this->translate('Service not found')); - } - - return $myService; - } - - -} \ No newline at end of file diff --git a/configuration.php b/configuration.php index fa8a24f..36cc412 100644 --- a/configuration.php +++ b/configuration.php @@ -1,6 +1,8 @@ providePermission('grafana/graphconfig', $this->translate('Allow to configure graphs.')); @@ -17,7 +19,11 @@ if ($auth->hasPermission('grafana/graphconfig')) { - $this->menuSection(N_('Configuration'))->add('Grafana Graphs')->setUrl('grafana/graph')->setPriority(900); + $section = $this->menuSection('Grafana Graphs')->setUrl('grafana/graph')->setPriority(999)->setIcon('chart-area'); + + $section->add(N_('Graphs Configuration'))->setUrl('grafana/graph')->setPriority(30); + $section->add(N_('Module Configuration'))->setUrl('grafana/config')->setPriority(40); + $this->provideConfigTab('graph', array( 'title' => 'Graphs', 'label' => 'Graphs', diff --git a/doc/01-about.md b/doc/01-about.md index fdd38ed..393e3be 100644 --- a/doc/01-about.md +++ b/doc/01-about.md @@ -22,4 +22,4 @@ LICENSE file included in the source package. ## Support -Join the [Icinga community channels](https://www.icinga.com/community/get-involved/) for questions. +[Github Issues](https://github.com/Mikesch-mp/icingaweb2-module-grafana/issues) diff --git a/doc/02-installation.md b/doc/02-installation.md index 5e9acf3..153b6f3 100644 --- a/doc/02-installation.md +++ b/doc/02-installation.md @@ -7,10 +7,10 @@ to the latest version, please [read on here](05-update.md). ## Requirements * [Icinga Web 2](https://www.icinga.com/products/icinga-web-2/) (>= - 2.8.2) + 2.11) * [Grafana](https://grafana.com/) (>= 7.0) * [InfluxDB](https://docs.influxdata.com/influxdb/) (>= 1.0) [Graphite](https://graphiteapp.org) as backend for Grafana -* [PHP 7](https://www.php.net) **with curl enabled** (for proxy mode) +* [PHP 8.1](https://www.php.net) **with curl and gd enabled** ## Install the Grafana module @@ -38,7 +38,7 @@ git clone "${REPO_URL}" "${TARGET_DIR}" Replace the version number with the lates available version from [Latest Release](https://github.com/Mikesch-mp/icingaweb2-module-grafana/releases/latest) ``` -MODULE_VERSION="1.1.7" +MODULE_VERSION="2.0.0" ICINGAWEB_MODULEPATH="/usr/share/icingaweb2/modules" REPO_URL="https://github.com/Mikesch-mp/icingaweb2-module-grafana" TARGET_DIR="${ICINGAWEB_MODULEPATH}/grafana" diff --git a/doc/03-module-configuration.md b/doc/03-module-configuration.md index 0bfcc2e..f125291 100644 --- a/doc/03-module-configuration.md +++ b/doc/03-module-configuration.md @@ -158,6 +158,7 @@ Contra: Images take some seconds to show up. In Iframe mode you have the full power of Grafana features like mouse over tooltip. Pro: All features from Grafana enabled. Fast page rendering. Contra: Less secure, page refresh from Icingaweb2 will be distracting! Needs `auth.anonymous` enabled in Grafana. +Also you need `allow_embedding = true` enabled in your grafana.ini ### ssl_verifypeer Only for `proxy` & `ìndirectproxy` modes. Verify the peer's SSL certificate. Defaults to `false`. diff --git a/doc/05-update.md b/doc/05-update.md index 360b7fd..0c56479 100644 --- a/doc/05-update.md +++ b/doc/05-update.md @@ -18,7 +18,7 @@ we will delete the old module directory first. Get the [latest version number](h into the `MODULE_VERSION` variable ```bash -MODULE_VERSION="1.2.0" +MODULE_VERSION="2.0.0" ICINGAWEB_MODULEPATH="/usr/share/icingaweb2/modules" REPO_URL="https://github.com/Mikesch-mp/icingaweb2-module-grafana" TARGET_DIR="${ICINGAWEB_MODULEPATH}/grafana" @@ -38,7 +38,3 @@ and or changed configuration options. When done, just hit the `Save Changes` but Dont forget to check the dashboard directories for newer versions of existing ones or new dashboards. - -## Grafana 5 - -If you enable Grafana 5 support in general configurations. You have to add the UID to all your configured graphs or they will not work anymore! diff --git a/library/Grafana/Helpers/Timeranges.php b/library/Grafana/Helpers/Timeranges.php index adc38aa..c595a75 100644 --- a/library/Grafana/Helpers/Timeranges.php +++ b/library/Grafana/Helpers/Timeranges.php @@ -98,7 +98,7 @@ private function buildTimerangeMenu($timerange = "", $timerangeto = "") $url = 'grafana/icingadbdashboard?'; } - $clockIcon = $this->view->qlink('', 'dashboard/new-dashlet', + $clockIcon = $this->view->qlink($timerange, 'dashboard/new-dashlet', ['url' => $url . http_build_query($this->urlparams, '', '&', PHP_QUERY_RFC3986)], ['icon' => 'clock', 'title' => 'Add graph to dashboard']); diff --git a/library/Grafana/ProvidedHook/GrafanaAuthentification.php b/library/Grafana/ProvidedHook/GrafanaAuthentification.php deleted file mode 100644 index c12422b..0000000 --- a/library/Grafana/ProvidedHook/GrafanaAuthentification.php +++ /dev/null @@ -1,58 +0,0 @@ -getUsername()))); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - if (!$result = curl_exec($ch)) { - // don't fail but log the possible errors - Logger::error(new \Exception(curl_error($ch))); - return; - } - - $preg = sprintf('/^\s*Set-Cookie:\s+%s=(.*?);.*$/mi', self::GRAFANA_SESS); - preg_match($preg, $result, $matches); - - if (count($matches) < 2) { - Logger::error(new \Exception("Login to grafana did not return any grafana_sess")); - return; - } - - $session = $matches[1]; - - if (!setcookie(self::GRAFANA_SESS, $session, 0, "/grafana", null, false, true)) { - Logger::error(new \Exception("Failed to set grafana_sess")); - return; - } - - return; - } - - public function onLogout(User $_) - { - // remove the cookie by set it to null - // this will remove this cookie from all tabs and windows - // but this will not logout the user from different browsers or devices - if (!setcookie(self::GRAFANA_SESS, null, 0, "/grafana", null, false, true)) { - Logger::error(new \Exception("Failed to set grafana_sess")); - return; - } - - return; - } -} diff --git a/library/Grafana/ProvidedHook/Grapher.php b/library/Grafana/ProvidedHook/Grapher.php deleted file mode 100644 index 2fa799d..0000000 --- a/library/Grafana/ProvidedHook/Grapher.php +++ /dev/null @@ -1,449 +0,0 @@ -Performance Graph"; - protected $custvardisable = "grafana_graph_disable"; - protected $custvarconfig = "grafana_graph_config"; - protected $repeatable = "no"; - protected $numberMetrics = "1"; - protected $debug = false; - protected $SSLVerifyPeer = false; - protected $SSLVerifyHost = "0"; - protected $cacheTime = 300; - protected $grafanaVersion = "0"; - protected $defaultdashboarduid; - - protected function init() - { - $this->permission = Auth::getInstance(); - $this->config = Config::module('grafana')->getSection('grafana'); - $this->grafanaVersion = $this->config->get('version', $this->grafanaVersion); - $this->grafanaHost = $this->config->get('host', $this->grafanaHost); - if ($this->grafanaHost == null) { - throw new ConfigurationError( - 'No Grafana host configured!' - ); - } - $this->protocol = $this->config->get('protocol', $this->protocol); - $this->enableLink = $this->config->get('enableLink', $this->enableLink); - if ($this->enableLink == "yes" && $this->permission->hasPermission('grafana/enablelink')) { - $this->usePublic = $this->config->get('usepublic', $this->usePublic); - if ($this->usePublic == "yes") { - $this->publicHost = $this->config->get('publichost', $this->publicHost); - if ($this->publicHost == null) { - throw new ConfigurationError( - 'No Grafana public host configured!' - ); - } - $this->publicProtocol = $this->config->get('publicprotocol', $this->publicProtocol); - } else { - $this->publicHost = $this->grafanaHost; - $this->publicProtocol = $this->protocol; - } - } - - // Confid needed for Grafana - $this->defaultDashboard = $this->config->get('defaultdashboard', $this->defaultDashboard); - $this->defaultdashboarduid = $this->config->get('defaultdashboarduid', null); - if (is_null($this->defaultdashboarduid)) { - throw new ConfigurationError( - 'no UID for default dashboard found!' - ); - } - $this->defaultDashboardPanelId = $this->config->get('defaultdashboardpanelid', $this->defaultDashboardPanelId); - $this->defaultOrgId = $this->config->get('defaultorgid', $this->defaultOrgId); - $this->grafanaTheme = $this->config->get('theme', $this->grafanaTheme); - $this->height = $this->config->get('height', $this->height); - $this->width = $this->config->get('width', $this->width); - - $this->accessMode = $this->config->get('accessmode', $this->accessMode); - $this->proxyTimeout = $this->config->get('proxytimeout', $this->proxyTimeout); - /** - * Read the global default timerange - */ - $this->timerange = $this->config->get('timerange', $this->timerange); - /** - * Datasource needed to regex special chars - */ - $this->dataSource = $this->config->get('datasource', $this->dataSource); - /** - * Display shadows around graph - */ - $this->shadows = $this->config->get('shadows', $this->shadows); - /** - * Name of the custom varibale to disable graph - */ - $this->custvardisable = ($this->config->get('custvardisable', $this->custvardisable)); - /** - * Name of the custom varibale for graph config - */ - $this->custvarconfig = ($this->config->get('custvarconfig', $this->custvarconfig)); - - /** - * Show some debug informations? - */ - $this->debug = ($this->config->get('debug', $this->debug)); - /** - * Verify the certificate's name against host - */ - $this->SSLVerifyHost = ($this->config->get('ssl_verifyhost', $this->SSLVerifyHost)); - /** - * Verify the peer's SSL certificate - */ - $this->SSLVerifyPeer = ($this->config->get('ssl_verifypeer', $this->SSLVerifyPeer)); - - /** - * Username & Password or token - */ - - $this->apiToken = $this->config->get('apitoken', $this->apiToken); - $this->authentication = $this->config->get('authentication'); - if ($this->apiToken == null && $this->authentication == "token") { - throw new ConfigurationError( - 'API token usage configured, but no token given!' - ); - } else { - $this->username = $this->config->get('username', $this->username); - $this->password = $this->config->get('password', $this->password); - if ($this->username != null) { - if ($this->password != null) { - $this->auth = $this->username . ":" . $this->password; - } else { - $this->auth = $this->username; - } - } else { - $this->auth = ""; - } - } - } - - private function getGraphConf($serviceName, $serviceCommand = null) - { - - $this->graphConfig = Config::module('grafana', 'graphs'); - - if ($this->graphConfig->hasSection(strtok($serviceName, - ' ')) && ($this->graphConfig->hasSection($serviceName) == false)) { - $serviceName = strtok($serviceName, ' '); - } - if ($this->graphConfig->hasSection(strtok($serviceName, - ' ')) == false && ($this->graphConfig->hasSection($serviceName) == false)) { - $serviceName = $serviceCommand; - if ($this->graphConfig->hasSection($serviceCommand) == false && $this->defaultDashboard == 'none') { - return null; - } - } - - $this->dashboard = $this->getGraphConfigOption($serviceName, 'dashboard', $this->defaultDashboard); - $this->dashboarduid = $this->getGraphConfigOption($serviceName, 'dashboarduid', $this->defaultdashboarduid); - $this->panelId = $this->getGraphConfigOption($serviceName, 'panelId', $this->defaultDashboardPanelId); - $this->orgId = $this->getGraphConfigOption($serviceName, 'orgId', $this->defaultOrgId); - $this->customVars = $this->getGraphConfigOption($serviceName, 'customVars', ''); - - if(Url::fromRequest()->hasParam('tr-from') && Url::fromRequest()->hasParam('tr-to')) { - $this->timerange = urldecode(Url::fromRequest()->getParam('tr-from')); - $this->timerangeto = urldecode(Url::fromRequest()->getParam('tr-to')); - } else { - $this->timerange = Url::fromRequest()->hasParam('timerange') ? - 'now-' . urldecode(Url::fromRequest()->getParam('timerange')) : - 'now-' . $this->getGraphConfigOption($serviceName, 'timerange', $this->timerange); - $this->timerangeto = strpos($this->timerange, '/') ? $this->timerange : $this->timerangeto; - } - - $this->height = $this->getGraphConfigOption($serviceName, 'height', $this->height); - $this->width = $this->getGraphConfigOption($serviceName, 'width', $this->width); - $this->repeatable = $this->getGraphConfigOption($serviceName, 'repeatable', $this->repeatable); - $this->numberMetrics = $this->getGraphConfigOption($serviceName, 'nmetrics', $this->numberMetrics); - - return $this; - } - - private function getGraphConfigOption($section, $option, $default = null) - { - $value = $this->graphConfig->get($section, $option, $default); - if (empty($value)) { - return $default; - } - return $value; - } - - //returns false on error, previewHTML is passed as reference - private function getMyPreviewHtml($serviceName, $hostName, &$previewHtml) - { - $imgClass = $this->shadows ? "grafana-img grafana-img-shadows" : "grafana-img"; - if ($this->accessMode == "indirectproxy") { - if ($this->object instanceof Service) { - $this->pngUrl = Url::frompath('grafana/img', array( - 'host' => rawurlencode($hostName), - 'service' => rawurlencode($serviceName), - 'panelid' => $this->panelId, - 'timerange' => urlencode($this->timerange), - 'timerangeto' => urlencode($this->timerangeto), - 'cachetime' => $this->cacheTime - )); - } else { - $this->pngUrl = Url::frompath('grafana/img', array( - 'host' => rawurlencode($hostName), - 'panelid' => $this->panelId, - 'timerange' => urlencode($this->timerange), - 'timerangeto' => urlencode($this->timerangeto), - 'cachetime' => $this->cacheTime - )); - } - $imghtml = '
%s
'; - $previewHtml = sprintf( - $imghtml, - $this->height, - $this->getView()->serverUrl(), - $this->pngUrl, - $serviceName, - $this->width, - $this->height - - ); - } elseif ($this->accessMode == "iframe") { - $iframehtml = ''; - $previewHtml = sprintf( - $iframehtml, - $this->protocol, - $this->grafanaHost, - $this->dashboarduid, - $this->dashboard, - rawurlencode($hostName), - rawurlencode($serviceName), - rawurlencode($this->object->check_command), - $this->customVars, - $this->panelId, - $this->orgId, - $this->grafanaTheme, - urlencode($this->timerange), - urlencode($this->timerangeto), - rawurlencode($serviceName), - $this->height - ); - } - return true; - } - - public function has(MonitoredObject $object) - { - if (($object instanceof Host) || ($object instanceof Service)) { - return true; - } else { - return false; - } - } - - public function getPreviewHtml(MonitoredObject $object, $report = false) - { - $this->object = $object; - // enable_perfdata = true ? || disablevar == true - if (!$this->object->process_perfdata || (( isset($this->object->customvars[$this->custvardisable]) && json_decode(strtolower($this->object->customvars[$this->custvardisable])) !== false)) ) { - return ''; - } - - if ($this->object instanceof Host) { - $this->cacheTime = $this->object->host_next_check - $this->object->host_last_check; - $serviceName = $this->object->check_command; - $hostName = $this->object->host_name; - $parameters = array( - 'host' => $this->object->host_name, - ); - $link = 'monitoring/host/show'; - } elseif ($this->object instanceof Service) { - $this->cacheTime = $this->object->service_next_check - $this->object->service_last_check; - $serviceName = $this->object->service_description; - $hostName = $this->object->host->getName(); - $parameters = array( - 'host' => $this->object->host->getName(), - 'service' => $this->object->service_description, - ); - $link = 'monitoring/service/show'; - } - - // Preserve timerange if set - $parameters['timerange'] = $this->timerange; - - if (array_key_exists($this->custvarconfig, - $this->object->customvars) && !empty($this->object->customvars[$this->custvarconfig])) { - $graphConfiguation = $this->getGraphConf($object->customvars[$this->custvarconfig]); - } else { - $graphConfiguation = $this->getGraphConf($serviceName, $object->check_command); - } - if ($graphConfiguation == null) { - return; - } - - if ($this->repeatable == "yes") { - $this->panelId = implode(',', range($this->panelId, - ($this->panelId - 1) + intval(substr_count($object->perfdata, '=') / $this->numberMetrics))); - } - - // replace special chars for graphite - if ($this->dataSource == "graphite" && $this->accessMode != "indirectproxy") { - $serviceName = Util::graphiteReplace($serviceName); - $hostName = Util::graphiteReplace($hostName); - } - - if (!empty($this->customVars)) { - // replace template to customVars from Icinga2 - $customVars = $object->fetchCustomvars()->customvars; - foreach ($customVars as $k => $v) { - $search[] = "\$$k\$"; - $replace[] = is_string($v) ? $v : null; - $this->customVars = str_replace($search, $replace, $this->customVars); - } - - // urlencodee values - $customVars = ""; - foreach (preg_split('/\&/', $this->customVars, -1, PREG_SPLIT_NO_EMPTY) as $param) { - $arr = explode("=", $param); - if (preg_match('/^\$.*\$$/', $arr[1])) { - $arr[1] = ''; - } - if ($this->dataSource == "graphite") { - $arr[1] = Util::graphiteReplace($arr[1]); - } - $customVars .= '&' . $arr[0] . '=' . rawurlencode($arr[1]); - } - $this->customVars = $customVars; - } - - $return_html = ""; - - // Hide menu if in reporting or compact mode - $menu = ""; - if ($report === false && !$this->getView()->compact) { - $timeranges = new Timeranges($parameters, $link); - $menu = $timeranges->getTimerangeMenu($this->timerange, $this->timerangeto); - } else { - $this->title = ''; - } - - foreach (explode(',', $this->panelId) as $panelid) { - - $html = ""; - $this->panelId = $panelid; - - //image value will be returned as reference - $previewHtml = ""; - $res = $this->getMyPreviewHtml($serviceName, $hostName, $previewHtml); - - //do not render URLs on error or if disabled - if (!$res || $this->enableLink == "no" || !$this->permission->hasPermission('grafana/enablelink')) { - $html .= $previewHtml; - } else { - - $html .= '%s'; - - $html = sprintf( - $html, - $this->publicProtocol, - $this->publicHost, - $this->dashboarduid, - $this->dashboard, - rawurlencode(($this->dataSource == "graphite" ? Util::graphiteReplace($hostName) : $hostName)), - rawurlencode(($this->dataSource == "graphite" ? Util::graphiteReplace($serviceName) : $serviceName)), - rawurlencode($this->object->check_command), - $this->customVars, - urlencode($this->timerange), - urlencode($this->timerangeto), - $this->orgId, - $this->panelId, - $previewHtml - ); - } - $return_html .= $html; - } - if ($this->debug && $this->permission->hasPermission('grafana/debug') && $report === false) { - $usedUrl = ""; - if ($this->accessMode == "indirectproxy" ) { - $usedUrl = $this->pngUrl; - } else { - $usedUrl = preg_replace('/.*?src\s*=\s*[\'\"](.*?)[\'\"].*/', "$1", $previewHtml); - } - if ($this->accessMode == "iframe") { - $this->height = "100%"; - } - - $return_html .= "

Performance Graph Debug

"; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - if ($this->grafanaVersion == "1") { - $return_html .= ""; - } else { - $return_html .= ""; - } - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - $return_html .= ""; - if (isset($object->customvars[$this->custvarconfig])) { - $return_html .= ""; - } - $return_html .= ""; - if ($this->accessMode == "proxy") { - $return_html .= ""; - $return_html .= ""; - } - $return_html .= "
Access mode" . $this->accessMode . "
Authentication type" . $this->authentication . "
Protocol" . $this->protocol . "
Grafana Host" . $this->grafanaHost . "
Dashboard UID" . $this->dashboarduid . "
Dashboard Store" . $this->defaultDashboardStore . "
Dashboard Name" . $this->dashboard . "
Panel ID" . $this->panelId . "
Organization ID" . $this->orgId . "
Theme" . $this->grafanaTheme . "
Timerange" . $this->timerange . "
Timerangeto" . $this->timerangeto . "
Height" . $this->height . "
Width" . $this->width . "
Custom Variables" . $this->customVars . "
Graph URL" . $usedUrl . "
Disable graph custom variable" . $this->custvardisable . "
Graph config custom variable" . $this->custvarconfig . "
" . $this->custvarconfig . "" . $object->customvars[$this->custvarconfig] . "
Shadows" . (($this->shadows) ? 'Yes' : 'No') . "
SSL Verify Peer" . (($this->SSLVerifyPeer) ? 'Yes' : 'No') . "
SSL Verify Host" . (($this->SSLVerifyHost) ? 'Yes' : 'No') . "
"; - - } - return '
' . $this->title . $menu . $return_html . '
'; - } -} diff --git a/library/Grafana/ProvidedHook/Icingadb/HostActions.php b/library/Grafana/ProvidedHook/Icingadb/HostActions.php index 78e9f6e..b981579 100644 --- a/library/Grafana/ProvidedHook/Icingadb/HostActions.php +++ b/library/Grafana/ProvidedHook/Icingadb/HostActions.php @@ -25,7 +25,7 @@ public function getActionsForObject(Host $host): array return [ new Link( t('Show all graphs'), - Url::fromPath('grafana/show', ['host' => $host->name, 'timerange' => $timerange]), + Url::fromPath('grafana/icingadbshow', ['host' => $host->name, 'timerange' => $timerange]), ['target' => '_next', 'icon' => 'gauge'] ) ]; diff --git a/library/Grafana/ProvidedHook/Icingadb/HostDetailExtension.php b/library/Grafana/ProvidedHook/Icingadb/HostDetailExtension.php index 8a99d08..85a0126 100644 --- a/library/Grafana/ProvidedHook/Icingadb/HostDetailExtension.php +++ b/library/Grafana/ProvidedHook/Icingadb/HostDetailExtension.php @@ -4,6 +4,8 @@ use Icinga\Module\Icingadb\Hook\HostDetailExtensionHook; use Icinga\Module\Icingadb\Model\Host; +use ipl\Html\Html; +use ipl\Html\HtmlString; use ipl\Html\ValidHtml; class HostDetailExtension extends HostDetailExtensionHook @@ -12,7 +14,12 @@ class HostDetailExtension extends HostDetailExtensionHook public function getHtmlForObject(Host $host): ValidHtml { - $this->object = $host; - return $this->getPreviewHtml($host); + $graphs = $this->getPreviewHtml($host); + + if (! empty($graphs)) { + return HtmlString::create($graphs); + } + + return HtmlString::create(''); } } diff --git a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php index 3a5f3e8..c774f3e 100644 --- a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php +++ b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php @@ -345,7 +345,8 @@ private function getMyPreviewHtml($serviceName, $hostName, HtmlDocument $preview public function getPreviewHtml(Model $object, $report = false) { $this->object = $object; - $this->cacheTime = round($object->state->next_check - $object->state->last_update); + //$this->cacheTime = round($object->state->next_check - $object->state->last_update); + $this->cacheTime = 0; if ($object instanceof Host) { $serviceName = $object->checkcommand_name; @@ -376,6 +377,11 @@ public function getPreviewHtml(Model $object, $report = false) $customvars = $this->getDb()->fetchPairs($varsFlat->assembleSelect()); + if ($object->perfdata_enabled == "n" || (( isset($customvars[$this->custvardisable]) && json_decode(strtolower($customvars[$this->custvardisable])) !== false)) ) { + return ''; + } + + if (array_key_exists($this->custvarconfig, $customvars) && !empty($customvars[$this->custvarconfig])) { $graphConfiguation = $this->getGraphConf($customvars[$this->custvarconfig]); @@ -758,7 +764,7 @@ public function getPreviewHtml(Model $object, $report = false) $htmlForObject = HtmlElement::create( "div", - ["class" => "icinga-module module-grafana", "style" => "display: inline-block;"] + ["class" => "icinga-module module-grafana", "style" => "display: inline-block; width: 100%"] ); $htmlForObject->add($this->title); diff --git a/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php b/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php index aaa18f0..00fa6ed 100644 --- a/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php +++ b/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php @@ -4,6 +4,8 @@ use Icinga\Module\Icingadb\Hook\ServiceDetailExtensionHook; use Icinga\Module\Icingadb\Model\Service; +use ipl\Html\Html; +use ipl\Html\HtmlString; use ipl\Html\ValidHtml; class ServiceDetailExtension extends ServiceDetailExtensionHook @@ -12,7 +14,13 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook public function getHtmlForObject(Service $service): ValidHtml { - $this->object = $service; - return $this->getPreviewHtml($service); + //$this->object = $service; + $graphs = $this->getPreviewHtml($service); + + if (! empty($graphs)) { + return HtmlString::create($graphs); + } + + return HtmlString::create(''); } } diff --git a/library/Grafana/ProvidedHook/Monitoring/HostActions.php b/library/Grafana/ProvidedHook/Monitoring/HostActions.php deleted file mode 100644 index bcbabe9..0000000 --- a/library/Grafana/ProvidedHook/Monitoring/HostActions.php +++ /dev/null @@ -1,40 +0,0 @@ -hasPermission('grafana/showall')) { - return []; - } - - $config = Config::module('grafana')->getSection('grafana'); - $timerange = $config->get('timerangeAll', $this->defaultTimerange); - $nav = new Navigation(); - $nav->addItem(new NavigationItem(t('Show all graphs'), array( - 'url' => Url::fromPath('grafana/show', array('host' => $host->getName(), 'timerange' => $timerange)), - 'target' => '_next', - 'icon' => 'gauge', - ))); - return $nav; - } -} diff --git a/library/Grafana/Web/Controller/MonitoringAwareController.php b/library/Grafana/Web/Controller/MonitoringAwareController.php deleted file mode 100644 index d810cc5..0000000 --- a/library/Grafana/Web/Controller/MonitoringAwareController.php +++ /dev/null @@ -1,19 +0,0 @@ -applyRestriction('monitoring/filter/objects', $dataView); - return $dataView; - } -} \ No newline at end of file diff --git a/library/Grafana/Web/Widget/PrintAction.php b/library/Grafana/Web/Widget/PrintAction.php index 207ee3f..080adb9 100644 --- a/library/Grafana/Web/Widget/PrintAction.php +++ b/library/Grafana/Web/Widget/PrintAction.php @@ -24,10 +24,10 @@ public function apply(Tabs $tabs) 'print', [ 'icon' => 'print', - 'target'=> '_blank', + 'target' => '_blank', 'label' => t('Print'), - 'url' => (htmlspecialchars_decode(Url::fromRequest()->getAbsoluteUrl())). '&showFullscreen', + 'url' => (htmlspecialchars_decode(Url::fromRequest()->getAbsoluteUrl())). '&showFullscreen=1', ] ); } -} \ No newline at end of file +} diff --git a/module.info b/module.info index 099561c..fd3183c 100644 --- a/module.info +++ b/module.info @@ -1,9 +1,10 @@ Name: Grafana -Version: 1.4.3 +Version: 2.0.0b Requires: - Modules: monitoring (>=2.9.0), icingadb (>=1.0.0) + Libraries: icinga-php-library (>=0.10.1) + Modules: icingadb (>=1.0.0) Description: Grafana - A perfdata visualisation module - Shows Grafana graphs for captured metrics. + Shows Grafana panels for captured metrics. This module requires: @@ -11,7 +12,7 @@ Description: Grafana - A perfdata visualisation module * InfluxDB or Graphite as datasource backend. - * PHP 7 with curl enabled (for proxy modes) + * PHP 8.1 with curl enabled (for proxy modes) Thanks for bug reporting/fixing or enhancements goes to: @@ -45,3 +46,5 @@ Description: Grafana - A perfdata visualisation module Lasse W. & Ruben M. Bernhard F. & Garrett S. + + raviks789 (IcingaDB support) diff --git a/public/css/module.less b/public/css/module.less index cda7665..f87d9ae 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -22,8 +22,6 @@ .module-grafana, .grafana-menu-navigation a { display: block; text-decoration: none; - width: 100%; - height: 100%; color: @text-color; outline: none; } @@ -36,6 +34,7 @@ } .grafana-table i.icon-clock { + vertical-align: middle; font-size: 2em; color: @icinga-blue; diff --git a/run.php b/run.php index 84156af..20c337e 100644 --- a/run.php +++ b/run.php @@ -1,7 +1,7 @@ provideHook('grapher'); -$this->provideHook('monitoring/HostActions'); +use Icinga\Module\Grafana\ProvidedHook\Icingadb\IcingadbSupport; + $this->provideHook('icingadb/HostActions'); $this->provideHook('icingadb/IcingadbSupport'); $this->provideHook('icingadb/HostDetailExtension');