Nagios monitoring network server and network service configuration (1)

Source: Internet
Author: User

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:

 
 
  1. ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin   
  2.  
  3. <Directory "/usr/local/nagios/sbin">   
  4.   Options ExecCGI   
  5.   AllowOverride None   
  6.   Order allow,deny   
  7.   Allow from all   
  8.   AuthName "Nagios Access"   
  9.   AuthType Basic   
  10.   AuthUserFile /usr/local/nagios/etc/htpasswd.users   
  11.   Require valid-user   
  12. </Directory>   
  13.  
  14. Alias /nagios /usr/local/nagios/share   
  15.  
  16. <Directory "/usr/local/nagios/share">   
  17.   Options None   
  18.   AllowOverride None   
  19.   Order allow,deny   
  20.   Allow from all   
  21.   AuthName "Nagios Access"   
  22.   AuthType Basic   
  23.   AuthUserFile /usr/local/nagios/etc/htpasswd.users   
  24.   Require valid-user   
  25. </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:

 
 
  1. mkdir -p /package   
  2. chmod 1755 /package   
  3. cd /package   
  4. fetch http://cr.yp.to/daemontools/daemontools-0.76.tar.gz   
  5. cd admin/daemontools-0.76/   
  6. package/install  

Check whether the svscan process is started:

 
 
  1. ps aux | grep svscan   
  2. root       376 0.0 0.0 1636   0 con- IW   -       0:00.00 /bin/sh /command/svscanboot   
  3. root       411 0.0 0.0 1224   208 con- S   8Jul06   0:42.50 svscan /service  

OK. The startup is normal.

 
 
  1. cd /service   
  2. mkdir nagios   
  3. chmod 1755 nagios   
  4. touch ./run   
  5. chmod 755 ./run   
  6. vi run   
  7. PATH=/usr/local/bin:/usr/bin:/bin   
  8. export PATH   
  9.  
  10. exec env - PATH=$PATH \   
  11. /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg   
  12.  
  13. mkdir log   
  14. cd log   
  15. touch ./run   
  16. chmod 755 ./run   
  17. vi ./run   
  18. #!/bin/sh   
  19. exec setuidgid logadmin multilog t s1000000 n100 ./main   
  20.  
  21. mkdir main   
  22. chmod 777 main   
  23. chown nagios.nagios main   
  24. touch status   
  25. chown nagios.nagios status   
  26.  
  27. svc -u /service/nagios/   
  28. svstat /service/nagios/   
  29. root@## ps auxww | grep nagios   
  30. root     23276 0.0 0.1 1176   488 ?? I   5:00PM   0:01.71 supervise nagios   
  31. 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   
  32. root@##   

OK. Now the nagios service is automatically started. You can run the svc command to start or stop the service.

 
 
  1. ---------------------------------------------------------------------------------   
  2. svc opts services   
  3. opts is a series of getopt-style options. services consists of any number of arguments, each argument naming a directory used by supervise.    
  4.  
  5. -u: Up. If the service is not running, start it. If the service stops, restart it.    
  6. -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.    
  7. -o: Once. If the service is not running, start it. Do not restart it if it stops.    
  8. -p: Pause. Send the service a STOP signal.    
  9. -c: Continue. Send the service a CONT signal.    
  10. -h: Hangup. Send the service a HUP signal.    
  11. -a: Alarm. Send the service an ALRM signal.    
  12. -i: Interrupt. Send the service an INT signal.    
  13. -t: Terminate. Send the service a TERM signal.    
  14. -k: Kill. Send the service a KILL signal.    
  15. -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.   
  16. ---------------------------------------------------------------------------------  

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.