Git Product home page Git Product logo

monitoring-tt's Introduction

MonTT - Generate Monitoring Config with Template Toolkit

Did you ever want to write sophisticated Nagios/Naemon config files using the power of template toolkit? Basically this is a config preprocesseor.

Requirements

You will need

  • Perl

  • 'Template' module from CPAN

Getting Started

The input folder(s) should contain some templates and a source of hosts and contacts. Then all will be put together into a clean and maintainable nagios configuration.

The input folder looks like a nagios config folder but you are allowed to use Template Toolkit Syntax.

For example:

input/
|-- cgi.cfg
|-- conf.d
|   |-- apps                      # will be processed for every host
|   |   `-- apache.cfg            # will be processed for every host with app tag apache
|   |-- contacts                  # will be processed for every contact
|   |-- contacts.cfg
|   `-- hosts
|       |-- linux                 # every host of type linux
|       |   |-- centos.cfg        # every host of type linux with tag centos
|       |   `-- debian
|       |       |-- squeeze.cfg   # every host of type linux with tags debian and squeeze
|       |       `-- wheezy.cfg
|       `-- switch.cfg
|-- nagios.cfg
|-- resource.cfg
|-- static                        # static files will just be copied into destination folder
|   `-- conf.d
|       |-- commands.cfg
|       `-- timeperiods.cfg
|-- hooks                         # pre/post hooks
`-- post_process*                 # scripts will be run after processing is finished

All files are nagios configuration files, but you may use template toolkit syntax to add some magic to those files. Any folder below conf.d except 'apps', 'contacts' and 'hosts' will be processed only once. The 'apps' and 'hosts' folder will be processed for every host, the 'contact' folder for every contact.

then run the montt processor:

%> ./montt input/ output/

The processor won’t overwrite existing files, so export the new config into a new empty folder and move files afterwards. You can automate this step with hooks.

Examples

For now the only examples are the tests folder below t/data.

Hooks

Hooks are scripts which are run at certain points of the export procedure. Hooks have to be executable and have to be placed in a hook folder below the input directory.

All hooks will be run with a comma seperated list of input folders as argument.

ex.:

 inputfolder1/hooks/pre inputfolder1,inputfolder2

pre

The 'pre' hook is run before the export.

post

The 'post' hook is run after the export.

Post Processing

Post Processor can be any script which matches post_process* in any of the input folders.

All scripts will be run with a the output folders as argument.

ex.:

 inputfolder1/post_process.pl outputfolder

monitoring-tt's People

Contributors

manwar avatar sni avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

manwar

monitoring-tt's Issues

System perl used in tests

The test suite may fail, looking like this:

#   Failed test 'exit code: 2 == 0'
#   at t/TestUtils.pm line 59.
# command failed with rc: 2 - 

#   Failed test 'stdout like /\[INFO\]\ done/'
#   at t/TestUtils.pm line 65.
#                   ''
#     doesn't match '/\[INFO\]\ done/'
# 
# cmd: './bin/montt -v t/data/200-basic/in /run/user/1023/cpansmoker/2016092703/1UYJDtIFYv' failed

#   Failed test 'stderr like /^\s*$/'
#   at t/TestUtils.pm line 79.
#                   'Can't locate Template.pm in @INC (you may need to install the Template module) (@INC contains: /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/inc /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/blib/lib /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/blib/arch /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/blib/lib/Monitoring/TT.pm line 8.
# BEGIN failed--compilation aborted at /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/blib/lib/Monitoring/TT.pm line 8.
# Compilation failed in require at /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/bin/montt line 5.
# BEGIN failed--compilation aborted at /tmpfs/.cpan-build-cpansand/2016092709/Monitoring-TT-1.0.0-0/bin/montt line 5.
# '
#     doesn't match '/^\s*$/'
# 
# cmd: './bin/montt -v t/data/200-basic/in /run/user/1023/cpansmoker/2016092703/1UYJDtIFYv' failed

#   Failed test 'exit code: 1 == 0'
#   at t/TestUtils.pm line 59.
# command failed with rc: 1 - Nur in t/data/200-basic/out: conf.d.
# Looks like you failed 4 tests of 12.
t/200-basic.t .................. 
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/12 subtests 

The @INC path looks like the system perl is used here, which was not the perl used for the build and running the test. Usually this kind of error can be fixed by using $^X when calling a perl script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.