设为首页 收藏本站
查看: 945|回复: 0

Nagios 3.0 Jumpstart Guide For Linux – Overview, Installation and Configuration

[复制链接]

尚未签到

发表于 2015-9-8 11:48:52 | 显示全部楼层 |阅读模式
DSC0000.jpg
  Let us discuss the overview, installation and configuration of Nagios, a powerful open source monitoring solution for host and services.

I. Overview of nagios
  II. 8 steps for installing nagios on Linux:


  • Download the nagios and plugins
  • Take care of the prerequisites
  • Create user and group for nagios
  • Install nagios
  • Configure the web interface
  • Compile and install nagios plugins
  • Start Nagios
  • Login to web interface
  III. Configuration files overview
  


I. Overview of Nagios
  .
Nagios is a host and service monitor tool. Following are some of the features of nagios.



  • Monitor equipments such as servers, switches, routers, firewalls, power supply etc.
  • Monitor services such as disk space, cpu usage, memory usage, temperature of the equipment, HTTP, Mail, SSH etc.
  • Nagios can monitor pretty much anything. for e.g. host, services, databases, applications etc.
  • Nagios has an extensible plugin interface for monitoring user defined services. There are lot of plugins available for Nagios. Visit NagiosPlugins and NagiosExchange for review the available user developed plugins.
  • It can send out various notifications ( email, pager etc.) when the problem occurs and get resolved.
  • Web interface to view current status, notifications, problem history, log files etc.
  Following is a partial screenshot of the nagios web dashboard:



DSC0001.jpg


Fig: Nagios Web UI (click on the image to enlarge)

II. 8 steps for installing nagios on Linux:

1. Download the nagios and plugins
  Download following files from Nagios.org and move to /home/downloads


  • nagios-3.0.1.tar.gz
  • nagios-plugins-1.4.11.tar.gz

2. Take care of the prerequisites


  • Make sure apache is working on the server by verifying from browser: http://localhost
  • Verify whether gcc is installed



      [iyunv@localhost]#rpm -qa | grep gcc
      gcc-3.4.6-8
      compat-gcc-32-3.2.3-47.3
      libgcc-3.4.6-8
      compat-libgcc-296-2.96-132.7.2
      compat-gcc-32-c++-3.2.3-47.3
      gcc-c++-3.4.6-8


  • Verify whether GD is installed



    [iyunv@localhost]# rpm -qa gd
      gd-2.0.28-5.4E

3. Create user and group for nagios



[iyunv@localhost]# useradd nagios
[iyunv@localhost]# passwd nagios
[iyunv@localhost]# groupadd nagcmd
[iyunv@localhost]# usermod -G nagcmd nagios
[iyunv@localhost]# usermod -G nagcmd apache


4. Install nagios



[iyunv@localhost]# tar xvf nagios-3.0.1.tar.gz
[iyunv@localhost]# cd nagios-3.0.1
[iyunv@localhost]# ./configure --with-command-group=nagcmd
[iyunv@localhost]# make all
[iyunv@localhost]# make install
[iyunv@localhost]# make install-config
[iyunv@localhost]# make install-commandmode


  Following are some additional parameters that you can pass to ./configure to customize your installation. I used only --with-command-group as shown above.



    --prefix              /opt/nagios    Where to put the Nagios files
    --with-cgiurl         /nagios/cgi-bin    Web server url where the cgi's will be available
    --with-htmurl         /nagios        Web server url where nagios will be available
    --with-nagios-user    nagios        user account under which Nagios will run
    --with-nagios-group    nagios        group account under which Nagios will run
    --with-command-group    nagcmd        group account which will allow the apache user to submit
                        commands to Nagios


  At the end of the configure output, it will display a summary as shown below:



*** Configuration summary for nagios 3.0.1 05-28-2008 ***:
General Options:
-------------------------
Nagios executable:  nagios
Nagios user/group:  nagios,nagios
Command user/group:  nagios,nagcmd
Embedded Perl:  no
Event Broker:  yes
Install ${prefix}:  /usr/local/nagios
Lock file:  ${prefix}/var/nagios.lock
Check result directory:  ${prefix}/var/spool/checkresults
Init directory:  /etc/rc.d/init.d
Apache conf.d directory:  /etc/httpd/conf.d
Mail program:  /bin/mail
Host OS:  linux-gnu
Web Interface Options:
------------------------
HTML URL:  http://localhost/nagios/
CGI URL:  http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):  /bin/traceroute


5. Configure the web interface.



[iyunv@localhost]# make install-webconf
[iyunv@localhost# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin


6. Compile and install nagios plugins



[iyunv@localhost]# tar xvf nagios-plugins-1.4.11.tar.gz
[iyunv@localhost]# cd nagios-plugins-1.4.11
[iyunv@localhost]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[iyunv@localhost]# make
[iyunv@localhost]# make install


  Note: On Red Hat, the ./configure command mentioned above did not work and was hanging at the when it was displaying the message: checking for redhat spopen problem… Add –enable-redhat-pthread-workaround to the ./configure command as a work-around for the above problem as shown below.



[iyunv@localhost]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround


7. Start Nagios


  • Add the nagios to the startup routine:



      [iyunv@localhost]# chkconfig --add nagios
      [iyunv@localhost]# chkconfig nagios on



  • Verify to make sure there are no errors in the nagios configuration file:



      [iyunv@localhost]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
      Total Warnings: 0
      Total Errors:   0
      Things look okay - No serious problems were detected during the pre-flight check



  • Start the nagios



      [iyunv@localhost]# service nagios start
      Starting nagios: done.


8. Login to web interface
  Nagios Web URL: http://localhost/nagios/
Use the userid, password that was created from step#5 above.
  


III. Configuration files overview
  .
The first configuration to modify is to change the default value of email address in /usr/local/nagios/etc/objects/contacts.cfg file to your email address.
  Following are the three major configuration files located under /usr/local/nagios/etc



  • nagios.cfg – This is the primary Nagios configuration file where lot of global parameters that controls the nagios can be defined.
  • cgi.cfg - This files has configuration information for nagios web interface.
  • resource.cfg – If you have to pass some sensitive information (username, password etc.) to a plugin to monitor a specific service, you can define them here. This file is readable only by nagios user and group.
  Following are the other configuration files under /usr/local/nagios/etc/objects directory:



  • contacts.cfg: All the contacts who needs to be notified should be defined here. You can specify name, email address, what type of notifications they need to receive and what is the time period this particular contact should be receiving notifications etc.
  • commands.cfg – All the commands to check services are defined here. You can use $HOSTNAME$ and $HOSTADDRESS$ macro on the command execution that will substitute the corresponding hostname or host ip-address automatically.
  • timeperiods.cfg – Define the timeperiods. for e.g. if you want a service to be monitored only during the business hours, define a time period called businesshours and specify the hours that you would like to monitor.
  • templates.cfg – Multiple host or service definition that has similar characteristics can use a template, where all the common characteristics can be defined. Use template is a time saver.
  • localhost.cfg – Defines the monitoring for the local host. This is a sample configuration file that comes with nagios installation that you can use as a baseline to define other hosts that you would like to monitor.
  • printer.cfg – Sample config file for printer
  • switch.cfg – Sample config file for switch
  • windows.cfg – Sample config file for a windows machine
  I will discuss about the steps to configure a remote Linux Host and Windows Host for monitoring through nagios inupcoming posts.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-111020-1-1.html 上篇帖子: 监控系列之三 nagios的初步安装 下篇帖子: Nagios简介
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表