Nagios Configuration
1: configure the web interface
Suppose you have run apache. If not, see:
Http: // localhost/upload/blog. php? Do-showone-tid-18.html
Vi/usr/local/apache2/conf/httpd. conf
Add the following content:
- ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
-
- <Directory "/usr/local/nagios/sbin">
- Options ExecCGI
- AllowOverride None
- Order allow,deny
- Allow from all
- AuthName "Nagios Access"
- AuthType Basic
- AuthUserFile /usr/local/nagios/etc/htpasswd.users
- Require valid-user
- </Directory>
-
- Alias /nagios /usr/local/nagios/share
-
- <Directory "/usr/local/nagios/share">
- Options None
- AllowOverride None
- Order allow,deny
- Allow from all
- AuthName "Nagios Access"
- AuthType Basic
- AuthUserFile /usr/local/nagios/etc/htpasswd.users
- Require valid-user
- </Directory>
After modification, save the file and restart apache:
/Usr/local/apahce2/bin/apachectl restart
2: Configure apache BASIC Authentication:
Generate the authentication password:
/Usr/local/apache2/bin/htpasswd-c/usr/local/nagios/etc/htpasswd. users nagios
Apache interface configuration is complete.
Start configuring nagios:
Cd/usr/local/nagios/etc/
Under/usr/local/nagios/etc, the configuration template file-sample of nagios is used to copy all the. cfg-sample files to. cfg.
Example: cp nagios. cfg-sample nagios. cfg
Copy all.
Vi minimal. cfg
Comment out all commands:
The comment method is to add "#" before each definition statement.
Modify cgi. cfg
Modify use_authentication = 1 to use_authentication = 0, that is, no verification is required. Otherwise, some pages will not be displayed.
Check whether the configuration file has a syntax error:
/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
If yes, the following results are displayed:
Total Warnings: 0
Total Errors: 0
Otherwise, modify the configuration file as prompted. The configuration file will be retrieved later. Start nagios now
/Usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios. cfg
To interrupt nagios exceptions, we use daemontools to start:
Install daemontool:
- mkdir -p /package
- chmod 1755 /package
- cd /package
- fetch http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
- cd admin/daemontools-0.76/
- package/install
Check whether the svscan process is started:
- ps aux | grep svscan
- root 376 0.0 0.0 1636 0 con- IW - 0:00.00 /bin/sh /command/svscanboot
- root 411 0.0 0.0 1224 208 con- S 8Jul06 0:42.50 svscan /service
OK. The startup is normal.
- cd /service
- mkdir nagios
- chmod 1755 nagios
- touch ./run
- chmod 755 ./run
- vi run
- PATH=/usr/local/bin:/usr/bin:/bin
- export PATH
-
- exec env - PATH=$PATH \
- /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
-
- mkdir log
- cd log
- touch ./run
- chmod 755 ./run
- vi ./run
- #!/bin/sh
- exec setuidgid logadmin multilog t s1000000 n100 ./main
-
- mkdir main
- chmod 777 main
- chown nagios.nagios main
- touch status
- chown nagios.nagios status
-
- svc -u /service/nagios/
- svstat /service/nagios/
- root@## ps auxww | grep nagios
- root 23276 0.0 0.1 1176 488 ?? I 5:00PM 0:01.71 supervise nagios
- nagios 34251 0.0 0.3 2316 1552 ?? S 6:06PM 0:00.10 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
- root@##
OK. Now the nagios service is automatically started. You can run the svc command to start or stop the service.
- ---------------------------------------------------------------------------------
- svc opts services
- opts is a series of getopt-style options. services consists of any number of arguments, each argument naming a directory used by supervise.
-
- -u: Up. If the service is not running, start it. If the service stops, restart it.
- -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.
- -o: Once. If the service is not running, start it. Do not restart it if it stops.
- -p: Pause. Send the service a STOP signal.
- -c: Continue. Send the service a CONT signal.
- -h: Hangup. Send the service a HUP signal.
- -a: Alarm. Send the service an ALRM signal.
- -i: Interrupt. Send the service an INT signal.
- -t: Terminate. Send the service a TERM signal.
- -k: Kill. Send the service a KILL signal.
- -x: Exit. supervise will exit as soon as the service is down. If you use this option on a stable system, you're doing something wrong; supervise is designed to run forever.
- ---------------------------------------------------------------------------------
For example:
Stop nagios -- svc-d/service/nagios/
Restart nagios -- svc-t/service/nagios/
Start nagios -- svc-u/service/nagios/
Of course, you can also use the inited method:
/Usr/local/etc/rc. d/nagios start/stop
Well, anyway, daemontools is very powerful. Opening the webpage: http: // localhost/nagios/will surely surprise you. Haha, my server and service status are clear. Now we only have one nagios instance, that is, its own, localhost, huh, and so on. We will add other host and host services.