Nagios 2: config the server
1, Apache
modify the apache configuration file, httpd.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/ <Directory "/usr/local/nagios/sbin/"> AllowOverride AuthConfig Options ExecCGI Order allow,deny Allow from all </Directory> Alias /nagios/ /usr/local/nagios/share/ <Directory "/usr/local/nagios/share"> Options None AllowOverride AuthConfig Order allow,deny Allow from all </Directory> |
2, Access control
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/usr/local/nagios/share vi .htaccess AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/.htpasswd require valid-user cd /usr/local/nagios/sbin vi .htpasswd AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/.htpasswd require valid-user |
3, generate the username and password for web login
1 |
usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/.htpasswd nagios |
If you want to add another user, use the command:
1 |
/usr/local/apache/bin/htpasswd /usr/local/nagios/etc/.htpasswd user2 |
4, check the configuration file of apache
1 |
/usr/local/apache2/bin/apachctl -t |
5, start setup nagios
generate the blank config file
1 2 3 |
sudo chown -R nagios:nagios /usr/local/nagios cd /usr/local/nagios/etc/objects/ touch contactgroups.cfg contacts.cfg hostgroups.cfg hosts.cfg services.cfg timeperiods.cfg |
link the config file to nagios
1 2 3 4 5 6 7 8 |
vi nagios.cfg cfg_file=/usr/local/nagios/etc/objects/commands.cfg cfg_file=/usr/local/nagios/etc/objects/contacts.cfg cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg cfg_file=/usr/local/nagios/etc/objects/templates.cfg cfg_file=/usr/local/nagios/etc/objects/hosts.cfg cfg_file=/usr/local/nagios/etc/objects/services.cfg |
and then, you can setup the contacts, hosts, services based on the demo.
After this, check the configuration:
1 |
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
Start the nagios if there is no error:
1 |
sudo /etc/init.d/nagios restart |
visit the site http://example.com/nagios/.
