Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Icinga Camp | Berlin | 7th of March 2017
Icinga Web 2
How to Write Modules
Icinga Web 2.4.1
released on Jan 20, 2017
• Send commands over the Icinga 2 API
• SSL support for MySQL resources
• Export detail views to JSON and CSV
• Change pas...
• Monitoring action bar
• Announce banner
• SELinux policy
• Forked Zend Framework 1
How to Write Modules
• Should I? Why?
• Open Source
• Great community
• It’s straight forward
• Icinga Web 2 is stable, future-proof and
easy to understand
• No deep knowledge of PHP, HTML, CS...
• Lessons learned from Icinga-web 1.x
• Keep framework overhead at a minimum
• Keep it simple
• No XML
/bin/rm
• Simple
• Reliable
• Performant
• Convention over configuration
• Put things in the right place rather than
having to configure where things are
• Reasona...
• Zend Framework 1.x
• jQuery version 1 and 2
• HTMLPurifier, JShrink, Parsedown,
dompdf, lessphp
• Where to start?
• Install Icinga Web 2
• Extend the module path
• Give the module a name
• Keep it simple
• Reflect what it does
• Module name used in PHP
Namespaces, URLs and paths in t...
• Create and activate a new module
• mkdir -p /usr/share/icingaweb2-
modules/showcase
• icingacli module list installed
• ...
• Module meta information in module.info
CLI Commands
• Icinga CLI is designed to offer all
application logic of Web 2 and its
modules also in the CLI
• Helps to provide cronjo...
• Just create a file with the name of the
command in application/clicommands
application/clicommands/SayCommand.php
icingacli <module> <command> <action>
icingacli showcase say something
• Namespaces help to encapsulate modules
• Every modules has its own namespace
built from its name:
IcingaModule<module>
•...
• Document your code
• CLI help is generated from
documentation
• Get help with --help
• Successful actions return exit code 0
• Erroneous actions print readable error
messages because all exceptions in CLI
ar...
CLI Parameter Handling
• Standalone and named parameters
• Default values
• Instance of IcingaCliParams available
in $this->params
Bring it to the Web
• MVC
• Available actions in controllers
• View scripts for output and presentation
• Library code as “model”
• Every action in a controller is automatically
a route in Web 2
icingaweb2/<module>/<controller>/<action>
• Let‘s create a controller
application/controllers/GinController.php
https://…/icingaweb2/showcase/gin/flavors
• Create the view script
• One directory per controller
• One view script per action
application/views/scripts/gin/flavors...
• Automatic borders
• Scrollable “content”
• Fixed “controls” for header elements
Tab Navigation
Menu Entries
• Users may add their own menu entries
• Modules provide menu entries
• configuration.php in the base directory of
the mod...
Dashboards
• Create own dashboard
• Or extend existing ones
• configuration.php
• Hide “controls” in dashboards
• Enable autorefresh with one single
function call in the action that should
auto refresh
Styles
• public/css/module.less
• LESS extends CSS
• Just use CSS if you want
• Module styles are isolated
Feed the View with Data
• Set data in controllers with
$this->view->key = value;
• Use data in views with
$this->key or
$key
Translation
• PHP: $this->translate(‘Translate Me’);
• icingacli module enable translation
• icingacli translation refresh module
shwo...
Configuration
• /etc/icingaweb2/modules/<module>/
• $this->Config(<file>)
• Default file is config.ini
• Available in Web and CLI
[section]
key = value
$this->Config()->get(‘key’);
$this->Config()->get(‘nokey’, ‘default-value’)
Vendor CSS and JS Files
www.icinga.org
dev.icinga.org
git.icinga.org
Thank You!
@icinga
/icinga
+icinga
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules
Nächste SlideShare
Wird geladen in …5
×

von

Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 1 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 2 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 3 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 4 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 5 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 6 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 7 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 8 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 9 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 10 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 11 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 12 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 13 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 14 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 15 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 16 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 17 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 18 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 19 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 20 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 21 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 22 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 23 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 24 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 25 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 26 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 27 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 28 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 29 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 30 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 31 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 32 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 33 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 34 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 35 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 36 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 37 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 38 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 39 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 40 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 41 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 42 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 43 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 44 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 45 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 46 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 47 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 48 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 49 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 50 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 51 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 52 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 53 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 54 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 55 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 56 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 57 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 58 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 59 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 60 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 61 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 62 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 63 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 64 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 65 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 66 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 67 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 68 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 69 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 70 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 71 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 72 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 73 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 74 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 75 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 76 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 77 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 78 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 79 Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules Slide 80
Nächste SlideShare
Icinga Camp Berlin 2017 - Welcome & State of Icinga
Weiter
Herunterladen, um offline zu lesen und im Vollbildmodus anzuzeigen.

3 Gefällt mir

Teilen

Herunterladen, um offline zu lesen

Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules

Herunterladen, um offline zu lesen

Talk by Eric Lippmann

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Icinga Camp Berlin 2017 - Icinga Web 2 - How to Write Modules

  1. 1. Icinga Camp | Berlin | 7th of March 2017 Icinga Web 2 How to Write Modules
  2. 2. Icinga Web 2.4.1 released on Jan 20, 2017
  3. 3. • Send commands over the Icinga 2 API • SSL support for MySQL resources • Export detail views to JSON and CSV • Change password for DB users
  4. 4. • Monitoring action bar • Announce banner • SELinux policy • Forked Zend Framework 1
  5. 5. How to Write Modules
  6. 6. • Should I? Why? • Open Source • Great community
  7. 7. • It’s straight forward • Icinga Web 2 is stable, future-proof and easy to understand • No deep knowledge of PHP, HTML, CSS and JS required • So, why not?
  8. 8. • Lessons learned from Icinga-web 1.x • Keep framework overhead at a minimum • Keep it simple • No XML
  9. 9. /bin/rm
  10. 10. • Simple • Reliable • Performant
  11. 11. • Convention over configuration • Put things in the right place rather than having to configure where things are • Reasonable defaults • INI config files
  12. 12. • Zend Framework 1.x • jQuery version 1 and 2 • HTMLPurifier, JShrink, Parsedown, dompdf, lessphp
  13. 13. • Where to start? • Install Icinga Web 2 • Extend the module path
  14. 14. • Give the module a name • Keep it simple • Reflect what it does • Module name used in PHP Namespaces, URLs and paths in the file system
  15. 15. • Create and activate a new module • mkdir -p /usr/share/icingaweb2- modules/showcase • icingacli module list installed • icingacli module enable showcase
  16. 16. • Module meta information in module.info
  17. 17. CLI Commands
  18. 18. • Icinga CLI is designed to offer all application logic of Web 2 and its modules also in the CLI • Helps to provide cronjobs, plugins, tools and even small services • Bash autocompletion
  19. 19. • Just create a file with the name of the command in application/clicommands
  20. 20. application/clicommands/SayCommand.php
  21. 21. icingacli <module> <command> <action> icingacli showcase say something
  22. 22. • Namespaces help to encapsulate modules • Every modules has its own namespace built from its name: IcingaModule<module> • The namespace for CLI commands is Clicommands
  23. 23. • Document your code • CLI help is generated from documentation • Get help with --help
  24. 24. • Successful actions return exit code 0 • Erroneous actions print readable error messages because all exceptions in CLI are caught • In this case the exit code is always 1 • Get full stacktrace with --trace
  25. 25. CLI Parameter Handling
  26. 26. • Standalone and named parameters • Default values • Instance of IcingaCliParams available in $this->params
  27. 27. Bring it to the Web
  28. 28. • MVC • Available actions in controllers • View scripts for output and presentation • Library code as “model”
  29. 29. • Every action in a controller is automatically a route in Web 2 icingaweb2/<module>/<controller>/<action>
  30. 30. • Let‘s create a controller application/controllers/GinController.php
  31. 31. https://…/icingaweb2/showcase/gin/flavors
  32. 32. • Create the view script • One directory per controller • One view script per action application/views/scripts/gin/flavors.phtml
  33. 33. • Automatic borders • Scrollable “content” • Fixed “controls” for header elements
  34. 34. Tab Navigation
  35. 35. Menu Entries
  36. 36. • Users may add their own menu entries • Modules provide menu entries • configuration.php in the base directory of the module
  37. 37. Dashboards
  38. 38. • Create own dashboard • Or extend existing ones • configuration.php
  39. 39. • Hide “controls” in dashboards
  40. 40. • Enable autorefresh with one single function call in the action that should auto refresh
  41. 41. Styles
  42. 42. • public/css/module.less • LESS extends CSS • Just use CSS if you want • Module styles are isolated
  43. 43. Feed the View with Data
  44. 44. • Set data in controllers with $this->view->key = value; • Use data in views with $this->key or $key
  45. 45. Translation
  46. 46. • PHP: $this->translate(‘Translate Me’); • icingacli module enable translation • icingacli translation refresh module shwocase de_DE • Use Poedit • icingacli translation compile module showcase de_DE
  47. 47. Configuration
  48. 48. • /etc/icingaweb2/modules/<module>/ • $this->Config(<file>) • Default file is config.ini • Available in Web and CLI
  49. 49. [section] key = value $this->Config()->get(‘key’); $this->Config()->get(‘nokey’, ‘default-value’)
  50. 50. Vendor CSS and JS Files
  51. 51. www.icinga.org dev.icinga.org git.icinga.org Thank You! @icinga /icinga +icinga
  • KatherineWatts9

    Nov. 23, 2021
  • AhmedAlhebsi2

    Apr. 13, 2017
  • DirkRder

    Mar. 14, 2017

Talk by Eric Lippmann

Aufrufe

Aufrufe insgesamt

4.031

Auf Slideshare

0

Aus Einbettungen

0

Anzahl der Einbettungen

2.517

Befehle

Downloads

17

Geteilt

0

Kommentare

0

Likes

3

×