2009-05-23 05:05:41 UTC
Nagios by default uses htaccess for authentication to access Nagios. Heres a simple way to manage Nagios access from Centron user and groups.
1) Log in to Centreon and add a user group named "Nagios_Access" (Configuration/Users/Contacts Groups)
2) yum install mod_auth_mysql
3) Edit /etc/http/conf.d/nagios.conf as follows
######################################################
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
ScriptAlias /nagios/cgi-bin "/usr/lib/nagios/cgi"
<Directory "/usr/lib/nagios/cgi">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
# AuthName "Nagios Access"
# AuthType Basic
# AuthUserFile /etc/nagios/htpasswd.users
# Require valid-user
AuthMySQLEnable On
AuthName "Nagios Login"
AuthType Basic
AuthMySQLHost localhost
#AuthMySQLPort <default port in MySQL>
#AuthMySQLSocket <default socket in MySQL>
AuthMySQLUser root
#AuthMySQLPassword
AuthMySQLDB centreon2
AuthMySQLUserTable "contact,contactgroup_contact_relation"
AuthMySQLUserCondition "contact.contact_id = contactgroup_contact_relation.contact_contact_id AND contactgroup_contact_relation.contactgroup_cg_id = (select cg_id from contactgroup where cg_name like('Nagios_Access'))"
AuthMySQLNameField contact.contact_alias
AuthMySQLPasswordField contact.contact_passwd
AuthMySQLNoPasswd On
AuthMySQLPwEncryption md5
#AuthMySQLSaltField <>
AuthMySQLAuthoritative On
require valid-user
</Directory>
Alias /nagios "/usr/share/nagios"
<Directory "/usr/share/nagios">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
# AuthName "Nagios Access"
# AuthType Basic
# AuthUserFile /etc/nagios/htpasswd.users
# Require valid-user
AuthMySQLEnable On
AuthName "Nagios Login"
AuthType Basic
AuthMySQLHost localhost
#AuthMySQLPort <default port in MySQL>
#AuthMySQLSocket <default socket in MySQL>
AuthMySQLUser root
#AuthMySQLPassword
AuthMySQLDB centreon2
AuthMySQLUserTable "contact,contactgroup_contact_relation"
AuthMySQLUserCondition "contact.contact_id = contactgroup_contact_relation.contact_contact_id AND contactgroup_contact_relation.contactgroup_cg_id = (select cg_id from contactgroup where cg_name like('Nagios_Access'))"
AuthMySQLNameField contact.contact_alias
AuthMySQLPasswordField contact.contact_passwd
AuthMySQLNoPasswd On
AuthMySQLPwEncryption md5
#AuthMySQLSaltField <>
AuthMySQLAuthoritative On
require valid-user
</Directory>
######################################################
4) Restart Apache: /etc/init.d/httpd restart
5) Now any users you add to the Nagios Access group in Centreon will be able to log into Nagios with the same user pass.