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

nagios 安装日志

[复制链接]

尚未签到

发表于 2015-9-8 10:52:08 | 显示全部楼层 |阅读模式
---修改yum升级服务器[iyunv@localhost ~]# cd /etc/yum.repos.d[iyunv@localhost yum.repos.d]# cp CentOS-Base.repo  CentOS-Base.repo.bak[iyunv@localhost yum.repos.d]# wget http://centos.ustc.edu.cn/CentOS-Base.repo
---更新软件[iyunv@localhost yum.repos.d]# yum update
---安装以下必备软件[iyunv@localhost yum.repos.d]# yum install httpd[iyunv@localhost yum.repos.d]# yum install gcc[iyunv@localhost yum.repos.d]# yum install glibc glibc-common[iyunv@localhost yum.repos.d]# yum install gd gd-devel
---添加nagios用户、nagcmd组等
[iyunv@localhost yum.repos.d]# cd [iyunv@localhost ~]# useradd -m nagios[iyunv@localhost ~]# passwd nagios---nagios[iyunv@localhost ~]# groupadd nagcmd[iyunv@localhost ~]# usermod -a -G nagcmd nagios[iyunv@localhost ~]# usermod -a -G nagcmd apache
---安装nagios
[iyunv@localhost ~]# mkdir -p ~/downloads[iyunv@localhost ~]# cd ~/downloads[iyunv@localhost downloads]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz[iyunv@localhost downloads]# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz[iyunv@localhost downloads]# tar xzf nagios-3.2.3.tar.gz[iyunv@localhost downloads]# cd nagios-3.2.3[iyunv@localhost nagios-3.2.3]# ./configure --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include [iyunv@localhost nagios-3.2.3]# make all[iyunv@localhost nagios-3.2.3]# make install[iyunv@localhost nagios-3.2.3]# make install-init[iyunv@localhost nagios-3.2.3]# make install-config[iyunv@localhost nagios-3.2.3]# make install-commandmode
[iyunv@localhost nagios-3.2.3]# cp /usr/local/nagios/etc/objects/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg.bak[iyunv@localhost nagios-3.2.3]# vi /usr/local/nagios/etc/objects/contacts.cfg---修改nagiosadmin:email
[iyunv@localhost nagios-3.2.3]# make install-webconf[iyunv@localhost nagios-3.2.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin---nagios
[iyunv@localhost nagios-3.2.3]# service httpd restart
---安装nagios-plugins
[iyunv@localhost nagios-3.2.3]# cd ~/downloads[iyunv@localhost downloads]# tar xzf nagios-plugins-1.4.15.tar.gz[iyunv@localhost downloads]# cd nagios-plugins-1.4.15[iyunv@localhost nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios[iyunv@localhost nagios-plugins-1.4.15]# make[iyunv@localhost nagios-plugins-1.4.15]# make install
---安装nagios-snmp-plugins
[iyunv@localhost nagios-plugins-1.4.15]# cd ~/downloads[iyunv@localhost downloads]# wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz[iyunv@localhost downloads]# tar xzf nagios-snmp-plugins.1.1.1.tgz[iyunv@localhost downloads]# cd nagios_plugins[iyunv@localhost nagios_plugins]# perl -MCPAN -e shell
cpan> install Net::SNMP
[iyunv@localhost nagios_plugins]# ./install.sh
---其它设置
[iyunv@localhost nagios_plugins]# cd [iyunv@localhost ~]# chkconfig --add nagios[iyunv@localhost ~]# chkconfig nagios on[iyunv@localhost ~]# chkconfig httpd on[iyunv@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg---检测配置[iyunv@localhost ~]# service nagios start
[iyunv@localhost ~]# cp /etc/sysconfig/selinux /etc/sysconfig/selinux.bak[iyunv@localhost ~]# vi /etc/sysconfig/selinux---SELINUX=permissive
---安装mysql
[iyunv@localhost ~]# yum -y install mysql[iyunv@localhost ~]# yum -y install mysql-server[iyunv@localhost ~]# yum -y install mysql-devel[iyunv@localhost ~]# yum -y install php-mysql
[iyunv@localhost ~]# chkconfig --levels 345 mysqld on[iyunv@localhost ~]# service mysqld start
[iyunv@localhost ~]# mysqlSET PASSWORD FOR 'root'@'localhost' = PASSWORD('mysql');
[iyunv@localhost yum.repos.d]# yum install php
---安装cacti
[iyunv@localhost ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm[iyunv@localhost ~]# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm[iyunv@localhost ~]# yum install rrdtool[iyunv@localhost ~]# yum install net-snmp net-snmp-utils net-snmp-devel
[iyunv@localhost ~]# yum install cacti---php-mysql,php-pdo,php-snmp
[iyunv@localhost conf.d]# vi cacti.conf
Alias /cacti/ /usr/local/wwwroot/cacti/<Directory /usr/local/wwwroot/cacti/>    DirectoryIndex index.php    Options -Indexes    AllowOverride all    order deny,allow    allow from all    AddType application/x-httpd-php .php    php_flag magic_quotes_gpc on    php_flag track_vars on</Directory>
[iyunv@localhost ~]# mysql -u root -pMysql>create database cacti;Mysql>use cacti;Mysql>source /usr/local/wwwroot/cacti/cacti.sqlMysql>grant all privileges on cacti.* to cacti@localhost identified by 'cacti';Mysql>flush privileges;
---apache设置
[iyunv@localhost ~]# vi /var/www/cacti/include/config.php
$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cacti";$database_password = "cacti";$database_port = "3306";
---安装ndoutils,实现nagios采集数据写入mysql
[iyunv@localhost ~]# wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz[iyunv@localhost ~]# tar zxf ndoutils-1.4b9.tar.gz[iyunv@localhost ~]# cd ndoutils-1.4b9[iyunv@localhost ndoutils-1.4b9]# ./configure --enable-mysql --disable-pgsql --with-mysql-lib=/usr/lib/mysql[iyunv@localhost ndoutils-1.4b9]# make[iyunv@localhost ndoutils-1.4b9]# cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
[iyunv@localhost ndoutils-1.4b9]# vi /usr/local/nagios/etc/nagios.cfg
check_external_commands=1command_check_interval=-1event_broker_options=-1broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfgprocess_performance_data=1
[iyunv@localhost ndoutils-1.4b9]# cd src/[iyunv@localhost src]# cp file2sock log2ndo ndo2db-3x ndomod-3x.o /usr/local/nagios/bin/[iyunv@localhost src]# cp ndo2db-3x /usr/local/nagios/bin/ndo2db[iyunv@localhost src]# cd ..[iyunv@localhost ndoutils-1.4b9]# cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[iyunv@localhost ndoutils-1.4b9]# cd /usr/local/nagios/etc/[iyunv@localhost etc]# cp ndomod.cfg ndomod.cfg.bak[iyunv@localhost etc]# cp ndo2db.cfg ndo2db.cfg.bak[iyunv@localhost etc]# cat ndomod.cfg|grep -v '^#'|sed /^$/dinstance_name=defaultoutput_type=tcpsocketoutput=127.0.0.1tcp_port=5668output_buffer_items=5000buffer_file=/usr/local/nagios/var/ndomod.tmpfile_rotation_interval=14400file_rotation_timeout=60reconnect_interval=15reconnect_warning_interval=15data_processing_options=-1config_output_options=2[iyunv@localhost etc]# cat ndo2db.cfg|grep -v '^#'|sed /^$/dlock_file=/usr/local/nagios/var/ndo2db.lockndo2db_user=nagiosndo2db_group=nagiossocket_type=tcpsocket_name=/usr/local/nagios/var/ndo.socktcp_port=5668db_servertype=mysqldb_host=localhostdb_port=3306db_name=cactidb_prefix=npc_db_user=cactidb_pass=cactimax_timedevents_age=1440max_systemcommands_age=10080max_servicechecks_age=10080max_hostchecks_age=10080max_eventhandlers_age=44640max_externalcommands_age=44640debug_level=1debug_verbosity=1debug_file=/usr/local/nagios/var/ndo2db.debugmax_debug_file_size=1000000
[iyunv@localhost etc]# chown nagios /usr/local/nagios/etc/*[iyunv@localhost etc]# chgrp nagios /usr/local/nagios/etc/*

alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output; alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output; alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output; alter table npc_notifications add long_output TEXT NOT NULL default '' after output; alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output; alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output; alter table npc_statehistory add long_output TEXT NOT NULL default '' after output; alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;


[iyunv@localhost etc]# /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
yum -y install php php-cli php-xcache php-mysql php-mbstring php-gd php-pgsql php-mcrypt php-mhash php-xml php-bcmath php-devel
[iyunv@localhost ~]# wget http://www.aurore.net/projects/php-json/php-json-ext-1.2.1.tar.bz2[iyunv@localhost ~]# tar xjf php-json-ext-1.2.1.tar.bz2[iyunv@localhost ~]# cd php-json-ext-1.2.1[iyunv@localhost php-json-ext-1.2.1]# [iyunv@localhost php-json-ext-1.2.1]# phpize[iyunv@localhost php-json-ext-1.2.1]# ./configure[iyunv@localhost php-json-ext-1.2.1]# make[iyunv@localhost php-json-ext-1.2.1]# make install[iyunv@localhost php-json-ext-1.2.1]# cp /usr/lib/php/modules/json.so /usr/lib/php/modules/php_json.so[iyunv@localhost php-json-ext-1.2.1]# vi /etc/php.d/json.ini
extension=php_json.so
---
[iyunv@localhost ~]# wget ftp://plcadmin:Colut-fibrlink@211.160.88.202/npc-2.0.4.tar.gz[iyunv@localhost ~]# tar zxf npc-2.0.4.tar.gz[iyunv@localhost ~]# mkdir -p /usr/local/wwwroot/cacti/plugins[iyunv@localhost ~]# mv npc /usr/local/wwwroot/cacti/plugins

/usr/local/nagios/sbin
[iyunv@localhost cacti-plugin-arch]# cd /root/cacti-plugin-arch[iyunv@localhost cacti-plugin-arch]# mysql -u root -p cacti<pa.sql[iyunv@localhost cacti-plugin-arch]# cp -rf * /usr/local/wwwroot/cacti
[iyunv@localhost cacti-spine-0.8.7g]# ./configure[iyunv@localhost cacti-spine-0.8.7g]# make[iyunv@localhost cacti-spine-0.8.7g]# cp spine /usr/local/wwwroot/cacti[iyunv@localhost cacti-spine-0.8.7g]# cp spine.conf.dist /usr/local/wwwroot/cacti/spine.conf
[iyunv@localhost cacti]# pwd/usr/local/wwwroot/cacti[iyunv@localhost cacti]# vi spine.conf
crontab -e*/1 * * * * env LANG=C /usr/local/bin/php /usr/local/wwwroot/cacti/poller.php

./configure --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios


cat ndo2db.cfg|grep -v '^#'|sed /^$/d

运维网声明 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-110984-1-1.html 上篇帖子: 《Nagios系统监控实践》一书出版 下篇帖子: Nagios远程监控软件的安装与配置详解 ZT
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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