Project

General

Profile

NagiosRecipe » History » Revision 10

Revision 9 (Anonymous, 2008-07-28 07:58) → Revision 10/13 (babo, 2009-01-09 10:19)

h1. Setting up Nagios Web Interface with Lighty 


 


 Nagios is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better. Nagios has a web interface that allows you to check and modify configuration via the web. There's a documentation that explains how to set up Nagios with Apache. http://nagios.sourceforge.net/docs/2_0/installweb.html 

 This assumes that Nagios is installed in /usr/local/nagios.  

 Edit lighttpd.conf and unhash "mod_alias", "mod_auth", "mod_setenv" "mod_auth" and "mod_cgi" in the server.modules section.  

 Then add the following:  


  


 <pre> 

 

 alias.url =       ( 
                 "/nagios/cgi-bin" => "/usr/local/nagios/sbin", 
                 "/nagios" => "/usr/local/nagios/share" 
                 ) 
 </pre> 


 


 Nagios comes with CGI scripts that are compiled binaries. We need to make sure that Lighty doesn't try to run them thru Perl. 


 


 <pre> 

 

 $HTTP["url"] =~ "^/nagios/cgi-bin" { 
         cgi.assign = ( "" => "" ) 
 } 
 </pre> 



 



 In order to see and modify the configuration you need to set up CGI authentication. The general steps to enable CGI authentication would be creating your /etc/nagios/passwd file and adding the following lines to your lighttpd.conf: 


 


 <pre> 
 

 $HTTP["url"] =~ "nagios" "^/nagios/cgi-bin" { 
         auth.backend = "htpasswd" 
         auth.backend.htpasswd.userfile = "/etc/nagios/passwd" 
         auth.require = ( "" => ( 
                 "method" => "basic", 
                 "realm" => "nagios", 
                 "require" => "user=nagiosadmin" 
                 ) 
         setenv.add-environment= ) 
 } 

 $HTTP["url"] =~ "^/nagios" { 
         auth.backend = "htpasswd" 
         auth.backend.htpasswd.userfile = "/etc/nagios/passwd" 
         auth.require = ( "REMOTE_USER" "" => "user" ( 
                 "method" => "basic", 
                 "realm" => "nagios", 
                 "require" => "user=nagiosadmin" 
                 ) 
         ) 
 } 
 </pre> 


 CGI programs for Nagios require a REMOTE_USER environmental variable which is provided by Apache, with here we are emulating it with mod_setenv. 


 More information about CGI authentication may be found here: http://nagios.sourceforge.net/docs/2_0/configcgi.html 

 Once you restart lighttpd, you should be able to access Nagios interface at http://your_host/nagios