Nagios监控
一、软件版本11.1、主程序nagios-3.2.3.tar.gz11.2、插件 nagios-plugins-1.4.15.tar.gz11.3、插件 nrpe-2.12.tar.gz11.4、飞信报警库及脚本 lib/ fetion1二、Nagios监控服务器端/8.230,程序安装12.1、Yum安装以下软件12.2、创建nagios 用户和组12.3、编译安装Nagios 主程序12.4、安装nagios-plugins插件22.5、将apache的运行用户加到nagios组里面22.6、增加web访问账号22.7、查看cgi.cfg文件22.8、编译安装nrpe插件22.9、nagios随系统启动3三、Nagios 被监控客户端/8.23133.1、增加用户nagios33.2、编译安装nagios-plugins插件33.3、编译安装nrpe插件33.4、修改services配置文件,在最后末尾增加43.5、修改nrpe配置文件43.6、启动基于xinetd 的nrpe服务43.7、测试回到8.230主监控服务器上4四、Nagios监控服务器端/8.230 主程序配置44.1、配置文件分组简介44.2、在定义配置文件路经,这里可以自定义配置文件.54.3、定义配置lxr 联系人新增配置文件54.4、定义配置lxrgroup联系组-新增配置文件54.5、定义配置host主机文件,新增配置文件64.6、定义配置hostgroup主机组文件,新增配置文件64.7、定义配置serivcegroup服务组文件,新增配置文件64.8、定义配置serivce服务文件,以上面所有的主机和组。在此配置文件调用。64.9、定义飞信短信报警机器人75.0、定义飞信短信报警代码,在末行增加7五、常用测试命令75.1、定义被监控端的命令比如swap75.2、监控服务端nrpe测试,swap命令8一、 软件版本1.1、主程序nagios-3.2.3.tar.gz下载地址:http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz/download1.2、插件 nagios-plugins-1.4.15.tar.gzhttp://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download1.3、插件 nrpe-2.12.tar.gz下载地址:http://down./data/165101#1.4、飞信报警库及脚本 lib/ fetion下载地址:http://bbs.it-adv.net/viewthread.php?tid=1081&extra=page%3D1
二、 Nagios监控服务器端/8.230,程序安装2.1、Yum安装以下软件# yum-y install httpd gcc glibc glibc-common gd gd-devel php openssl-develxinetd
2.2、创建nagios 用户和组# useradd nagios# passwd nagios# mkdir/usr/local/nagios# chown nagios.nagios /usr/local/nagios2.3、编译安装Nagios 主程序# tar -xvf nagios-3.2.3.tar.gz# cd nagios-3.2.3#./configure --prefix=/usr/local/nagios --with-command-group=nagios#make all#make install# make install-init
# make install-config# make install-commandmode#make install-webconf(查看是否有/usr/local/nagios/etc、bin、sbin、share、var、libexec这六个目录,如果有,表示安装成功)2.4、安装nagios-plugins插件#tar -xvf nagios-plugins-1.4.15.tar.gz#cd nagios-plugins-1.4.15./configure--prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios#make && make installls /usr/local/nagios/libexec(会显示很多应用脚本)2.5、将apache的运行用户加到nagios组里面#usermod -G nagios apache2.6、增加web访问账号#cat /etc/httpd/conf.d/nagios.conf | grephtpasswdAuthUserFile /usr/local/nagios/etc/htpasswd.usersAuthUserFile /usr/local/nagios/etc/htpasswd.users#htpasswd -c/usr/local/nagios/etc/htpasswd.users nagiosadmin2.7、查看cgi.cfg文件# grep nagiosadmin /usr/local/nagios/etc/cgi.cfgauthorized_for_system_information=nagiosadminauthorized_for_configuration_information=nagiosadminauthorized_for_system_commands=nagiosadminauthorized_for_all_services=nagiosadminauthorized_for_all_hosts=nagiosadminauthorized_for_all_service_commands=nagiosadminauthorized_for_all_host_commands=nagiosadmin2.8、编译安装nrpe插件#tar -xvf nrpe-2.12.tar.gz#cd nrpe-2.12# ./configure --enable-ssl --with-ssl-lib#make all# make install-plugin# make install-daemon# make install-daemon-config#make install-xinetd2.9、nagios随系统启动#chkconfig --add nagios#chkconfig nagios on#/etc/init.d/httpd start验证配置是否配置正确:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg如果不报错,可以启动nagios服务:service nagios startIE浏览器地址栏输入:192.168.8.230/nagios,敲入用户名及密码,就可以看到如下界面了http://2999835.blog./e/u/themes/default/images/spacer.gif
三、 Nagios 被监控客户端/8.2313.1、增加用户nagios# yum-y install httpd gcc glibc glibc-common gd gd-devel php openssl-develxinetd
# useradd nagios# passwd nagios
3.2、编译安装nagios-plugins插件#tar -xvf nagios-plugins-1.4.15.tar.gz#cd nagios-plugins-1.4.15./configure--prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios#make && make installls /usr/local/nagios/libexec(会显示很多应用脚本)
3.3、编译安装nrpe插件#tar -xvf nrpe-2.12.tar.gz#cd nrpe-2.12# ./configure --enable-ssl --with-ssl-lib#make all# make install-plugin# make install-daemon# make install-daemon-config#make install-xinetd3.4、修改services配置文件,在最后末尾增加#cat /etc/services | grep nrpenrpe 5666/tcp # nrpe
3.5、修改nrpe配置文件#vim /etc/xinetd.d/nrpeonly_from = 192.168.8.230à监控服务器地址3.6、启动基于xinetd 的nrpe服务#/etc/init.d/xinetd start#netstat -nap | grep 5666tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 1284/xinetd3.7、测试回到8.230主监控服务器上# /usr/local/nagios/libexec/check_nrpe -H 192.168.8.231返回 “NRPE v2.12” 表示部署成功四、 Nagios监控服务器端/8.230 主程序配置4.1、配置文件分组简介cgi.cfg---à控制相关的cgi 脚本resoure.cfg -à系统传入参数配置文件commands.cfg-à定义命令配置文件timeperiods.cfgà监视时段配置文件
配置分组自定义contacts .cfg-à 定义了故障报警的联系人contactsgroup.cfg---à定义了故障报警联系组
hosts--à主机配置文件hostgroups-à主机组配置文件
services-à服务配置文件servicesgroupà服务组配置文件
4.2、 在定义配置文件路经,这里可以自定义配置文件.#vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg 注释掉。cfg_file=/usr/local/nagios/etc/objects/contacts.cfg注释掉末尾增加以下内容cfg_file=/usr/local/nagios/my/lxrcfg_file=/usr/local/nagios/my/lxrgroupcfg_file=/usr/local/nagios/my/hostcfg_file=/usr/local/nagios/my/hostgroupcfg_file=/usr/local/nagios/my/serivcegroupcfg_file=/usr/local/nagios/my/service
4.3、定义配置lxr 联系人新增配置文件# mkdir /usr/local/nagios/my# cd /usr/local/nagios/my# vim lxrdefine contact{ contact_name Alvin-zeng use generic-contact alias Alvin-zeng-admin service_notification_commands notify-service-by-email,service-notify-by-fetion host_notification_commands notify-host-by-email,host-notify-by-fetion email alvin.zyong@gmail.com pager 136xxxxxxx}
4.4、定义配置lxrgroup联系组-新增配置文件# vim lxrgroupdefine contactgroup{ contactgroup_name lxrgp #:组名随便定义 alias zeng #:别名随便定义 members Alvin-zeng #这里将上面的联系人成员。加到这个组里面 }
4.5、定义配置host主机文件,新增配置文件# vim hostdefine host{ host_name test-2 #被监空端真实的主机名,主要不要留空格。 alias test max_check_attempts 5 address 192.168.8.231 }#:被监客户端IP地址4.6、定义配置hostgroup主机组文件,新增配置文件# vim hostgroupdefine hostgroup{ hostgroup_name group1 #:组名 alias group members test-2 #:将test-2 加到这个组里面来}4.7、定义配置serivcegroup服务组文件,新增配置文件# vim serivcegroupdefine servicegroup{ servicegroup_name tt #:组名 alias TT #:别名}4.8、定义配置serivce服务文件,以上面所有的主机和组。在此配置文件调用。# vim servicedefine service{ hostgroup_name group1 #这里调用主机组或者单个主机 servicegroups tt #这里调用服务组或者单个服务 service_description check_swap #检查swap check_period 24x7 #检查24小时 max_check_attempts 1 normal_check_interval 1 retry_check_interval 1 notification_options w,u,c,r notification_interval 1 notification_period 24x7 check_command check_nrpe!check_swap contact_groups lxrgp #这里调用联系人组或者单个联系人}4.9、定义飞信短信报警机器人先解压,解压完后。找到lib 目录库和fetion脚本#mkdir /usr/local/fetion/#mkdir /usr/local/fetion/# cp lib//usr/local/fetion/# cp fetion/usr/local/fetion/
5.0、定义飞信短信报警代码,在末行增加#vim /usr/local/nagios/etc/objects/commands.cfg
define command { command_name host-notify-by-fetion ; command_lineLD_LIBRARY_PATH=/usr/local/fetion/lib /usr/local/fetion/fetion --mobile=13692216****--pwd=feishu8 --to=13692216****--msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$ }
# 'notify-service-by-fetion' command definitiondefine command { command_name service-notify-by-fetion command_line LD_LIBRARY_PATH=/usr/local/fetion/lib /usr/local/fetion/fetion --mobile=13692216****--pwd=feishu8 --to=13692216****--msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$ }# ' check_nrpe ' command definitiondefine command{ command_name check_nrpe command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}五、 常用测试命令5.1、定义被 监控端的命令比如swap#vim /usr/local/nagios/etc/nrpe.cfg
command=/usr/local/nagios/libexec/check_swap -w 50% -c 20%5.2、监控服务端nrpe测试,swap命令#cd /usr/local/nagios/libexec/#./check_nrpe -H 192.168.8.231 -c check_swapSWAP OK - 100% free (1983 MB out of 1983 MB) |swap=1983MB;991;396;0;1983
男人与女人,终究也只是欲望的动物吧!真的可以因为爱而结合吗?对不起,我也不知道。。 找不到恐龙,就用蜥蜴顶 男人有冲动可能是爱你,也可能是不爱,但没有冲动肯定是不爱! 打破老婆终身制,实行小姨股份制。引入小姐竞争制,推广情人合同制。 .其实我是一个天才,可惜天妒英才! 我妈常说,我们家要是没有电话就不会这么穷。
页:
[1]