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

Nagios+Centreon+Nrpe集成(二)

[复制链接]

尚未签到

发表于 2019-1-15 06:34:53 | 显示全部楼层 |阅读模式
4centreon集成

4.1应用程序安装

### 版本:centreon-2.3.9.tar.gz

下载地址:http://www.centreon.com/Content-Download/donwload-centreon

安装参考文档:(1)http://documentation.centreon.com/01-centreon/centreon_web/documentation/01-setup/installation_from_sources/step_05_-_centreon

(2)http://blog.sina.com.cn/s/blog_5611597901016qd2.html

# tar zxvf centreon-2.3.9.tar.gz
# cd centreon-2.3.9
# ./install.sh -i //以下是安装过程中需要根据实际路径修改的地方,其他均为y 回车(当然你也可以自己定制)
Where is your NDO ndomod binary ?
default to [/usr/sbin/ndomod.o]
> /usr/local/nagios/bin/ndomod.o
/usr/local/nagios/bin/ndomod.o                             OK

4.2 web installation

(1)以下服务均已启动
# /etc/init.d/apache2 start
# /etc/init.d/mysqld start
# /etc/init.d/ndo2db start
# /etc/init.d/nagios start
(2)开始安装:http://192.168.113.5/centreon/
### 备注参考内容:
http://documentation.centreon.com/01-centreon/centreon_web/documentation/01-setup/installation_from_sources/step_05_-_centreon
http://blog.sina.com.cn/s/blog_5611597901016qd2.html
### 部分配图:其他基本next
图示1mysql root密码填写,三个新库密码设置
                                                  

图示2:配置centreon管理员用户、密码、其他三项自定义
   



4.3在线安装nagios

Centreon安装时,其他应用在线安装的,需要修改以下可能出现的路径问题:

Where is installed Nagios ?
default to [/usr/local/nagios]
>  /usr/share/nagios3/
Path /usr/share/nagios3/                                   OK

Where is your nagios config directory
default to [/usr/local/nagios/etc]
> /etc/nagios3
Path /etc/nagios3                                          OK

Where is your Nagios var directory ?
default to [/usr/local/nagios/var]
>  /var/log/nagios3/
Path /var/log/nagios3/                                     OK

Where is your Nagios plugins (libexec) directory ?
default to [/usr/local/nagios/libexec]
> /usr/lib64/nagios/plugins
Path /usr/lib64/nagios/plugins                             OK
/usr/sbin/nagios3                                          OK

Where is your Nagios image directory ?
default to [/usr/local/nagios/share/images/logos]
> /usr/share/nagios3/htdocs/images/logos/
Path /usr/share/nagios3/htdocs/images/logos/               OK

Where is your NDO ndomod binary ?
default to [/usr/sbin/ndomod.o]
> /usr/lib/ndoutils/ndomod-mysql-3x.o
/usr/lib/ndoutils/ndomod-mysql-3x.o                        OK

4.4 Web 安装centreon完成后

### 参考链接:http://www.xodino.it/?page_id=968
Finalize Centreon configuration:
Open in webrowser: "http:///centreon/", replace "" with your Centreon server ip address or hostname.

Go to: Configuration -> Nagios -> cgi (in sidebar), Press on "CGI.cfg" link
Change settings to some options, as writed below:
- Physical HTML Path: /usr/share/nagios3/htdocs
- URL HTML Path : /nagios3
- Nagios Process Check Command: /usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/status.dat 5 '/usr/sbin/nagios3'
Press Save

Go to: Configuration -> Nagios -> nagios.cfg (in sidebar), Press on "Nagios CFG 1" link, you should be in "Files" section of the configuration screen.
Make sure to set folowing configuration values:
- Log File : /var/log/nagios3/nagios.log
- Downtime File : /var/lib/nagios3/downtime.dat
- Comment File : /var/lib/nagios3/comment.dat
- Temp File : /var/cache/nagios3/nagios.tmp
- P1 File : /usr/lib/nagios3/p1.pl
- Lock File : /var/run/nagios3/nagios3.pid
- Object Cache File : /var/cache/nagios3/objects.cache
- Status File : /var/cache/nagios3/status.dat
- External Command File : /var/lib/nagios3/rw/nagios.cmd

Now Press on "Logs Options" tab to go to "Logs Options" section.
Make sure to set folowing configuration values:
- Log Archive Path : /var/log/nagios3/archives/
- State Retention File : /var/lib/nagios3/retention.dat
Press Save

Go to: Administration -> Options -> CentStorage (in sidebar)
Make sure to set folowing configuration values:
- Nagios current log file to parse: /var/log/nagios3/nagios.log
Press Save

Now let's apply our changes, go to: Configuration -> Nagios
Select as below:
- Generate Configuration Files
- Include Comments
- Run Nagios debug (-v)
- Move Export Files
- Restart Nagios
- Method: "External Command"
Press Export

This will restart Nagios & apply all changes you made in Web Interface.
You will do it every time you make changes, e.g. adding/modifying of hosts, commands, contacts, services...etc...

The installation of Centreon is completed.

Final fixes (very important):
Go to terminal console, then...

In Debian/Ubuntu the user "nagios" is set to "/bin/false" shell. Because of it "centcore" and "centstorage" daemons won't start. A reason for that is because those daemons use "su -c" command which requires a real shell, so the shell for

"nagios" user must be set to "/bin/sh":
# usermod -s /bin/sh nagios

Apply permissions for Web interface to be able to send "External Commands", perform the following commands to change directory permissions and to make the changes permanent:
# invoke-rc.d nagios3 stop
# dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
# dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3

Add htaccess user with password "P@ssw0rd" for nagios CGI:
# htpasswd -bc /etc/nagios3/htpasswd.users nagiosadmin P@ssw0rd

Allow SNMP readonly access:
# echo "rocommunity public" > /etc/snmp/snmpd.conf

If you want to allow SNMP access only for localhost then use this instead:
# echo "rocommunity public 127.0.0.1" > /etc/snmp/snmpd.conf

# ls -al /usr/lib/nagios/plugins //查看权限,需要具有sudo权限
# cd /usr/lib/nagios/
# chmod -R u+s plugins   //权限修改成 -rwsr-xr-x
### 不修改权限会报:Warning: This plugin must be either run as root or setuid root.
Now, restart the server
# reboot

4.5 常规信息监控

4.5.1激活配置

   
# /etc/init.d/nagios3 reload
# /etc/init.d/centcore restart or start
# /etc/init.d/centstorage restart or start
# /etc/init.d/ndoutils restart
# /etc/init.d/nagios-nrpe-server restart

4.5.2监控本机

   
1)配置监控主机
   
2)定义主机服务
   
Go to: Configuration -> Serivces -> Add -> Services by host
   
   
Add---关系(Relations)保存后生效,然后激活配置
   
   

4.5.3通过nrpe插件监控本机

1)定义check_nrpe命令
命令名:check_nrpe
命令行:$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
Go to: Configuration -> Commands -> Checks -> Add -> Services by host
   
2nrpe常用模版修改
# vim /etc/nagios/nrpe.cfg
# The following examples use hardcoded command arguments...
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
3)添加check_load
Go to: Configuration -> Services -> Templates -> Add -> Save
   依次对照填写以下内容
   
3)关联模版
因为 Centreon-Server继承的是generic-host主机模板,所以我们在generic-host模板里将刚才的服务模板都关联上
Go to: Configuration -> HOsts -> Templates -> generic-host –> Relations
   
Go to: Configuration -> HOsts -> Centreon-Server
   
再次查看Centreon-Serve服务,已经生成  //若没有以下状态,可以重启nagios-nrpe-server ndoutils 服务
Go to: Monitoring -> Services -> All Serveices
   

4.6 Linux客户端监控

# apt-get install build-essential
4.6.1 nagios-plugins install

# groupadd nagios    # useradd –g nagios nagios
# tar zxvf  nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16/
# ./configure
# make && make install
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
4.6.2 nrpe install

# apt-get install libssl-dev
# tar zxvf nrpe-2.13.tar.gz //以下为源码安装
# cd nrpe-2.13
# ./configure
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.113.5
# The following examples use hardcoded command arguments...
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_desk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

# cp init-script.debian /etc/init.d/nrpe
# chmod +x /etc/init.d/nrpe    # /etc/init.d/nrpe start
# netstat -antup |grep 5666
# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1  //在线安装路径
# /usr/lib/nagios/plugins/check_nrpe -H 192.168.113.6 //在监控服务器上
4.6.3 web centreon configuration

1Go to: Configuration -> HOsts -> Templates ->Servers-Linux –> Relations -> Save

   
2Go to: Configuration -> HOsts -> Add –> Save

   
   






4.6 可能的报错信息

1)报错解决:
Error: Could not create external command file '/var/log/nagios3/rw/nagios.cmd'
解决:mkdir /var/log/nagios3/rw
Chown nagios.nagios rw
2)在线安装ndoutils,启动ndo2前一定要修改:/etc/default/ndoutils
ENABLE_NDOUTILS=1




运维网声明 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-663307-1-1.html 上篇帖子: Nagios+Centreon+Nrpe集成(一) 下篇帖子: 关于nagios 邮件报警问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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