Friday, June 17, 2011

ninja op5 nagios alternative

Ninja

The Ninja project is an attempt to develop an alternative Nagios GUI with the aim of being the most useful Open Source web frontend for Nagios. The project is also included in op5s network monitoring product op5 Monitor.
Brief description of Ninja
  • Create New PHP versions of the existing .cgi's with effort put into removing “obvious problems” such as
    • Lack of good search and filtering. Today's host search can be so much better
    • Scalability. Ways to present large data sets, host lists, service lists, etc
  • Multi language support (gettext)
  • Template/skin support for easy customization of look and feel
  • Support for several databases
  • Session based authentication with support for common auth protocols
    https://wiki.op5.org/
    https://wiki.op5.org/ninja:docs:quickstart-ubuntu

    Ninja - Nagios is Now Just Awesome is a modern web gui for Nagios
       2
       3 Requirements
       4 ------------
       5 Ninja requieres the following softwares to be installed:
       6
       7 php, php-pdo and php-cli 5.1.6+
       8 MySQL 5+ (4 might also work but is not tested)
       9 Nagios 3.0.x+ (needs to run on the same server)
      10 Merlin
      11
      12
      13 Installation
      14 ------------
      15 Ninja is a web application mainly written in php so in short words the
      16 installation goes something like this
      17
      18 1. download, untar and put ninja in some nice place on your server
      19 2. configure your webserver
      20 3. configure ninja with basic info such as where it's installed and where
      21    the database is located.
      22 done :)
      23
      24 Here is a longer and a bit more exact version on how to install it
      25
      26 1. Make sure that all Ninja requirements are installed. In particular Merlin
      27    which is a Nagios module responsible for maintaining a database with Nagios
      28    status, similar to the objects.cache file. For more info about Merlin,
      29    check out http://www.op5.org/
      30
      31 2. download ninja from http://www.op5.org/
      32
      33 3. untar
      34 tar zxvf ninja-x.x.x.tar.gz
      35
      36 4. copy the ninja dir to a suitable location. Will vary between installations.
      37 mkdir /usr/local/nagios/addons/
      38 cp -a ninja /usr/local/nagios/addons/
      39
      40 5. Configure your webserver. We provide an example config file for apache
      41    located at ninja/op5build/ninja.httpd-conf. The example below works for
      42    CentOS and RedHat
      43 vim ninja/op5build/ninja.httpd-conf
      44 cp ninja/op5build/ninja.httpd-conf /etc/httpd/conf.d
      45 service httpd restart
      46
      47 6. Configure Ninja. An example config file exists in ninja/op5build/index.php,
      48    edit the $ninja_base variable and copy it to the ninja root dir. There are
      49    more configuration files located in ninja/application/config/ but you should
      50    normally not require to edit them. Take a look at database.php if you
      51    modified any of the default database settings when installing Merlin.
      52
      53 vim ninja/op5build/index.php
      54
      55   $ninja_base = '/usr/local/nagios/addons/ninja';
      56
      57 cp ninja/op5build/index.php ninja/
      58
      59 7. Setup the db tables required for Ninja by executing
      60
      61 ninja/install_scripts/ninja_db_init.sh
      62
      63    This script will also try to import any existing htpasswd users from your
      64    Nagios config.
      65
      66 8. Point your browser to https://yourip/ninja and try your installation
      67
      68 congratulations! you now (hopfully) have a working Ninja installation
      69
      70 Questions, feedback, patches etc are best sent to op5-users@lists.op5.com
      71 subscription (http://lists.op5.com/mailman/listinfo/op5-users) is needed
      72 to post. Check out www.op5.org for more info about Ninja.
    http://www.op5.org/community/plugin-inventory/op5-projects/ninja


    Merlin

    The Merlin project, or Module for Effortless Redundancy and Loadbalancing In Nagios, for setting up distributed Nagios installations and allowing Nagios processes to exchange information directly.

       1 Requirements
       2 ------------
       3 Merlin requires Nagios 3.2.4 or later.
       4 Since (at the time of this writing), Nagios 3.2.4 is not yet
       5 released, you'll have to use the latest sources from CVS head
       6 or cloned from git, using the following command:
       7
       8    git clone git://git.op5.org/nagios.git
       9
      10
      11 For running merlin with its default configuration, you'll need
      12 to have libdbi-dbd-mysql and all of its dependencies (generally
      13 libdbi-drivers, libdbi and mysql-libs) installed.
      14
      15 You will ofcourse also need an sql database supported by libdbi
      16 (refer to the libdbi documentation for further information about
      17 supported databases), as well as a Nagios installation that the
      18 merlin module can plug in to. The import script is currently
      19 limited to MySQL only, so that's currently the only database
      20 supported.
      21
      22 For the import script to work, you need to have php-cli and
      23 php-mysql installed. They may be named differently in your
      24 distribution, but I'm sure you get the idea.
      25
      26 The install script requires administration privileges to create
      27 its installation directories and copy files there, as well as
      28 sql administration privileges in order to create the database
      29 that merlin will populate for you.
      30
      31 GNU sed 4.0.9 or better is required for the install script to
      32 be able to modify your nagios configuration files.
      33
      34
      35 Compilation
      36 -----------
      37 Merlin doesn't support autoconf (and I'm reluctant to take
      38 patches that makes it do so). You'll need to have libdbi-devel
      39 installed. If it's not in a default location, please amend the
      40 CPPFLAGS manually while running make, like so:
      41
      42      make CPPFLAGS="-I/usr/local/include"
      43
      44
      45 Installation
      46 ------------
      47 There is an install-script provided here which will attempt to
      48 make all the necessary modifications to your nagios.cfg file
      49 as well as installing merlin on your system. Please run
      50
      51   sh install-merlin.sh --dest-dir=/path/to/merlin \
      52            --nagios-cfg=/path/to/nagios.cfg \
      53                    --db-type=mysql --db-user=merlin --db-pass=merlin \
      54                    --db-name=merlin
      55
      56 Note that the install-merlin.sh script requires write access to
      57 whatever directory you choose as --dest-dir, as well as access
      58 to write to your nagios.cfg file.
      59 Also note that the install script can only handle setting up
      60 mysql databases at the moment. Patches welcome to make it also
      61 handle postgresql and whatever else you feel there is a need for.
      62 If a different database type is selected, the install script will
      63 still work, but it will not create the database for you.
      64
      65 Configuration
      66 -------------
      67 Configuring merlin is pretty straight-forward. Check the example.conf
      68 file that accompanies this release and you'll see most of the common
      69 examples available.
      70
      71 The syntax is fairly standard, being made up of a key without
      72 spaces and a value containing arbitrary characters (although no
      73 semi-colons). A configuration statement is terminated either by a
      74 newline or a semi-colon. A configuration statement starting with a
      75 hash-character (#) is considered a comment. Thus,
      76
      77   key = value; # comment
      78
      79 makes "key" the key, "value" the value, terminated by the semi-colon,
      80 and "# comment" all of the comment.
      81 Leading and trailing whitespace is ignored.
      82
      83 The thing it doesn't really cover very well is how to configure masters,
      84 peers and pollers, which is described more in-depth here.
      85
      86 In order to set up a loadbalanced system (ie, 2 or more peers), all
      87 you need to do is add a section similar to the following to your
      88 merlin configuration files on your merlin-empowered Nagios systems.
      89 Let's pretend we have "nagios1" and "nagios2" in the network and
      90 you wish for them to be set up in loadbalanced/redundancy mode.
      91 nagios1 has 192.168.1.1 as IP. nagios2 has 192.168.1.2. Both use
      92 port 15551 (the default).
      93
      94 On nagios1, add the following section to your merlin.conf file:
      95   --------------
      96   peer nagios2 {
      97     address = 192.168.1.2;
      98     port = 15551; # optional, since 15551 is the default
      99   }
     100   --------------
     101
     102 On nagios2, add the following section to your merlin.conf file:
     103   --------------
     104   peer nagios1 {
     105     address = 192.168.1.1;
     106     port = 15551; # optional, since 15551 is the default
     107   }
     108   --------------
     109
     110 Assuming nagios2 is a poller-node instead, responsible for checking
     111 hosts in germany, you need to create a hostgroup in Nagios containing
     112 all the hosts in germany that you want nagios2 to check for you. Let's
     113 assume you call that hostgroup "germany-hosts". Then you need to add
     114 following sections to your merlin.conf files.
     115
     116 On nagios1 (the "master" server), add the following section:
     117   --------------
     118   poller nagios2 {
     119     address = 192.168.1.2;
     120         port = 15551;
     121         hostgroup = germany-hosts; # name of the hostgroup containing all
     122                                    # the hosts you want this poller to check
     123   }
     124   --------------
     125
     126 On nagios2 (the slave server), add the following section:
     127   --------------
     128   master nagios1 {
     129     address = 192.168.1.1;
     130         port = 15551;
     131   }
     132   --------------
     133
     134 Note that these configuration sections need to be in the base section
     135 of the configuration file. They must *not* be inside the daemon section.
     136 This is because the master server will disable checks for all its pollers
     137 once those pollers connect, and therefore it needs to read the list of
     138 available nodes at configuration time.
     139
     140 A merlin node can have up to 65534 neighbours (assuming your system
     141 lets a single program have that many file-descriptors open). A neighbour
     142 is, in merlin terminology, a node that merlin connects to directly, so
     143 you can build arbitrarily large networks by just specifying multiple
     144 tiers of pollers.
     145
     146 A single merlin node can have pollers, peers and master nodes in its own
     147 neighbourhood. As such, a single merlin node can, at the same time be
     148 a peer (to its peers), a master (to its pollers) and a poller (to its
     149 masters). One section has to be added to the merlin.conf file for each
     150 of the hosts in its neighbourhood. The section must contain the
     151 address of the neighbour, the port the neighbour is listening to
     152 (unless it's the default port 15551) and, if the neighbour is a poller,
     153 the section *must* contain a hostgroup statement declaring which
     154 hostgroup the poller is responsible for checking.



    Download and extract the code

    Get the latest version of Ninja (ninja-1.0.1.tar.gz in my case) from the project page.
    Extract the tar file and move Ninja to a folder of choice:
    tar -zxvf ninja-1.0.1.tar.gz
    
    # become root (or type sudo before all the following commands)
    sudo -s
    cp -a ninja-1.0.1 /usr/local/nagios/addons/ninja
    cd /usr/local/nagios/addons/ninja
    

    Configure Apache

    Copy the example config file to your Apache configuration:
    cp op5build/ninja.httpd-conf /etc/apache2/conf.d/ninja.conf
    
    And edit /etc/apache2/conf.d/ninja.conf to have the correct path for Ninja:
    
            LoadModule alias_module modules/mod_alias.so
    
    
    Alias /ninja /usr/local/nagios/addons/ninja
    
            Order allow,deny
            Allow from all
            DirectoryIndex index.php
    
    
    Restart Apache:
    /etc/init.d/apache2 restart
    

    Modify and run the install scripts

    Edit install_scripts/auth_import_mysql.php to have the correct paths for Merlin and Nagios configuration files:
    ...
    private $merlin_path = '/usr/local/nagios/addons/merlin';       # where to find merlin files
    private $nagios_cfg_path = '/usr/local/nagios/etc';             # path to nagios cfg files
    ...
    
    You will also need to modify install_scripts/auth_import_mysql.php to use the correct path to awk using this line:
    sed -i 's/\/bin\/awk/\/usr\/bin\/awk/g' install_scripts/auth_import_mysql.php
    
    Run the installation script:
    install_scripts/ninja_db_init.sh /usr/local/nagios/addons/ninja
    

    Install dependencies

    apt-get install libmysqld-dev
    apt-get install php5-gd
    /etc/init.d/apache2 restart
    
    Stop nagios:
    /etc/init.d/nagios stop
    

    Edit setup script

    Edit setup.sh and modify it as follows:
    vi scripts/setup.sh
     mod_path=/usr/local/nagios/addons/reports-module
     prefix=/usr/local/nagios
    
     # Remove the following lines (or use comments, i.e #):
     php $mod_path/find_configured.php \
         > /tmp/$name.interesting
    
     archived="$prefix/var/archives/nagios-*.log"
     nagioslog=$prefix/var/nagios.log
    
     # remove the line
     /etc/rc.d/init.d/monitor start
    
    Run the script to create the database and tables:
    sh scripts/setup.sh
    
    # if no errors were encountered, run
    make
    
    /etc/init.d/nagios start
    

    Import ninja report table definitions

    To be able to save and schedule your availability and SLA reports, Ninja needs some additional tables:
    mysql monitor_reports < /usr/local/nagios/addons/ninja/install_scripts/reports.sql
    

    Set nagios_base_path

    Finally we need to set the nagios_base_path variable in /application/config/config.php
    $config['nagios_base_path']='/usr/local/nagios';
    


No comments:

Post a Comment