Codebase list icingaweb2-module-pnp / 05d7e38
Adding upstream version 1.1.0. Signed-off-by: David Kunz <david.kunz@dknet.ch> David Kunz 5 years ago
23 changed file(s) with 1143 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 <!--- Provide a general summary of the issue in the Title above -->
1
2 <!-- Formatting tips:
3
4 GitHub supports Markdown: https://guides.github.com/features/mastering-markdown/
5 Multi-line code blocks either with three back ticks, or four space indent.
6
7 ```
8 Stacktrace ...
9 <line>
10 <line>
11 ```
12 -->
13
14 ## Expected Behavior
15 <!--- If you're describing a bug, tell us what should happen -->
16 <!--- If you're suggesting a change/improvement, tell us how it should work -->
17
18 ## Current Behavior
19 <!--- If describing a bug, tell us what happens instead of the expected behavior -->
20 <!--- If suggesting a change/improvement, explain the difference from current behavior -->
21
22 ## Possible Solution
23 <!--- Not obligatory, but suggest a fix/reason for the bug, -->
24 <!--- or ideas how to implement: the addition or change -->
25
26 ## Steps to Reproduce (for bugs)
27 <!--- Provide a link to a live example, or an unambiguous set of steps to -->
28 <!--- reproduce this bug. Include configuration, logs, etc. to reproduce, if relevant -->
29 1.
30 2.
31 3.
32 4.
33
34 ## Context
35 <!--- How has this issue affected you? What are you trying to accomplish? -->
36 <!--- Providing context helps us come up with a solution that is most useful in the real world -->
37
38 ## Your Environment
39 <!--- Include as many relevant details about the environment you experienced the problem in -->
40 * Module version (System - About):
41 * Icinga Web 2 version and modules (System - About):
42 * Icinga 2 version (`icinga2 --version`):
43 * Operating System and version:
44 * Webserver, PHP versions:
45
0 since-tag=v1.0.1
0 <markus.frosch@icinga.com> <markus.frosch@netways.de>
1 <markus.frosch@icinga.com> <markus@lazyfrosch.de>
2 <michael.friedrich@icinga.com> <michael.friedrich@netways.de>
3 <eric.lippmann@icinga.com> <eric.lippmann@netways.de>
4 <johannes.meyer@icinga.com> <johannes.meyer@netways.de>
5 <thomas.gelf@icinga.com> <thomas@gelf.net>
6 <marius.hein@icinga.com> <marius.hein@netways.de>
0 Eric Lippmann <eric.lippmann@icinga.com>
1 Johannes Meyer <johannes.meyer@icinga.com>
2 Lee Clemens <java@leeclemens.net>
3 Marius Hein <marius.hein@icinga.com>
4 Markus Frosch <markus.frosch@icinga.com>
5 Matthew Thode <mthode@mthode.org>
6 Michael Friedrich <michael.friedrich@icinga.com>
7 Mirko Nardin <mirko.nardin@gmx.net>
8 Thomas Gelf <thomas.gelf@icinga.com>
0 # Change Log
1
2 ## [v1.1.0](https://github.com/Icinga/icingaweb2-module-pnp/tree/v1.1.0) (2017-08-15)
3 [Full Changelog](https://github.com/Icinga/icingaweb2-module-pnp/compare/v1.0.0...v1.1.0)
4
5 **Implemented enhancements:**
6
7 - \[dev.icinga.com \#9894\] missing "close-Button" in pnp4nagios Module \(Icinga Web 2 Frame\) [\#14](https://github.com/Icinga/icingaweb2-module-pnp/issues/14)
8 - \[dev.icinga.com \#9797\] Close button to PNP iframe [\#12](https://github.com/Icinga/icingaweb2-module-pnp/issues/12)
9 - Improve UI and user interaction [\#28](https://github.com/Icinga/icingaweb2-module-pnp/pull/28) ([lazyfrosch](https://github.com/lazyfrosch))
10
11
12
13 \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
2
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Lesser General Public License instead.) You can apply it to
18 your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
26
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
31
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
37
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
41
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
48
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
54
55 The precise terms and conditions for copying, distribution and
56 modification follow.
57
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
70
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
77
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
85
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
88
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
93
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
96
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
101
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
112
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
122
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
127
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
132
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
136
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
140
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
147
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
153
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
164
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
170
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
178
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
187
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
195
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
208
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
213
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
224
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
227
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
235
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281 How to Apply These Terms to Your New Programs
282
283 If you develop a new program, and you want it to be of the greatest
284 possible use to the public, the best way to achieve this is to make it
285 free software which everyone can redistribute and change under these terms.
286
287 To do so, attach the following notices to the program. It is safest
288 to attach them to the start of each source file to most effectively
289 convey the exclusion of warranty; and each file should have at least
290 the "copyright" line and a pointer to where the full notice is found.
291
292 <one line to give the program's name and a brief idea of what it does.>
293 Copyright (C) <year> <name of author>
294
295 This program is free software; you can redistribute it and/or modify
296 it under the terms of the GNU General Public License as published by
297 the Free Software Foundation; either version 2 of the License, or
298 (at your option) any later version.
299
300 This program is distributed in the hope that it will be useful,
301 but WITHOUT ANY WARRANTY; without even the implied warranty of
302 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303 GNU General Public License for more details.
304
305 You should have received a copy of the GNU General Public License along
306 with this program; if not, write to the Free Software Foundation, Inc.,
307 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
308
309 Also add information on how to contact you by electronic and paper mail.
310
311 If the program is interactive, make it output a short notice like this
312 when it starts in an interactive mode:
313
314 Gnomovision version 69, Copyright (C) year name of author
315 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316 This is free software, and you are welcome to redistribute it
317 under certain conditions; type `show c' for details.
318
319 The hypothetical commands `show w' and `show c' should show the appropriate
320 parts of the General Public License. Of course, the commands you use may
321 be called something other than `show w' and `show c'; they could even be
322 mouse-clicks or menu items--whatever suits your program.
323
324 You should also get your employer (if you work as a programmer) or your
325 school, if any, to sign a "copyright disclaimer" for the program, if
326 necessary. Here is a sample; alter the names:
327
328 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329 `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
331 <signature of Ty Coon>, 1 April 1989
332 Ty Coon, President of Vice
333
334 This General Public License does not permit incorporating your program into
335 proprietary programs. If your program is a subroutine library, you may
336 consider it more useful to permit linking proprietary applications with the
337 library. If this is what you want to do, use the GNU Lesser General
338 Public License instead of this License.
0 PNP module for Icinga Web 2
1 ===========================
2
3 General Information
4 -------------------
5
6 PNP is an addon to Icinga which analyzes performance data provided by plugins
7 and stores them automatically into RRD-databases.
8
9 This module integrates PNP4Nagios into your
10 [Icinga Web 2](https://www.icinga.org/icinga/screenshots/icinga-web-2/)
11 frontend. It requires [PNP4Nagios](https://docs.pnp4nagios.org/)
12 to installed and configured.
13
14 Installation
15 ------------
16
17 Just drop this module to a folder named `pnp` in one of your Icinga Web 2 module
18 directories. Then enable it in your frontend (Configuration -> Modules -> pnp
19 -> enable) and it should work out of the box. Check the modules config tab right
20 there in case you are using a customized installation instead of standard
21 PNP4Nagios packages.
22
23 TODO
24 ----
25
26 We should also provide an easy way to integrate our authentication and
27 permission system into PNP4Nagios. This would require a small wrapper doing an
28 embedded Icinga Web 2 bootstrap in order to provide our user object and a list
29 of allowed hosts/services to PNP4Nagios.
0 # Release Workflow
1
2 Specify the release version.
3
4 ```
5 VERSION=1.1.0
6 ```
7
8 ## Issues
9
10 Check issues at https://github.com/Icinga/icingaweb2-module-pnp
11
12 ## Authors
13
14 Update the [.mailmap](.mailmap) and [AUTHORS](AUTHORS) files:
15
16 ```
17 git checkout master
18 git log --use-mailmap | grep ^Author: | cut -f2- -d' ' | sort | uniq > AUTHORS
19 ```
20
21 ## Changelog
22
23 Update the [CHANGELOG.md](CHANGELOG.md) file.
24
25 Uses [github_changelog_generator](https://github.com/skywinder/github-changelog-generator)
26
27 ```
28 export CHANGELOG_GITHUB_TOKEN=xxx
29 github_changelog_generator --future-release v$VERSION
30 ```
31
32 Check if the file has been updated correctly.
33
34 ## Git Tag
35
36 Commit these changes to the "master" branch:
37
38 ```
39 git commit -v -a -m "Release version $VERSION"
40 git push origin master
41 ```
42
43 And tag it with a signed tag:
44
45 ```
46 git tag -s -m "Version $VERSION" v$VERSION
47 ```
48
49 Push the tag.
50
51 ```
52 git push --tags
53 ```
54
55 ## GitHub Release
56
57 Create a new release for the newly created Git tag.
58 https://github.com/Icinga/icingaweb2-module-pnp/releases
0 <?php
1 /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
2
3 namespace Icinga\Module\Pnp\Controllers;
4
5 use Icinga\Web\Controller;
6 use Icinga\Module\Pnp\Forms\Config\GeneralConfigForm;
7
8 class ConfigController extends Controller
9 {
10 /**
11 * General configuration
12 */
13 public function indexAction()
14 {
15 $this->assertPermission('config/modules');
16
17 $form = new GeneralConfigForm();
18 $form->setIniConfig($this->Config());
19 $form->handleRequest();
20
21 $this->view->form = $form;
22 $this->view->tabs = $this->Module()->getConfigTabs()->activate('config');
23 }
24 }
0 <?php
1 /* Icinga Web 2 | (c) 2013-2017 Icinga Development Team | GPLv2+ */
2
3 namespace Icinga\Module\Pnp\Controllers;
4
5 use Icinga\Module\Pnp\Web\Controller;
6
7 class GraphController extends Controller
8 {
9 public function indexAction()
10 {
11 $url = $this->getRequest()->getUrl();
12 $queryString = $url->getQueryString();
13
14 $this->view->url = sprintf(
15 '%s/graph?%s',
16 $this->getBaseUrl(),
17 $queryString
18 );
19
20 $host = $this->getParam('host');
21 $service = $this->getParam('srv');
22
23 $serviceTitle = '';
24 if ($service && $service !== '_HOST_') {
25 $serviceTitle = sprintf(' | %s: %s', $this->translate('Service'), $service);
26 }
27 $this->view->title = $title = sprintf('%s: %s%s',
28 $this->translate('Host'),
29 $host,
30 $serviceTitle
31 );
32
33 $this->getTabs()->add('graph', array(
34 'label' => $title,
35 'url' => $url,
36 ))->activate('graph');
37
38 $this->setViewScript('index/iframe');
39 }
40 }
0 <?php
1 /* Icinga Web 2 | (c) 2013-2017 Icinga Development Team | GPLv2+ */
2
3 namespace Icinga\Module\Pnp\Controllers;
4
5 use Icinga\Module\Pnp\Web\Controller;
6
7 class IndexController extends Controller
8 {
9 public function indexAction()
10 {
11 $this->getTabs()->activate('pnp');
12
13 $defaultQuery = $this->Config()->get('pnp4nagios', 'default_query', 'host=.pnp-internal&srv=runtime');
14
15 $this->view->title = 'PNP';
16 $this->view->url = sprintf(
17 '%s/graph?%s',
18 $this->getBaseUrl(),
19 $defaultQuery
20 );
21
22 $this->setViewScript('index/iframe');
23 }
24 }
0 <?php
1 /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
2
3 namespace Icinga\Module\Pnp\Forms\Config;
4
5 use Icinga\Forms\ConfigForm;
6
7 class GeneralConfigForm extends ConfigForm
8 {
9 /**
10 * Initialize this form
11 */
12 public function init()
13 {
14 $this->setName('form_config_pnp4nagios_general');
15 $this->setSubmitLabel($this->translate('Save Changes'));
16 }
17
18 /**
19 * {@inheritdoc}
20 */
21 public function createElements(array $formData)
22 {
23 $this->addElement(
24 'text',
25 'pnp4nagios_config_dir',
26 array(
27 'value' => '/etc/pnp4nagios',
28 'label' => $this->translate('PNP4Nagios configuration'),
29 'description' => $this->translate('PNP4Nagios configuration path name (e.g. /etc/pnp4nagios)')
30 )
31 );
32 $this->addElement(
33 'text',
34 'pnp4nagios_base_url',
35 array(
36 'value' => '/pnp4nagios',
37 'label' => $this->translate('PNP4Nagios url'),
38 'description' => $this->translate('The base URL of your PNP4Nagios installation (e.g. /pnp4nagios)')
39 )
40 );
41
42 $this->addElement(
43 'checkbox',
44 'pnp4nagios_menu_disabled',
45 array(
46 'label' => $this->translate('Disable menu entry'),
47 'description' => $this->translate('Hide PNP from main menu')
48 )
49 );
50
51 $this->addElement(
52 'text',
53 'pnp4nagios_default_query',
54 array(
55 'value' => 'host=.pnp-internal&srv=runtime',
56 'label' => $this->translate('Index query'),
57 'description' => $this->translate('Default URL query for the index view: /pnp4nagios/graph?{query}')
58 )
59 );
60 }
61 }
0 # Icinga Web 2 - Head for multiple monitoring backends.
1 # Copyright (C) 2015 Icinga Development Team
2 # This file is distributed under the same license as Pnp Module.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4 #
5 msgid ""
6 msgstr ""
7 "Project-Id-Version: Pnp Module (1.0.0)\n"
8 "Report-Msgid-Bugs-To: dev@icinga.org\n"
9 "POT-Creation-Date: 2015-11-17 11:56+0100\n"
10 "PO-Revision-Date: 2015-11-17 12:01+0100\n"
11 "Last-Translator: Thomas Gelf <thomas@gelf.net>\n"
12 "Language: de_DE\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
17 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18 "X-Generator: Poedit 1.5.4\n"
19
20 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:224
21 msgid "25 Hours"
22 msgstr "25 Stunden"
23
24 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:223
25 msgid "4 Hours"
26 msgstr "4 Stunden"
27
28 #: /usr/local/icingaweb-modules/pnp/configuration.php:8
29 msgid "Config"
30 msgstr "Konfiguration"
31
32 #: /usr/local/icingaweb-modules/pnp/configuration.php:7
33 msgid "Configure this module"
34 msgstr "Dieses Modul konfigurieren"
35
36 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:226
37 msgid "One Month"
38 msgstr "Ein Monat"
39
40 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:225
41 msgid "One Week"
42 msgstr "Eine Woche"
43
44 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:227
45 msgid "One Year"
46 msgstr "Ein Jahr"
47
48 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:29
49 msgid "PNP4Nagios configuration"
50 msgstr "PNP4Nagios Konfiguration"
51
52 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:30
53 msgid "PNP4Nagios configuration path name (e.g. /etc/pnp4nagios)"
54 msgstr "PNP4Nagios Konfigurationspfad (z.b. /etc/pnp4nagios)"
55
56 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:38
57 msgid "PNP4Nagios url"
58 msgstr "PNP4Nagios URL"
59
60 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:16
61 msgid "Save Changes"
62 msgstr "Änderungen speichern"
63
64 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:39
65 msgid "The base URL of your PNP4Nagios installation (e.g. /pnp4nagios)"
66 msgstr "Basis-URL deiner PNP4Nagios installation (z.B. /pnp4nagios)"
67
68 #~ msgid ""
69 #~ "Configuration form is still missing in this prototype. In case your "
70 #~ "PNP4Nagios config path is not %s or your base PNP4Nagios web url differs "
71 #~ "from %s please create a config file in %s following this example:"
72 #~ msgstr ""
73 #~ "Dieser Prototyp stellt noch kein Konfigurationsformular bereit. Sollte "
74 #~ "dein PNP4Nagios Konfigurationspfad nicht %s sein oder deine PNP4Nagios "
75 #~ "URL sich von %s unterscheiden erstelle bitte unter %s eine dem folgenden "
76 #~ "Beispiel entprechende Konfigurationsdatei:"
0 # Icinga Web 2 - Head for multiple monitoring backends.
1 # Copyright (C) 2015 Icinga Development Team
2 # This file is distributed under the same license as Pnp Module.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4 #
5 msgid ""
6 msgstr ""
7 "Project-Id-Version: Pnp Module (1.0.0)\n"
8 "Report-Msgid-Bugs-To: dev@icinga.org\n"
9 "POT-Creation-Date: 2015-11-17 11:57+0100\n"
10 "PO-Revision-Date: 2015-11-17 11:59+0100\n"
11 "Last-Translator: Thomas Gelf <thomas@gelf.net>\n"
12 "Language: it_IT\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
17 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18 "X-Generator: Poedit 1.5.4\n"
19
20 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:224
21 msgid "25 Hours"
22 msgstr "25 ore"
23
24 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:223
25 msgid "4 Hours"
26 msgstr "4 ore"
27
28 #: /usr/local/icingaweb-modules/pnp/configuration.php:8
29 msgid "Config"
30 msgstr "Configurazione"
31
32 #: /usr/local/icingaweb-modules/pnp/configuration.php:7
33 msgid "Configure this module"
34 msgstr "Configura questo modulo"
35
36 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:226
37 msgid "One Month"
38 msgstr "Un mese"
39
40 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:225
41 msgid "One Week"
42 msgstr "Una settimana"
43
44 #: /usr/local/icingaweb-modules/pnp/library/Pnp/ProvidedHook/Grapher.php:227
45 msgid "One Year"
46 msgstr "Un anno"
47
48 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:29
49 msgid "PNP4Nagios configuration"
50 msgstr "Configurazione PNP4Nagios"
51
52 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:30
53 msgid "PNP4Nagios configuration path name (e.g. /etc/pnp4nagios)"
54 msgstr "Directory della configurazione PNP4Nagios (es. /etc/pnp4nagios)"
55
56 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:38
57 msgid "PNP4Nagios url"
58 msgstr "URL PNP4Nagios"
59
60 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:16
61 msgid "Save Changes"
62 msgstr "Salva modifiche"
63
64 #: /usr/local/icingaweb-modules/pnp/application/forms/Config/GeneralConfigForm.php:39
65 msgid "The base URL of your PNP4Nagios installation (e.g. /pnp4nagios)"
66 msgstr "URL di base della tua installazione PNP4Nagios (es. /pnp4nagios)"
0 <div class="controls">
1 <?= $tabs; ?>
2 </div>
3 <div class="content">
4 <?= $form; ?>
5 </div>
0 <div class="controls">
1 <?= $tabs ?>
2 </div>
3 <iframe src="<?= $this->url ?>" style="height: 99%; width:100%" frameborder="no"></iframe>
0 <?php
1
2 /** @var $this Icinga\Application\Modules\Module */
3 $this->provideConfigTab('config', array(
4 'title' => $this->translate('Configure this module'),
5 'label' => $this->translate('Config'),
6 'url' => 'config'
7 ));
8
9
10 $menuDisabled = $this->getConfig()->get('pnp4nagios', 'menu_disabled');
11 if (! $menuDisabled) {
12 /** @var \Icinga\Web\Navigation\NavigationItem $section */
13 $section = $this->menuSection('pnp');
14 $section->setLabel('PNP')
15 ->setUrl('pnp')
16 ->setIcon('chart-line')
17 ->setPriority(50);
18 }
0 <?php
1
2 namespace Icinga\Module\Pnp\ProvidedHook;
3
4 use Icinga\Application\Config;
5 use Icinga\Exception\ConfigurationError;
6 use Icinga\Application\Hook\GrapherHook;
7 use Icinga\Module\Monitoring\Object\MonitoredObject;
8 use Icinga\Module\Monitoring\Object\Host;
9 use Icinga\Module\Monitoring\Object\Service;
10 use Icinga\Web\Url;
11
12 class Grapher extends GrapherHook
13 {
14 protected $hasPreviews = true;
15
16 protected $pnpConfig;
17
18 protected $pnpViews;
19
20 protected $configDir = '/etc/pnp4nagios';
21
22 protected $baseUrl = '/pnp4nagios';
23
24 protected function init()
25 {
26 $cfg = Config::module('pnp')->getSection('pnp4nagios');
27 $this->configDir = rtrim($cfg->get('config_dir', $this->configDir), '/');
28 $this->baseUrl = rtrim($cfg->get('base_url', $this->baseUrl), '/');
29 $this->readPnpConfig();
30 }
31
32 public function has(MonitoredObject $object)
33 {
34 if ($object instanceof Host) {
35 $service = '_HOST_';
36 } elseif ($object instanceof Service) {
37 $service = $object->service_description;
38 } else {
39 return false;
40 }
41
42 $host = $object->host_name;
43 return is_file($this->getXmlFilename($host, $service));
44 }
45
46 public function getPreviewHtml(MonitoredObject $object)
47 {
48 if (! $object->process_perfdata) {
49 return '';
50 }
51
52 // Skip preview images when missing, for local installations only
53 if (false === strpos($this->baseUrl, '://') && ! $this->has($object)) {
54 return '';
55 }
56
57 if ($object instanceof Host) {
58 $service = '_HOST_';
59 } elseif ($object instanceof Service) {
60 $service = $object->service_description;
61 } else {
62 return '';
63 }
64
65 $host = $object->host_name;
66
67 $html = '<table style="width: 100%; max-width: 40em; text-align: center;'
68 . ' font-size: 0.8em; line-height: 0.8em; table-layout: fixed">'
69 . "\n <tr>\n";
70 $viewKeys = array_reverse(array_keys($this->pnpViews));
71 foreach ($viewKeys as $view) {
72 $html .= '<th>' . htmlspecialchars($this->getViewName($view)) . "</th>\n";
73 }
74 $html .= " </tr>\n <tr>\n";
75 foreach ($viewKeys as $view) {
76 $html .= ' <td style="border-left: 1px solid #555; padding-right: 3px">'
77 . $this->getPreviewImg($host, $service, $view)
78 . "</td>\n";
79 }
80 $html .= "</tr></table>\n";
81 return $html;
82 }
83
84 // Currently unused, but would work fine. This is for tiny preview images
85 // in list views
86 public function getSmallPreviewImage($host, $service = null)
87 {
88 if ($service === null) {
89 $service = '_HOST_';
90 }
91
92 return sprintf(
93 '<img src="%s/image?host=%s&srv=%s&view=0&source=0&h=20&w=50" alt="" style="float: right" />',
94 $this->baseUrl,
95 urlencode($this->pnpClean($host)),
96 urlencode($this->pnpClean($service))
97 );
98 }
99
100 private function listAdditionalConfigFiles()
101 {
102 $files = array();
103 $base = $this->configDir . '/config';
104
105 $file = $base . '_local.php';
106 if (file_exists($file) && is_readable($file)) {
107 $files[] = $file;
108 }
109
110 $confd = $base . '.d';
111 if (is_dir($confd) && is_readable($confd)) {
112 $dh = opendir($confd);
113 while ($file === readdir($dh)) {
114 if ($file[0] === '.') continue;
115 if (substr($file, -4) !== '.php') continue;
116
117 $filename = $confd . '/' . $file;
118 if (is_file($filename) && is_readable($filename)) {
119 $files[] = $filename;
120 }
121 }
122
123 closedir($dh);
124 }
125
126 return $files;
127 }
128
129 // This reads the PNP4Nagios config and makes it's $conf available
130 private function readPnpConfig()
131 {
132 $file = $this->configDir . '/config.php';
133
134 if (! is_readable($file)) {
135 throw new ConfigurationError(
136 sprintf(
137 'Cannot read PNP4Nagios-Web config file "%s"',
138 $file
139 )
140 );
141 }
142 if (! include($file)) {
143 throw new ConfigurationError(
144 sprintf(
145 'Including PNP4Nagios-Web config "%s" failed',
146 $file
147 )
148 );
149 }
150
151 if (! isset($views)) {
152 $views = array();
153 }
154
155 foreach ($this->listAdditionalConfigFiles() as $file) {
156 $oldViews = $views;
157 include $file;
158 if (empty($views)) {
159 $views = $oldViews;
160 }
161 }
162
163 if (! isset($conf) || ! is_array($conf)) {
164 throw new ConfigurationError(
165 sprintf(
166 'There is no $conf in your PNP4Nagios config file "%s"',
167 $file
168 )
169 );
170 }
171
172 if (! isset($views) || ! is_array($views)) {
173 throw new ConfigurationError(
174 sprintf(
175 'There is no $views array in your PNP4Nagios config file "%s"',
176 $file
177 )
178 );
179 }
180
181 if (! array_key_exists('rrdbase', $conf)) {
182 throw new ConfigurationError(
183 sprintf(
184 'There is no rrdbase in your PNP4Nagios config file "%s"',
185 $file
186 )
187 );
188 }
189 $this->pnpConfig = $conf;
190 $this->pnpViews = $views;
191 return $this;
192 }
193
194 // pnp_Core::clean
195 private function pnpClean($string)
196 {
197 if ($string === false) {
198 return null;
199 }
200 return preg_replace('~[ :/\\\]~', '_', $string);
201 }
202
203 private function getBasePath($host, $service)
204 {
205 if ($service === null) {
206 $service = '_HOST_';
207 }
208 return rtrim($this->pnpConfig['rrdbase'], '/')
209 . '/' . $this->pnpClean($host) . '/'
210 . $this->pnpClean($service);
211 }
212
213 private function getRrdFilename($host, $service)
214 {
215 return $this->getBasePath($host, $service) . '.rrd';
216 }
217
218 private function getXmlFilename($host, $service)
219 {
220 return $this->getBasePath($host, $service) . '.xml';
221 }
222
223 private function getPreviewImg($host, $service, $view)
224 {
225 $viewName = $this->getViewName($view);
226
227 $host = $this->pnpClean($host);
228 $service = $this->pnpClean($service);
229
230 $title = $service === '_HOST_' ? sprintf(
231 '%s, %s', $host, $viewName
232 ) : sprintf(
233 '%s on %s, %s', $service, $host, $viewName
234 );
235
236 $url = Url::fromPath('pnp/graph', array(
237 'host' => $this->pnpClean($host),
238 'srv' => $this->pnpClean($service),
239 'view' => $view
240 ));
241 $imgUrl = sprintf(
242 '%s/image?host=%s&srv=%s&view=%d&source=0&w=120&h=30',
243 $this->baseUrl,
244 urlencode($this->pnpClean($host)),
245 urlencode($this->pnpClean($service)),
246 $view
247 );
248
249 $html = '<a href="%s" title="%s"><img src="%s" alt="%s" width="100%%" height="30" /></a>';
250
251 return sprintf(
252 $html,
253 $url,
254 htmlspecialchars($title),
255 $imgUrl,
256 htmlspecialchars(mt('pnp', 'Loading') . '...')
257 );
258 }
259
260 protected function getViewName($view)
261 {
262 return mt('pnp4nagios', $this->pnpViews[$view]['title']);
263 }
264
265 private function unusedFunctionAllowingToTranslateForeignStrings()
266 {
267 mt('pnp4nagios', '4 Hours');
268 mt('pnp4nagios', '25 Hours');
269 mt('pnp4nagios', 'One Week');
270 mt('pnp4nagios', 'One Month');
271 mt('pnp4nagios', 'One Year');
272 }
273 }
0 <?php
1
2 namespace Icinga\Module\Pnp\Web;
3
4 use Icinga\Web\Controller as IcingaController;
5
6 class Controller extends IcingaController
7 {
8 public function init()
9 {
10 $this->getTabs()->add('pnp', array(
11 'label' => $this->translate('PNP'),
12 'url' => 'pnp',
13 ));
14 }
15
16 protected function setViewScript($name)
17 {
18 $this->_helper->viewRenderer->setNoController(true);
19 $this->_helper->viewRenderer->setScriptAction($name);
20 }
21
22 protected function getBaseUrl()
23 {
24 return rtrim($this->Config()->get('pnp4nagios', 'base_url', '/pnp4nagios'), '/');
25 }
26 }
0 Name: PNP4Nagios
1 Version: 1.0.1
2 Depends: monitoring>=2.1.0
3 Description: Timeseries grapher integration for PNP4Nagios
4 PNP is an addon to Icinga or Nagios which analyzes performance data
5 provided by plugins and stores them automatically into RRD-database.
6
7 This module requires PNP4Nagios to be fully configured and installed.
0 <?php
1
2 $this->provideHook('grapher');