搭建nagios监控
来源:互联网 发布:数据采集控制箱 编辑:程序博客网 时间:2024/05/23 12:28
配置监控端
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devellibpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 gd gd-devel glib2-develbzip2 bzip2-devel ncurses ncurses-devel curl curl-devel openssl openssl-devellibmcrypt-devel libtool libtool-devel
安装apache
#useradd www
#tar -jxvf httpd-2.2.24.tar.bz2
#./configure --prefix=/usr/local/apache --enable-module=so--enable-deflate=shared --enable-expires=shared--enable-rewrite=shared --enable-cache --enable-file-cahe--enable-mem-cache --enable-disk-cache --enable-static-support --enable-ssl --enable-so
#make && make install
#cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
#vim /usr/local/apache/conf/httpd.conf
#/etc/init.d/httpd start
安装PHP
# tar -zxvf php-5.3.6.tar.gz
#./configure --prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin/apxs --with-gd--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--enable-safe-mode --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --enable-zip --enable-sockets
# make && make install
编辑apache配置文件
#vim /usr/local/apache/conf/httpd.conf
找到AddType模块处添加
在index.html前添加index.php
# useradd nagios -s /sbin/nologin
# mkdir /usr/local/nagios
# chown nagios:nagios /usr/local/nagios/ -R
# tar -jxvf nagios-cn-3.2.3.tar.bz2
# ./configure --prefix=/usr/local/nagios/--with-gd-lib=/usr/lib --with-gd-inc=/usr/include--with-nagios-user=nagios --with-nagios-group=nagios--with-command-group=nagios
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
******#make install-webconf//如果是rpm包安装的apache,可以执行,否则报错,做如下操作即可
#vim /usr/local/apache/conf/httpd.conf
在最后添加
Alias /nagios/cgi-bin/images/"/usr/local/nagios/share/images/"
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin/"
Alias /nagios/ "/usr/local/nagios/share/"
AddDefaultCharset utf-8 //防止部分中文乱码
# /usr/local/apache/bin/htpasswd -c/usr/local/nagios/etc/.passwd.conf nagiosadmin //生成nagios口令密码
或者
# /usr/local/apache/bin/htpasswd -bc/usr/local/nagios/etc/.passwd.conf nagiosadmin nagiosadmin
# /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg //检查文件是否出错
#/etc/init.d/nagios start
#/etc/init.d/httpd start
访问http://IP/nagios/ //别名里有/,这里就要有/
# chmod o+w /usr/local/nagios/var/rw/nagios.cmd//更改事件通知时会用到
#/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg//nagios手动重启
安装插件
# tar -zxvf nagios-plugins-1.4.16.tar.gz
# ./configure--prefix=/usr/local/nagios/
# make && make install
#tar -zxvf nrpe-2.12.tar.gz
#./configure--prefix=/usr/local/nagios/
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
#make install-xinetd
#vim /usr/local/nagios/etc/objects/commands.cfg
在最后加上
define command{
或者
define command{
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d //启动nrpe
#/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg//nagios手动重启
配置被监控的
#yum install openssl openssl-devel
# useradd nagios -s /sbin/nologin
#tar -zxvf nagios-plugins-1.4.16.tar.gz -C/usr/local/src/
#./configure --prefix=/usr/local/nagios
#make
#make install
#chown nagios:nagios /usr/local/nagios/ -R
#tar -zxvf nrpe-2.12.tar.gz -C /usr/local/src/
#./configure --prefix=/usr/local/nagios/
#make all
#make install-plugin
#make install-deamon
#make install-daemon-config
#make install-xinetd
#vim /usr/local/nagios/etc/nrpe.cfg
修改如下内容,根据自己需求修改
allowed_hosts=127.0.0.1 //添加ip用逗号分隔
command[check_users]=/usr/local/nagios//libexec/check_users -w5 -c 10
command[check_load]=/usr/local/nagios//libexec/check_load -w15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios//libexec/check_disk -w20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local//nagios/libexec/check_procs-w 5 -c 10 -s Z
command[check_total_procs]=/usr/local//nagios/libexec/check_procs-w 150 -c 200
# vim /etc/xinetd.d/nrpe
修改only from的IP //多个ip用逗号分隔
# vim /etc/services
在最后添加
nrpe 5666/tcp #nrpe
# /etc/init.d/xinetd restart //启动xinetd
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg-d //启动nrpe,没生成/bin或者启动文件,可以从监控端cp一个过来
# netstat -anpt |grep 5666 //查看端口,看nrpe是否启动
添加监控主机和监控服务
例如:
# vim host.cfg
define host{
# parents
define service{
报错解决方法
HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.070second response time
主要是监控端在检测被监控端下/var/www/html/index.html文件,编译安装的apache可定不在这个下面,所以创建一个就好了
在被监控机上#touch /var/www/html/index.html
监控网站主页
# vim commands.cfg
添加
define command{
# vim host.cfg
define service{
监控mysql
查看libexec目录下有没有check_mysql,如果没有,yum installedmysql-devel,在重装nagios-plugin
创建nagios专用数据库
mysql> create database nagios;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on nagios.* tonagios@'localhost' identified by 'nagios';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
测试
# /usr/local/nagios/libexec/check_mysql -H localhost -u nagios-d nagios -p nagios
Uptime: 44649 Threads: 10 Questions: 152675 Slow queries:0 Opens: 292 Flush tables: 1 Open tables: 64 Queries persecond avg: 3.419
# vim commands.cfg //定义命令
在最后添加
#check mysql
define command{
command_name check_mysql
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -unagiosuser -d nagios -p nagiospwd
}
# vim host.cfg //定义主机
define service{
报错解决办法
1.
Can't locate RRDs.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/sbin/show.cgi line 9., referer: http://jk.ylwkj.com/nagios/cgi-bin/status.cgi?host=all
#cp -rp /usr/local/rrdtool/lib/perl/5.8.8/x86_64-linux-thread-multi/ /usr/lib64/perl5/site_perl/5.8.8/
- nagios监控系统搭建
- nagios监控平台搭建
- 搭建nagios监控
- nagios 监控环境搭建
- nagios监控环境搭建
- 搭建nagios监控平台
- 使用Nagios搭建监控服务器
- linux下搭建nagios监控
- nagios监控服务器的搭建
- Ubuntu上快速搭建Nagios监控
- Ubuntu上快速搭建Nagios监控
- Nagios监控搭建与配置详细步骤
- ubuntu下nagios监控环境搭建
- Ubuntu上快速搭建Nagios监控
- Nagios搭建配置及监控脚本开发
- 搭建Nagios监控环境遇到的几个问题
- nagios监控
- Nagios 监控
- 安装bumblebee解决双显卡笔记本安…
- 搭建svn版本管理器
- ubuntu常用设置
- Effective C++ 学习笔记1
- Ubuntu下安装KVM
- 搭建nagios监控
- 搭建cacti监控
- mysql主从同步
- LAMP
- LNMP+ZendGuardLoader+eAccelerato
- HTTP请求方法
- vsftp虚拟用户
- Nginx负载均衡配置文件
- 关于qt中的tr()函数