nagios监控安装
2017-04-26 10:09
120 查看
#以前做的笔记,现在自己都看不懂了,日后用再研究吧。
一、Nagios服务端安装:
基础支持套件:
1.2创建用户和组:
2.安装nagios
修改nagios报警发送邮件地址(需要安装sendmail)
设置开机启动
3.安装nagios插件
4.安装nrpe
启动nagios之前先检查一下配置文件nagios.cfg
二.Nagios客户端安装
开始时间同步服务
查看配置文件
添加nagios客户端用户
1.安装nagios-plugins
检查安装:
2.安装nrpe
3.安装其他相关插件【iostat】
#for monitor iostat
sar是监控物理组件的关键
*配置开发的几个脚本插件
配置nrpe客户端允许监控的主机ip:
配置nrpe监控项目:
启动nrpe守护进程:
测试nrpe
三、配置服务端文件
1. 修改主配置文件nagios.cfg
2.修改hosts.cfg配置文件
#vi /usr/local/nagios/etc/object/hosts.cfg
3.修改services.cfg配置文件:
排错:nagios服务端services.cfg配置文件的check_nrpe!check_disk等于
/usr/localnagios/libexec/check_nrpe–H 10.1.1.13 –c check_disk
可以用来测试客户端的nrpe文件
###############################################################
Nagios services.cfg扩展:
vi /usr/local/nagios/etc/services/10.1.1.14.cfg
######################################################
四、主动监控
监控端口:
测试:
监控url地址:
测试:
#############---监控普通域名—www.darren.com---#####################
####--监控特殊域名---www.darren.com/darren/index.php/@%2e/j4*&----#########
模板的作用:监控不同主机同一服务
一、Nagios服务端安装:
基础支持套件:
#rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel如果系统中没有这些套件,使用yum 安装
#yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel #Yum install -y httpd php php-gd
1.2创建用户和组:
Useradd -m Nagios Groupadd nagcmd Usermod –a –G nagcmd Nagios Usermod –a –G nagcmd apacheNagios 和Apache可以访问同一个目录。
2.安装nagios
tar zxvf nagios-3.4.3.tar.gz ./configure--prefix=/usr/local/nagios--with-command-group=nagcmd makeall makeinstall makeinstall-init makeinstall-commandmode makeinstall-config生成用于登陆nagios的用户密码:
#在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件: htpasswd-c /usr/local/nagios/etc/htpasswd.users darren
修改nagios报警发送邮件地址(需要安装sendmail)
vi /usr/local/nagios/etc/objects/contacts.cfg+35
设置开机启动
chkconfig--add nagios chkconfig--level 35 nagios on chkconfig--list Nagios
3.安装nagios插件
tarzxvf nagios-plugins-1.4.16.tar.gz cdnagios-plugins-1.4.16 ./configure –with-nagios-user=nagios–with-nagios-group=nagios --enable-perl-module make&& make install
4.安装nrpe
tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12.tar.gz ./configure make all make install-plugin make install-daemon make install-daemon-config
启动nagios之前先检查一下配置文件nagios.cfg
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg启动nagios:
/usr/local/nagios/bin/nagios-d /usr/local/nagios/etc/nagios.cfg
二.Nagios客户端安装
后面编译的软件有perl程序,这里要提前设置一下环境变量 echo'export LC_ALL=C'>> /etc/profile tail-1 /etc/profile source/etc/profile
开始时间同步服务
echo '#time sync by darren at 2016-2-1'>>/var/spool/cron/root echo'*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null2>&1'>>/var/spool/cron/root
查看配置文件
crontab-l */10 * * * * /usr/sbin/ntpdatepool.ntp.org >/dev/null 2>&1 /usr/sbin/ntpdatepool.ntp.org
添加nagios客户端用户
groupaddnagios /usr/sbin/addusernagios -M -s /sbin/nologin
1.安装nagios-plugins
tar zxvf nagios-plugins-1.4.16.tar.gz cd nagios-plugins-1.4.16 ./configure\ --with-nagios-user=nagios--with-nagios-group=nagios --enable-perl-modules make && make install
检查安装:
ls /usr/local/nagios/libexec/ | wc -l
2.安装nrpe
tar-zxvf nrpe-2.15.tar.gz cdnrpe-2.15 ./configure makeall makeinstall-plugin makeinstall-daemon make install-daemon-config
3.安装其他相关插件【iostat】
tar -zxvf Params-Validate-0.91.tar.gz cd Params-Validate-0.91 perl Makefile.PL make make install cd ..
tar -zxvf Class-Accessor-0.31.tar.gz cd Class-Accessor-0.31 perl Makefile.PL make make install cd ..
tar zxvf Config-Tiny-2.12.tar.gz cd Config-Tiny-2.12 perl Makefile.PL make make install cd ..
tar zxvf Math-Calc-Units-1.07.tar.gz cd Math-Calc-Units-1.07 perl Makefile.PL make make install cd ..
tar zxvf Regexp-Common-2010010201.tar.gz cd Regexp-Common-2010010201 perl Makefile.PL make make install cd ..
tar zxvf Nagios-Plugin-0.34.tar.gz cd Nagios-Plugin-0.34 perl Makefile.PL make make install cd ..---------------Dear,我是分隔符-----------------
#for monitor iostat
yum install sysstat -y这个命令是安装系统性能分析工具,监控系统性能时程序或脚本会调用这些工具。
sar是监控物理组件的关键
*配置开发的几个脚本插件
cp /check_memory.pl或iostat.pl /usr/local/nagios/libexec check_memory和check_iostat授权为755 yum install dos2unix -y dos2unix/usr/local/nagios/libexec/check_memory.pl dos2unix/usr/local/nagios/libexec/check_iostat
配置nrpe客户端允许监控的主机ip:
vim /usr/local/nagios/etc/nrpe.cfg +79文件,在参数allowed_hosts后添加监控机ip(多个ip以逗号分隔。
allowed_hosts=127.0.0.1,10.1.1.19
配置nrpe监控项目:
vim /usr/local/nagios/etc/nrpe.cfg command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5 -c 30,25,20 command[check_mem]=/usr/local/nagios/libexec/check_memory.pl-w 10% -c 3% command[check_disk]=/usr/local/nagios/libexec/check_disk-w 7% -p / command[check_swap]=/usr/local/nagios/libexec/check_swap-w 20% -c 10% command[check_iostat]=/usr/local/nagios/libexec/check_iostat-w 6 -c 10
启动nrpe守护进程:
/usr/local/nagios/bin/nrpe-c /usr/local/nagios/etc/nrpe.cfg –d 将以上命令加入到 /etc/rc.local设置开机启动。 echo‘/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d’ >>/etc/rc.local nrpe默认端口号是5666 netstat –lnt | grep 5666
测试nrpe
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 NRPEv2.15正常返回版本信息说明服务正常。
三、配置服务端文件
1. 修改主配置文件nagios.cfg
vi /usr/local/nagios/etc/nagios.cfg cfg_file=/usr/local/nagios/etc/objects/commands.cfg cfg_file=/usr/local/nagios/etc/objects/contacts.cfg cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg cfg_file=/usr/local/nagios/etc/objects/templates.cfg cfg_file=/usr/local/nagios/etc/objects/hosts.cfg cfg_file=/usr/local/nagios/etc/objects/services.cfg chown –R nagios.nagios /usr/local/nagios/etc/
2.修改hosts.cfg配置文件
#vi /usr/local/nagios/etc/object/hosts.cfg
define host{ use linux-server host_name LAMP alias LAMP address 10.1.1.13 } define host{ use linux-server host_name LNMP alias LNMP
address 10.1.1.16 } define hostgroup{ hostgroup_name hostgroup alias hostgroupalias members LAMP,LNMP }##################################################
3.修改services.cfg配置文件:
vi/usr/local/Nagios/etc/object/services.cfg
define service{ use generic-service host_name LAMP,LNMP service_description check_load check_command check_nrpe!check_load max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }
define service{ use generic-service host_name LAMP,LNMP service_description check_disk check_command check_nrpe!check_disk max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }
define service{ use generic-service host_name LAMP,LNMP service_description check_disk check_command check_nrpe!check_local_swap max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }
define service{ use generic-service host_name LAMP,LNMP service_description check_http check_command check_nrpe!check_http max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }
define service{ use generic-service host_name LAMP,LNMP service_description check_mysql check_command check_nrpe!check_mysql max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }#############################################################
排错:nagios服务端services.cfg配置文件的check_nrpe!check_disk等于
/usr/localnagios/libexec/check_nrpe–H 10.1.1.13 –c check_disk
可以用来测试客户端的nrpe文件
###############################################################
Nagios services.cfg扩展:
启用cfg_dir=/usr/local/nagios/etc/servers vi /usr/local/nagios/etc/nagios.cfg 添加下面一行: cfg_dir=/usr/local/nagios/etc/servers 清空cfg_file=/usr/local/nagios/etc/objects/services.cfg >/usr/local/nagios/etc/objects/services.cfg 在/usr/local/nagios/etc/servers添加每台主机。 vi /usr/local/nagios/etc/servers/10.1.1.13.cfg######################################################
define service{ use generic-service host_name LAMP service_description check_disk check_command check_nrpe!check_disk } ###################################################### define service{ use generic-service host_name LAMP service_description check_swap check_command check_nrpe!check_swap }#####################################################
vi /usr/local/nagios/etc/services/10.1.1.14.cfg
######################################################
define service{ use generic-service host_name LNMP service_description check_disk check_command check_nrpe!check_disk } ###################################################### define service{ use generic-service host_name LNMP service_description check_swap check_command check_nrpe!check_swap }#####################################################
四、主动监控
监控端口:
测试:
cd /usr/local/nagios/libexec/ ./check_tcp –H 10.1.1.13 –p22修改配置文件:
cd /usr/local/nagios/etc/objects vi services.cfg#####################################################
defineservice{ use generic-service host_name LAMP service_description www_80 check_command check_tcp!80 max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }####################################################
defineservice{ use generic-service host_name LAMP service_description mysql_3306 check_command check_tcp!3306 max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }###############################################
监控url地址:
测试:
./libexec/check_http -Hwww.baidu.com -C 30,14修改配置文件:
cd /usr/local/nagios/etc/objects vi services.cfg#####################################################
defineservice{ use generic-service host_name LAMP service_description www.darrenwang.com
#############---监控普通域名—www.darren.com---#####################
check_command check_http#######---监控特殊域名--- www.darren.com/darren.test.html--#########
#check_command check_http! -H -u /darren/test.html
####--监控特殊域名---www.darren.com/darren/index.php/@%2e/j4*&----#########
#check_command check_http!-H -u“darren/index.php/@%2e/j4”#带特殊字符的需要用双引号
max_check_attempts 2 normal_check_interval 4 retry_check_interval 4 check_period 24x7 notification_interval 360 notification_period 24x7 contact_groups admins process_perf_data 1 }####################################################
模板的作用:监控不同主机同一服务
相关文章推荐
- Nagios远程监控软件的安装与配置详解
- Nagios3.0 NRPE 安装 监控远程Linux服务
- UBUNTU9.10安装nagios监控软件实现手机短信通知
- Nagios 监控 Linux 服务器 运行情况 快速安装手册
- LINUX开源监控平台Nagios(插件的安装和使用)
- Nagios远程监控安装与配置详解图文第1/3页
- nagios3.20安装配置笔记(带飞信短信报警,mssql和mysql监控)
- linux下Nagios远程监控安装与配置详解
- 编译安装和配置nagios的全套监控系统笔记
- Linux系统监控二:Nagios源码安装
- Nagios远程监控软件的安装与配置详解(上)
- linux 监控软件 Nagios编译安装的详细
- Nagios远程监控软件的安装与配置详解
- Ubuntu9.10平台上安装Nagios进行系统资源的监控
- nagios3.20安装配置笔记(带飞信短信报警,mssql和mysql监控)
- Nagios远程监控软件的安装与配置详解 ZT
- LINUX开源监控平台Nagios(NRPE的安装配置)
- nagios,ndoutils简要安装步骤及分布式监控环境的建立
- Nagios监控系统安装及配置文档