yum install httpd php gcc glibc glibc-common gd gd-devel
yum install nagios nagios-plugins-all
/etc/selinux/config
templates.cfg (located in /etc/nagios/objects):
nagios.cfg (located in /etc/nagios/), uncomment the line where the /etc/nagios/objects/windows.cfg is defined.
htpasswd -c /etc/nagios/passwd nagiosadmin
/etc/httpd/conf.d/nagios.conf
ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/ <Directory /usr/lib/nagios/cgi-bin/> ... allow from 127.0.0.1 allow from xxx.xxx.xxx.xxx/24 AuthType Basic ... Alias /nagios/ /usr/share/nagios/html/ <Directory /usr/share/nagios/html/> ... allow from 127.0.0.1 allow from xxx.xxx.xxx.xxx/24 AuthType Basic ...
service httpd start
chkconfig --levels 235 httpd on
service nagios start
chkconfig --levels 235 nagios on
yum install mysql mysql-server mod_python Django MySQL-python
tar xzf djagios-0.1.x.tar.gz
cd djagios-0.1.x
python setup.py install
/usr/share/djagios-0.1 for the 0.1.x versions.
/var/www/djagios/apps as project path. Run following commands:
cd /var/www/djagios/
django-admin startproject apps
apps/settings.py file. Set following variables:
... # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '/usr/share/djagios-0.1/media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '/media' LOGIN_URL='/login' ...
/usr/share/djagios-0.1/templates’ to the TEMPLATES_DIRS list and add 'django.contrib.admin' and ‘djagios.core’ to the INSTALLED_APPS list.
...
TEMPLATE_DIRS = (
'/usr/share/djagios-0.1/templates'
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'djagios.core',
)
...
apps/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),
)
[root@localhost djagios]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 428 Server version: 5.1.37 Source distribution 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.01 sec) mysql> create user 'djagios'@'localhost' identified by 'djagios'; Query OK, 0 rows affected (0.01 sec) mysql> grant all on djagios.* to djagios; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
apps/settings.py file
... DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'djagios' # Or path to database file if using sqlite3. DATABASE_USER = 'djagios' # Not used with sqlite3. DATABASE_PASSWORD = 'djagios' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. ...
python apps/manage.py syncdb
[root@localhost djagios]# python apps/manage.py syncdb Creating table auth_permission Creating table auth_group ... ... Creating table core_hosttemplate You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): yes Username (Leave blank to use 'root'): robert E-mail address: robert@belbob.net Password: Password (again): Superuser created successfully. Installing index for auth.Permission model Installing index for auth.Message model ... ... Installing index for core.HostTemplate model [root@localhost djagios]#
export PYTHONPATH=/var/www/djagios/apps/
ln -s /usr/lib/python2.6/site-packages/djagios/import.py apps/import.py
env DJANGO_SETTINGS_MODULE=settings python apps/import.py -s localhost -p /etc/nagios/nagios.cfg
INFO:root:Temporary directory /tmp/1fa3df12-9383-4a51-a7a3-cd63fb169621 created for the parsed config files INFO:root:NagiosConfigParser initialized! Initial save happend! Nagios main config imported, starting with the other objects INFO:root:Starting with host.cfg INFO:root:Finished with host.cfg ... ... INFO:root:Finished with contact.cfg [root@localhost djagios]#
python apps/manage.py reset core
python apps/manage.py runserver 0.0.0.0:8000
[root@localhost djagios]# python apps/manage.py runserver 0.0.0.0:8000 Validating models... 0 errors found Django version 1.1, using settings 'apps.settings' Development server is running at http://0.0.0.0:8000/ Quit the server with CONTROL-C.
# 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])
#!/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/ export PYTHONPATH='/var/www/djagios/apps/' export DJANGO_SETTINGS_MODULE='settings' mkdir /tmp/nagios3 python apps/export.py /tmp/nagios3
sh djagios_export.sh
nagios -v /tmp/nagios3/nagios.cfg
Nagios Core 3.2.0 Copyright (c) 2009 Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 08-12-2009 License: GPL Website: http://www.nagios.org Reading configuration data... Read main config file okay... Processing object config directory '/tmp/nagios3/objects'... Processing object config file '/tmp/nagios3/objects/contact.cfg'... Processing object config file '/tmp/nagios3/objects/contactgroup.cfg'... Processing object config file '/tmp/nagios3/objects/service.cfg'... Processing object config file '/tmp/nagios3/objects/timeperiod.cfg'... Processing object config file '/tmp/nagios3/objects/command.cfg'... Processing object config file '/tmp/nagios3/objects/hostgroup.cfg'... Processing object config file '/tmp/nagios3/objects/host.cfg'... Read object config files okay... Running pre-flight check on configuration data... Checking services... Checked 17 services. Checking hosts... Checked 4 hosts. Checking host groups... Checked 2 host groups. Checking service groups... Checked 0 service groups. Checking contacts... Checked 1 contacts. Checking contact groups... Checked 1 contact groups. Checking service escalations... Checked 0 service escalations. Checking service dependencies... Checked 0 service dependencies. Checking host escalations... Checked 0 host escalations. Checking host dependencies... Checked 0 host dependencies. Checking commands... Checked 24 commands. Checking time periods... Checked 5 time periods. Checking for circular paths between hosts... Checking for circular host and service dependencies... Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0
/etc/nagios/nagios.cfg with /tmp/nagios3/nagios.cfg
/etc/nagios/nagios.cfg use /tmp/nagios3/objects
service nagios restart
| Revision History | |||
|---|---|---|---|
| Revision 1.0.1 | 2009-10-18 | ||
| |||
| Revision 1.0.2 | 2009-10-23 | ||
| |||
| Revision 1.0.3 | 2009-10-27 | ||
| |||
| Revision 1.0.4 | 2009-12-16 | ||
| |||