homedjagios for all

Installation

Centos / Fedora / RHEL

Robert Keersse wrote out an excellent documentation that he maintains for Djagios. you can find it here: http://djagios.belbob.net

Prerequisites

  • setuptools 0.6c9
  • Django 1.1 (at least) (and it’s prerequisites, please check the Django website)
  • MySQL (or other database supported by Django, however the install guide only uses MySQL)

About Nagios Configuration

For setting up Djagios I based myself upon the configuration documentation on the Nagios website for version 3. However the default config files on a default Nagios install contain mistakes against it’s own documentation. Following are the steps to be able to import the default (but incorrect) Nagios configuration:

- Most of the errors are in the templates.cfg (located in /etc/nagios/objects):

    - remove all occurances of 'failure_prediction_enabled'
    - remove all occurances of 'parallelize_check'
    - replace all occurances of 'retry_check_interval' with 'retry_interval'
    - replace all occurances of 'normal_check_interval' with 'check_interval'

- The last change is in nagios.cfg (located in /etc/nagios/) where uncomment the line
  where the /etc/nagios/objects/windows.cfg is defined.

After doing these changes your default Nagios config should be importable.

from source

First download the version you wish to install at our download section. Then run following commands:

tar xzf djagios-0.1.x.tar.gz
cd djagios-0.1.x
python setup.py install

That will install all the needed files for the djagios app. The media and template files are installed in /usr/share/djagios-0.1 for the 0.1.x versions.

configuration

First you need to start a project for the installation. We will use /var/www/djagios.org/apps as project path. Run following command:

cd /var/www/djagios.org/
django-admin.py startproject apps

Now you have setup your django environment. We will need to edit the settings file. Set following variables:

MEDIA_ROOT = '/usr/share/djagios-1.0/media
MEDIA_URL = '/media'
LOGIN_URL='/login'

Make sure you define the media path in your apache with the appropriate access levels!

Also add ‘/usr/share/djagios-0.1/templates’ to the TEMPLATES_DIRS list and add ‘djagios.core’ to the INSTALLED_APPS list.

Now we need to make sure the urls.py file contains the correct information. Below is a working example:

# Copyright (c) 2009 Jochen Maes
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

from django.conf.urls.defaults import *

from djagios.core import views
from djagios import config

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/(.*)', admin.site.root),
    (r'^login/$', 'django.contrib.auth.views.login', {'template_name': '%s/login.html'%config.theme_name}),
    (r'^logout', 'django.contrib.auth.views.logout_then_login', {'login_url': '/login'},),
    (r'^@@media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': '/usr/share/djagios-0.1/media/%s/'%config.theme_name}),
    (r'^hosttemplate/add', views.add_host_template),
    (r'^host/add', views.add_host),
    (r'^host/delete', views.delete_host),
    (r'^service/addhost', views.add_host_to_service),
    (r'^service/removehost', views.remove_host_from_service),
    (r'^json/servicesforhost/(?P<host_id>.*)/$',views.get_services_for_host ),
    (r'^$', views.home),
)

setup database

In order to use djagios you need to create a database and configure it in the settings.py file. I use following commands in MySQL:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.0.83-log Gentoo Linux mysql-5.0.83

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database djagios character set utf8 collate utf8_bin;
Query OK, 0 rows affected (0.03 sec)

mysql> create user 'djagios'@'localhost' identified by 'djagios';
Query OK, 0 rows affected (0.04 sec)

mysql> grant all on djagios.* to djagios;
Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

mysql> quit
Bye

Now we will create the tables for our applications:

python manage.py syncdb

Import Nagios config

To import your current nagios configuration files execute following commands with a user that has all access to the nagios files! Make sure you are in the folder where settings resides!:

export PYTHONPATH=`pwd`
env DJANGO_SETTINGS_MODULE=settings python import.py -s <name of server> -p <path>

The export makes sure that the setting module will be found. That should do it!

If however something is incorrect, please fix the config file and run this prior to retrying to import:

python manage.py reset core

export your configs

When you change things to Djagios then you need to export to a nagios config. I have a basic export.py that I use:

 # Djagios export
 # Copyright (c) 2009 Jochen Maes
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.

 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.

 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import sys
from djagios.common.utils import Exporter

e = Exporter()
e.export(sys.argv[1])

A script for a simple export is shown below:

#!/bin/bash
#
# Djagios export script
# Copyright (c) 2009 Jochen Maes
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

cd /var/www/djagios_src
export PYTHONPATH='/var/www/djagios_src'
export DJANGO_SETTINGS_MODULE='settings'
mkdir /tmp/nagios3
python djagios/export.py /tmp/nagios3

Table Of Contents

Previous topic

Screenshots

Next topic

Development

This Page