- 浏览: 3548919 次
- 性别:
- 来自: 大连
博客专栏
-
使用Titanium Mo...
浏览量:38156
-
Cordova 3.x入门...
浏览量:607323
-
常用Java开源Libra...
浏览量:682353
-
搭建 CentOS 6 服...
浏览量:89368
-
Spring Boot 入...
浏览量:401861
-
基于Spring Secu...
浏览量:69699
-
MQTT入门
浏览量:91724
文章分类
最新评论
-
afateg:
阿里云的图是怎么画出来的?用什么工具?
各云服务平台的架构图 -
cbn_1992:
博主,采用jdbctoken也就是数据库形式之后,反复点击获取 ...
Spring Security OAuth2 Provider 之 数据库存储 -
ipodao:
写的很是清楚了,我找到一份中文协议:https://mcxia ...
MQTT入门(6)- 主题Topics -
Cavani_cc:
还行
MQTT入门(6)- 主题Topics -
fexiong:
博主,能否提供完整源码用于学习?邮箱:2199611997@q ...
TensorFlow 之 构建人物识别系统
(一)Cacti
*** 需要先安装Apache + MySQL + PHP(php-snmp)
(1)安装Net-SNMP
# yum -y install net-snmp
# cp -p /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.org
# vi /etc/snmp/snmpd.conf
# /etc/init.d/snmpd start
(2)安装RRDtool & cacti
# vi /etc/yum.repos.d/CentOS-Base.repo
# wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt
# yum -y install --enablerepo=dag rrdtool
# yum -y install --enablerepo=dag cacti
(3)设置
创建数据库
# mysql -u root -p
# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql
# mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
设置cacti
# vi /etc/cacti/db.php
设置Apache
# vi /etc/httpd/conf.d/cacti.conf
# /etc/init.d/httpd restart
设置自动收集数据
# vi /etc/cron.d/cacti
(4)确认
http://<youripaddress>/cacti/
第一次需要按照向导设置。
(二)Nagios
被监视机器端
(1)安装nagios-plugins
(2)安装NRPE
服务器端
(1)安装Nagios
(2)安装NRPE
安装完成后,nagios的plugin里应该有一个check_nrpe:/usr/local/nagios/libexec/check_nrpe
(3)设置NRPE
(4)服务器测试被监视服务器NRPE
(5)设置邮件通知
设置邮件内容和发送人地址
设置收件人地址
所有的设置内容可以放入一个新建的文件
(6)使用check_linux_stats.pl监控系统运行参数
被监视机器端的默认nrpe.cfg配置文件中已经定义好了以下监控服务:check_users、check_load、check_hda1、check_zombie_procs、check_total_procs。但是有一些局限性,这里使用check_linux_stats.pl脚本扩展监控。
安装perl
安装Sys::Statistics::Linux
下载脚本
从https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details下载文件check_linux_stats.pl到/usr/local/src。
修改配置
监控服务器端确认
被监控端常见的几个错误:
原因:nrpe.cfg里IP限制、5666端口
原因:脚本执行权限
原因:nrpe.cfg里没有配置该命令
*** 需要先安装Apache + MySQL + PHP(php-snmp)
(1)安装Net-SNMP
# yum -y install net-snmp
# cp -p /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.org
# vi /etc/snmp/snmpd.conf
引用
# sec.name source community
#com2sec notConfigUser default public ←注释掉
com2sec local localhost private ←
com2sec mynetwork 192.168.21.0/24 public ←
# groupName securityModel securityName
#group notConfigGroup v1c notConfigUser ←注释掉
#group notConfigGroup v2c notConfigUser ←注释掉
group MyROGroup v1 local ←
group MyROGroup v2c local ←
group MyROGroup v1 mynetwork ←
group MyROGroup v2c mynetwork ←
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
#view systemview included .1.3.6.1.2.1.1 ←注释掉
#view systemview included .1.3.6.1.2.1.25.1.1 ←注释掉
view all included .1 80 ←
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact systemview none none ←注释掉
access MyROGroup "" any noauth exact all none none ←
access MyRWGroup "" any noauth exact all all none ←
# Check the / partition and make sure it contains at least 10 megs.
#disk / 10000
disk / 10000 ←
#com2sec notConfigUser default public ←注释掉
com2sec local localhost private ←
com2sec mynetwork 192.168.21.0/24 public ←
# groupName securityModel securityName
#group notConfigGroup v1c notConfigUser ←注释掉
#group notConfigGroup v2c notConfigUser ←注释掉
group MyROGroup v1 local ←
group MyROGroup v2c local ←
group MyROGroup v1 mynetwork ←
group MyROGroup v2c mynetwork ←
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
#view systemview included .1.3.6.1.2.1.1 ←注释掉
#view systemview included .1.3.6.1.2.1.25.1.1 ←注释掉
view all included .1 80 ←
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact systemview none none ←注释掉
access MyROGroup "" any noauth exact all none none ←
access MyRWGroup "" any noauth exact all all none ←
# Check the / partition and make sure it contains at least 10 megs.
#disk / 10000
disk / 10000 ←
# /etc/init.d/snmpd start
(2)安装RRDtool & cacti
# vi /etc/yum.repos.d/CentOS-Base.repo
引用
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag/
gpgcheck=1
enabled=0
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag/
gpgcheck=1
enabled=0
# wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt
# yum -y install --enablerepo=dag rrdtool
# yum -y install --enablerepo=dag cacti
(3)设置
创建数据库
# mysql -u root -p
引用
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'your-password-here';
mysql> FLUSH privileges;
mysql> quit;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'your-password-here';
mysql> FLUSH privileges;
mysql> quit;
# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql
# mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
设置cacti
# vi /etc/cacti/db.php
引用
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "your-password-here";
$database_port = "3306";
$database_ssl = false;
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "your-password-here";
$database_port = "3306";
$database_ssl = false;
设置Apache
# vi /etc/httpd/conf.d/cacti.conf
引用
Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
deny from all
allow from 127.0.0.1
allow from 192.168.1.0/24 ←
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
deny from all
allow from 127.0.0.1
allow from 192.168.1.0/24 ←
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
# /etc/init.d/httpd restart
设置自动收集数据
# vi /etc/cron.d/cacti
引用
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
(4)确认
http://<youripaddress>/cacti/
第一次需要按照向导设置。
(二)Nagios
被监视机器端
(1)安装nagios-plugins
# yum -y install gcc openssl openssl-devel # mkdir /usr/local/nagios /usr/local/nagios/bin /usr/local/nagios/libexec /usr/local/nagios/etc # useradd -d /usr/local/nagios/ -M nagios # cd /usr/local/src # wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz # tar zxvf nagios-plugins-2.0.3.tar.gz # cd nagios-plugins-2.0.3 # ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios # make # make install
(2)安装NRPE
# cd /usr/local/src # wget --no-check-certificate https://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz # tar zxvf nrpe-2.15.tar.gz # cd nrpe-2.15 # ./configure # make all # make install # cp -p init-script /etc/rc.d/init.d/nrpe # chmod 755 /etc/rc.d/init.d/nrpe # chown nagios:nagios /usr/local/nagios/etc # cp -p sample-config/nrpe.cfg /usr/local/nagios/etc/ # vim /usr/local/nagios/etc/nrpe.cfg allowed_hosts=127.0.0.1,<Nagios服务器IP> # /etc/init.d/nrpe start # netstat -nlp | grep 5666
引用
启动nrpe:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
重启nrpe:
ps aux|grep nrpe
kill $pid
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
重启nrpe:
ps aux|grep nrpe
kill $pid
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
服务器端
(1)安装Nagios
# yum -y install gd-devel # useradd -d /usr/local/nagios/ -M nagios # cd /usr/local/src # wget http://jaist.dl.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz -O nagios-4.0.8.tar.gz # tar zxvf nagios-4.0.8.tar.gz # cd nagios-4.0.8 # ./configure && make all && make fullinstall && make install-config
(2)安装NRPE
# cd /usr/local/src # wget http://cznic.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz # tar zxvf nrpe-2.15.tar.gz # cd nrpe-2.15 # ./configure # make all # make install
安装完成后,nagios的plugin里应该有一个check_nrpe:/usr/local/nagios/libexec/check_nrpe
(3)设置NRPE
# vi /usr/local/nagios/etc/objects/commands.cfg define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } # vi /usr/local/nagios/etc/objects/localhost.cfg define host{ use linux-server ; Name of host template to use host_name Web_Server_A alias Web_Server_A address 192.168.1.100 } define hostgroup{ hostgroup_name linux-servers ; The name of the hostgroup alias Linux Servers ; Long name of the group members Nagios_Server,Web_Server_A ; Comma separated list of hosts that belong to this group } # vi /usr/local/nagios/etc/objects/services.cfg define service{ use generic-service host_name Web_Server_A service_description load check_command check_nrpe!check_load notifications_enabled 1 }
(4)服务器测试被监视服务器NRPE
# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.100 NRPE v2.15 # /usr/local/nagios/libexec/check_nrpe -H 192.168.1.100 -c check_load OK - load average: 0.02, 0.01, 0.00|load1=0.020;15.000;30.000;0; load5=0.010;10.000;25.000;0; load15=0.000;5.000;20.000;0;
(5)设置邮件通知
设置邮件内容和发送人地址
# vi /usr/local/nagios/etc/objects/commands.cfg define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f rensanning@gmail.com -t $CONTACTEMAIL$ -s mail.gmail.com -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" } define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$ \nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f rensanning@gmail.com -t $CONTACTEMAIL$ -s mail.gmail.com -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" }
设置收件人地址
# vi /usr/local/nagios/etc/objects/contacts.cfg define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email rensanning@gmail.com ←管理员邮件地址 } # service nagios restart
所有的设置内容可以放入一个新建的文件
# vi /usr/local/nagios/etc/objects/mysetting.cfg # vi /usr/local/nagios/etc/nagios.cfg cfg_file=/usr/local/nagios/etc/objects/mysetting.cfg
(6)使用check_linux_stats.pl监控系统运行参数
被监视机器端的默认nrpe.cfg配置文件中已经定义好了以下监控服务:check_users、check_load、check_hda1、check_zombie_procs、check_total_procs。但是有一些局限性,这里使用check_linux_stats.pl脚本扩展监控。
安装perl
# yum install -y perl-devel
安装Sys::Statistics::Linux
# cd /usr/local/src # wget http://search.cpan.org/CPAN/authors/id/B/BL/BLOONIX/Sys-Statistics-Linux-0.66.tar.gz # tar -zxvf Sys-Statistics-Linux-0.66.tar.gz # cd Sys-Statistics-Linux-0.66 # perl Makefile.PL # make # make install
下载脚本
从https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_linux_stats/details下载文件check_linux_stats.pl到/usr/local/src。
# cd /usr/local/src # cp check_linux_stats.pl /usr/local/nagios/libexec/check_linux_stats.pl # chown nagios:nagiso /usr/local/nagios/libexec/check_linux_stats.pl # chmod 755 /usr/local/nagios/libexec/check_linux_stats.pl # vi /etc/sudoers nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_linux_stats.pl
修改配置
# vi /usr/local/nagios/etc/nrpe.cfg command[check_cpu]=/usr/local/nagios/libexec/check_linux_stats.pl -C -w 90 -c 95 -s 5 command[check_disk]=/usr/local/nagios/libexec/check_linux_stats.pl -D -w 20 -c 10 -u % -p / command[check_load]=/usr/local/nagios/libexec/check_linux_stats.pl -L -w 10,8,5 -c 20,18,15 command[check_memory]=/usr/local/nagios/libexec/check_linux_stats.pl -M -w 90 -c 95 command[check_nginx]=/usr/local/nagios/libexec/check_linux_stats.pl -T -w 200000000 -c 300000000 -p /usr/local/nginx/logs/nginx.pid command[check_tomcat]=sudo /usr/local/nagios/libexec/check_linux_stats.pl -T -w 5000000000 -c 7000000000 -p /var/run/tomcat.pid # /etc/init.d/nrpe restart
监控服务器端确认
# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.100 -c check_disk
被监控端常见的几个错误:
引用
CHECK_NRPE: Error - Could not complete SSL handshake.
原因:nrpe.cfg里IP限制、5666端口
引用
NRPE: Unable to read output
原因:脚本执行权限
引用
NRPE: Command 'check_tomcat' not defined
原因:nrpe.cfg里没有配置该命令
发表评论
-
logrotate入门
2018-02-07 08:36 1228日志文件对于开发运维是非常有用的,通过日志可以跟踪系统的使用以 ... -
Bash简要入门
2018-01-19 16:03 1113(一)Shell 和 Bash Bash ... -
搭建独立图像处理服务(Thumbor)
2017-08-16 10:26 7409Thumbor是基于Python的开源 ... -
搭建分布式文件存储服务(FastDFS)
2017-03-17 16:04 3289服务器规划如下: 引用-跟踪服务器 192.168. ... -
CentOS 安装 OpenAM
2017-01-23 15:59 3579官网:https://forgerock.org/openam ... -
CentOS 安装 Nexus
2016-12-08 15:21 1570前提:Java 1)下载 # cd /usr/local/s ... -
CentOS 安装 KVM
2016-09-07 15:55 1444KVM:Kernel-based Virtual Machin ... -
CentOS 安装 Android
2016-09-02 09:58 1843前提 # java -version # gradle -v ... -
CentOS 安装 Jenkins
2016-09-01 09:03 2046(1)安装Jenkins # java -version ... -
CentOS 安装 ELK
2016-07-19 10:02 2641ELK(Elasticsearch, Logstash, Ki ... -
CentOS 7 vs CentOS 6的不同
2015-07-20 14:36 6624升级 CentOS 6 到 CentOS 7 1)备份你的系 ... -
搭建VirtualBox + Vagrant + CoreOS + Docker环境
2015-05-08 14:26 11032构成图 引用 Container | Container | ... -
搭建 CentOS 6 服务器(13) - Keepalived、HAProxy、LVS
2015-04-15 15:47 3460(一)Keepalived (1)安装 # cd /usr/ ... -
搭建 CentOS 6 服务器(4) - TigerVNC
2015-04-15 09:34 2607安装GNOME桌面环境 # yum groupinstall ... -
搭建 CentOS 6 服务器(12) - squid、Varnish
2015-04-13 14:07 2392(一)squid 安装 # yum -y install e ... -
搭建 CentOS 6 服务器(11) - rsync、Amanda
2015-04-13 14:06 2475(一)rsync Server端 # yum install ... -
搭建 CentOS 6 服务器(10) - Samba
2015-04-13 14:04 2063(1)安装 # yum -y install samba ... -
搭建 CentOS 6 服务器(14) - CVS、SVN、Git
2015-04-08 10:29 2380(一)CVS 安装xinetd # rpm -q xinetd ... -
搭建 CentOS 6 服务器(9) - vsftpd、ProFTPD
2015-03-18 15:09 3239(一)vsftpd 安装 # yum -y install ... -
搭建 CentOS 6 服务器(8) - Apache/Nginx/Jetty、Tomcat、WildFly
2015-03-18 14:38 5164(一)Apache (1)下载安装APR-Apache Po ...
相关推荐
使用`yum install nagios nagios-plugins-all nrpe`命令进行安装。 7. **配置Nagios**: 编辑配置文件`/etc/nagios/nagios.cfg`,配置Nagios服务器的基本信息,包括主机名、邮件通知等。接着配置要监控的主机和...
#./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install ``` **Cacti安装** Cacti是一款基于PHP和MySQL的网络监控和绘图工具,可以生成流量图。在集成Nagios之前,首先需要...
CACTI和NAGIOS是两个著名的开源网络监控工具,用于监控网络设备和服务的状态,提供图形化的性能数据展示。在CentOS 5环境下,安装这两个工具通常需要先搭建LAMP(Linux, Apache, MySQL, PHP)环境。下面将详细介绍...
【Cacti与Nagios整合安装教程】 Cacti是一款基于Web的网络监控和图形绘制工具,主要用于网络流量监控。而Nagios则是一款强大的网络监控系统,它可以监控网络服务、主机、网络设备以及各种应用程序的状态。将两者...
- CentOS: `sudo yum install nagios nagios-plugins-all` 3. **配置Nagios**:编辑`/etc/nagios3/nagios.cfg`,配置Nagios的基本信息,如主机名、端口等。 4. **添加主机和服务**:在`/etc/nagios3/conf.d`下...
【Nagios与Cacti整合】文档详细介绍了如何在CentOS 6.6操作系统上集成这两个强大的监控工具。Nagios主要用于服务监控,而Cacti则专注于网络流量监控。整合这两个工具可以让用户获得更全面的系统和网络监控体验。 ...
【Cacti中文版在CentOS 5 (RHEL 5) 上的安装】 Cacti是一款基于PHP、MySQL、SNMP以及RRDTool的网络监控工具,它提供了丰富的图表来展示网络设备的性能数据。在CentOS 5或RHEL 5上安装Cacti中文版,首先需要确保系统...
6. **图表生成**:Cacti使用rrdtool(Round Robin Database Tool)来存储和处理时间序列数据,并生成图形。理解rrdtool的数据结构和更新机制对于优化性能至关重要。 7. **报警与通知**:Cacti可以设置阈值,当网络...
【Cacti搭配Nagios攻略】是一篇详细介绍如何在Linux环境下使用Cacti和Nagios进行网络监控的文章。Cacti是一款基于Web的网络监控工具,利用SNMP协议获取数据,通过RRDTool进行数据存储和图表绘制。而Nagios则是一款...
Cacti+Nagios 完美部署 本文将详细介绍 Cacti 和 Nagios 的完美部署,包括 Cacti 和 RRDTool 的安装部署、Cacti 的架构图、Cacti 的工作原理图、Cacti 的优点和缺点等。 一、Cacti 和 RRDTool 的安装部署 Cacti ...
在本篇文档中,作者详细描述了在CentOS 5.3操作系统环境下搭建Cacti和Nagios监控系统全过程。文档首先概述了Cacti和Nagios的基本概念,然后分步骤介绍了如何安装配置这些监控工具。以下将详细解析文档中的知识点。 ...
- "CentOS5.5上搭建Nagio.pdf":讲述了在CentOS 5.5上安装和配置Nagios的教程。 - "QQ截图20120324173512.png" 和 "QQ截图20120324173540.png":可能是Cacti或Nagios的界面截图,展示了配置或监控结果。 通过学习和...
首先,我们的基础环境是R410服务器,配备8GB内存和16核CPU,运行CentOS 5.5 x86_64操作系统。为了顺利进行后续的配置,需要先关闭Selinux和iptables,如果生产环境中需要开启,应根据实际网络情况添加相应规则。 **...
Nagios是一款强大的网络监控系统,它能够实时监控网络服务、服务器和网络设备的状态,当出现问题时,Nagios会立即发出警告,帮助管理员及时发现并处理故障。Cacti则是一款开源的网络流量监控图形界面工具,主要用于...
Cacti 是一款基于 Web 的网络监控和性能图形化工具,常用于监控服务器、网络设备的性能数据。本文将详细介绍如何在 CentOS 5.4 x86_64 环境下安装配置 Cacti。 ### 一、准备工作 首先确保系统为 CentOS 5.4 x86_64...
下载并解压nagios-plugins源码,配置后进行编译和安装。这些插件通常位于/usr/local/nagios/libexec目录下。 为了实现Web监控界面,还需要安装Apache和PHP。Apache提供HTTP服务,PHP则用于处理Nagios的CGI脚本。...