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

Nagios实践之路(三)—-Nagios基本平台的安装

[复制链接]
发表于 2017-4-20 08:30:42 | 显示全部楼层 |阅读模式
Nagios基本平台的安装

           这里所说的基础平台安装是指Nagios软件包的安装,它是监控体系的框架,也是所有监控的基础。
        首先到官方网站(http://www.nagios.org/)去下载最新的nagios软件包,本文中使用的是nagios-3.0.5.tar.gz 。顺便把官方文档也下载下来,以备不时之需。
        你安装Nagios平台的环境必须是Linux或是Unix系统。所以以下的操作都是在该系统中进行。本人使用的系统是SUSE 企业版 10.0。里面本来已经有Apache和Nagios安装包,可为了使用上的方便,所以就自己重装了这两个东西。下面就开始我们的Nagios的安装之旅吧。。。。

1) Create Account Information
Become the root user.
引用
# su -l

Create a new nagios user account and give it a password.
引用
#/usr/sbin/useradd -m nagios
#passwd nagios


Create a new nagios group. Add the nagios user to the group.
引用
#/usr/sbin/groupadd nagios
#/usr/sbin/usermod -G nagios nagios
#/usr/sbin/usermod -G nagios apache2 //apache2是在Apache2的时候你设置的用户名


2)Download the source code tarballs of both Nagios and the Nagios plugins (visit
http://www.nagios.org/download/ for links to the latest versions). At the time of writing, the latest
versions of Nagios and the Nagios plugins were 3.0.5 and 1.4.11, respectively.
引用
#wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.5.tar.gz
#wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz



3) Compile and Install Nagios
进入nagios-3.0.5.tar.gz所在的目录
引用
#tar zxvf nagios-3.0.5.tar.gz
#cd nagios-3.0.5

Run the Nagios configure script, passing the name of the group you created earlier like so:
引用
#./configure --with-command-group=nagcmd

Compile the Nagios source code.
引用
#make all

Install binaries, init script, sample config files and set permissions on the external command directory.
#make install  // - This installs the main program, CGIs, and HTML files
引用
#make install-init  //- This installs the init script in /etc/rc.d

引用
#make install-commandmode  //- This installs and configures permissions on the directory for holding the external      command   file

引用
#make install-config  //- This installs *SAMPLE* config files in /usr/local/nag ios/etc



注意:Don’t start Nagios yet - there’s still more that needs to be done...

4) Customize Configuration
Sample configuration files have now been installed in the  /usr/local/nagios/etc directory. These sample  files should work fine for getting started with Nagios. You’ll need to make just one change before you
proceed...
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving  alerts.
引用
#vi /usr/local/nagios/etc/objects/contacts.cfg  //更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail信息以接收报警内容。


5) Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
引用
#make install-webconf  //- This installs the Apache config file for the Nagios web interface


Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you
assign to this account - you’ll need it later.
引用
#/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

输入密码(这一步很重要)
注:此处输入的用户名和密码也就是管理员登录Web界面的时候要输入的用户名和密码。

Restart Apache to make the new settings take effect.
引用
# /etc/init.d/apachectl restart


6) Compile and Install the Nagios Plugins
Extract the Nagios plugins source code tarball.
进到nagios-plugins-1.4.11.tar.gz所在的目录
引用
#tar xzf nagios-plugins-1.4.11.tar.gz
#cd nagios-plugins-1.4.11

Compile and install the plugins.
引用
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install


7) Start Nagios
Add Nagios to the list of system services and have it automatically start when the system boots.
引用
#chkconfig --add nagios
#chkconfig nagios on

Verify the sample Nagios configuration files.
引用
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.
引用
#/usr/local/nagios/bin/nagios start


注:也可以将该服务设置为开启自动运行,方法:
  引用
# cp /usr/local/nagios/bin/nagios /etc/init.d
  # chmod 755 /etc/init.d/nagios


8)编辑apache 的httpd.conf最后面添加:
引用
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
#  SSLRequireSSL   
Options ExecCGI   
AllowOverride None  
Order allow,deny   
Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1   
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">
#  SSLRequireSSL   
Options None  
AllowOverride None  
Order allow,deny
  Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1  
AuthName "Nagios Access"
  AuthType Basic   
AuthUserFile /usr/local/nagios/etc/htpasswd.users   
Require valid-user
</Directory>


9)再验证下
引用
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

没有出错的话!
重新启动nagios和apache

10) Login to the Web Interface
You should now be able to access the Nagios web interface at the URL below. You’ll be prompted for the username (nagiosadmin) and password you specified earlier.
http://localhost/nagios/
Click on the "Service Detail" navbar link to see details of what’s being monitored on your local machine.
It will take a few minutes for Nagios to check all the services associated with your machine, as the
checks are spread out over time.

运维网声明 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-366589-1-1.html 上篇帖子: Monitor Tool(1)Nagios 下篇帖子: Nagios 用户无法登录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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