




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
完整安装nagios+cacti+短信和邮件报警 一:安装nagios中用到的其他软件和库文件 yum -y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-server mysql-devel openssl-devel 二:安装和配置nagios3.4.1监控主程序 2.1建立用户和组groupadd nagcmduseradd m nagiosusermod -a -G nagcmd nagiosusermod -a -G nagcmd apache2.2下载最新版nagios3.4.1mkdir downloadswget /sourceforge/nagios/nagios-3.4.1.tar.gz2.3 编译安装cd downloadstar zxvf nagios-3.4.1.tar.gzcd nagios默认安装至/usr/local/nagios/./configure -with-command-group=nagcmd -enable-event-brokermake all & make install & make install-init & make install-config & make install-commandmode & make install-webconfWEB界面的用户名和密码htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin输入密码并确认service httpd restartchkconfig httpd on三:编译安装nagios-plugins-下载最新版本nagios-plugins-1.4.16cd downloadswget /sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gzcd nagios-plugins-1.4.16./configure -with-nagios-user=nagios -with-nagios-group=nagcmd -with-mysqlmake & make installchkconfig -add nagioschkconfig nagios onvim /etc/profile加入PATH=$PATH:/usr/local/nagios/bin检查nagios语法是否正确nagios -v /usr/local/nagios/etc/nagios.cfgservice nagios start3.2 关闭selinux 及修改iptables或关闭iptables关闭selinux的方法 vi /etc/sysconfig/selinux添加 SELINUX=disabled iptables建议开启,然后允许需要开启的端口,一般nagios需要的端口是80和5666(nrpe) vi /etc/sysconfig/iptables service httpd restart 此时已经能从浏览器访问http:/*/nagios 默认用户名nagiosadmin 密码是之前输入过的。 四:监控nagios本机创建fund123目录,用于存放所有相关配置文件cd /usr/local/nagios/etc/mkdir fund123cd /usr/local/nagios/etc/objectscp -v -R * /usr/local/nagios/etc/fund123/文件和目录修改下权限chown -R nagios:nagios fund123修改主配置文件nagios.cfg,修改之前最好先备份下vi /usr/local/nagios/etc/nagios.cfg修改成cfg_file=/usr/local/nagios/etc/fund123/commands.cfgcfg_file=/usr/local/nagios/etc/fund123/contacts.cfgcfg_file=/usr/local/nagios/etc/fund123/timeperiods.cfgcfg_file=/usr/local/nagios/etc/fund123/templates.cfgcfg_file=/usr/local/nagios/etc/fund123/contactgroups.cfgcfg_file=/usr/local/nagios/etc/fund123/hostgroups.cfgcfg_file=/usr/local/nagios/etc/fund123/servicegroups.cfgcfg_dir=/usr/local/nagios/etc/fund123/servers/cfg_dir=/usr/local/nagios/etc/fund123/services/注释掉#cfg_file=/usr/local/nagios/etc/objects/localhost.cfgcp objects/localhost.cfg fund123/servers/local-nagios.cfgvi local-nagios.cfg# Define a host for the local machinedefine host use linux-server ; Name of host template to use ; This host definition will inherit all variablesthat are defined ; in (or inherited by) the linux-server host template definition. host_name local-nagios alias nagios+cacti address 注释掉组的定义,后续会在hostgroups里定义#define hostgroup# hostgroup_name linux-servers ; The name of the hostgroup# alias Linux Servers ; Long name of the group# members localhost ; Comma separated list of hosts that belong to this group# 通过PING检测主机是否存活define service use local-service ; Name of service template to use host_name local-nagios service_description PING check_command check_ping!100.0,20%!500.0,60% # Define a service to check the disk space of the root partition# on the local machine. Warning if 20% free, critical if# 20 users, critical# if 50 users.define service use local-service ; Name of service template to use host_name local-nagios service_description Current Users check_command check_local_users!20!50 # Define a service to check the number of currently running procs# on the local machine. Warning if 250 processes, critical if# 400 users.define service use local-service ; Name of service template to use host_name local-nagios service_description Total Processes check_command check_local_procs!250!400!RSZDT # Define a service to check the load on the local machine.define service use local-service ; Name of service template to use host_name local-nagios service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 # Define a service to check the swap usage the local machine.# Critical if less than 10% of swap is free, warning if less than 20% is freedefine service use local-service ; Name of service template to use host_name local-nagios service_description Swap Usage check_command check_local_swap!20!10 # Define a service to check SSH on the local machine.# Disable notifications for this service by default, as not all users may have SSH enabled.define service use local-service ; Name of service template to use host_name local-nagios service_description SSH check_command check_ssh notifications_enabled 0 # Define a service to check HTTP on the local machine.# Disable notifications for this service by default, as not all users may have HTTP enabled.define service use local-service ; Name of service template to use host_name local-nagios service_description HTTP check_command check_http notifications_enabled 0 wq保存退出定义主机组文件/usr/local/nagios/etc/fund123/hostgroups.cfgvi /usr/local/nagios/etc/fund123/hostgroups.cfg# Nagios Servers Groupdefine hostgroup hostgroup_name NagiosMonitor ;定义的组名,我这里定义的是Nagios监控的所有主机成员,以后有新的主机监控进来都会在这个组里显示 alias Monitor all servers ;别名 members * ;主机组的成员主机,星号代表所有主机,有多个组成员可以用逗号隔开 # Linux System Groupdefine hostgroup hostgroup_name Linux-System ;定义的主机组名称,我这里定义的是Linux系统组 alias linux system members local-nagios ;这里的组成员是local-nagios.cfg定义的“host_name”这个的值 # Windows System Group#define hostgroup# hostgroup_name Windows-System ;这里我定义的是Windows系统组,现在还没有主机成员,所以先注释掉,等有成员机了再添加进来# alias windows system# members # 定义服务组文件/usr/local/nagios/etc/fund123/servicegroups.cfgvi /usr/local/nagios/etc/fund123/servicegroups.cfg# Define an servicegroup for Pingdefine servicegroup servicegroup_name Network alias network connetivity members local-nagios,PING ; 组成员的设置,主机名,服务名的方式表示,中间用逗号分隔 定义联系人组文件/usr/local/nagios/etc/fund123/contactgroups.cfgvi /usr/local/nagios/etc/fund123/contactgroups.cfg#contact groupdefine contactgroup contactgroup_name sagroup ;定义联系人组的名字 alias Nagios Adminstrators ;别名 members nagiosadmin ;联系人组成员保险起见再赋予下fund123 文件权限chown -R nagios:nagios fund123检查配置是否有误cd /usr/local/nagios/bin/nagios -v ./etc/nagios.cfg重启nagios 重启http/etc/init.d/nagios reloadservice httpd restartservice nagios restart五nagios监控windows客户端1下载nscilent+最新版本NSCP-83-x64.msi,网址是/nscp/downloads2安装NSCP-83-x64.msi选择第一个这里第一项填nagios服务器的地址,第二项密码不用填,其余都勾上。3,安装完毕后修改系统服务登陆允许服务与桌面交互。4,配置nagios主控端,增加对2这台机器的监控。cp /usr/local/nagios/etc/fund123/windows.cfg /usr/local/nagios/etc/fund123/servers/20.12.cfgvi 20.12.cfgdefine host use windows-server ; Inherit default values from a template host_name XS-20.12 ; The name were giving to this host alias XS-20.12 ; A longer name associated with the host address 2 ; IP address of the host #define hostgroup# hostgroup_name windows-servers ; The name of the hostgroup# alias Windows Servers ; Long name of the group# 这里注释掉hostgroup的定义,因为我们都统一在hostgroup文件去定义。其余都采用默认,注意把host name这项的内容都改成XS-20.12。注意:这里的继承模板“windows-server”中有定义hostgroup,所以要到templates.cfg中注释掉,不然验证配置文件时会报错。/usr/local/nagios/etc/fund123rootnagios230 fund123# vi templates.cfg# hostgroups windows-servers ;配置修改完成后都需要验证下配置是否正确,然后重启nagios和apachecd /usr/local/nagios/bin/nagios -v ./etc/nagios.cfg/etc/init.d/nagios reloadservice httpd restartservice nagios restart至此windows监控已完毕。六配置sendemail 来发送nagios报警信息下载sendemail程序cd downloads/wget /menu/Software/SendEmail/sendEmail-v1.56.tar.gztar -zxvf sendEmail-v1.56.tar.gz & cd sendEmail-v1.56cp sendEmail /usr/local/binchmod 0755 /usr/local/bin/sendEmail2测试发送邮件用nagios1的邮箱给weihj发一封邮件主题是nagios测试,内容是nagios test 测试sendEmail -f t -s -xu -xp -u nagios测试 -m nagios test 测试默认可能无法显示中文,可以做如下修改sendEmail -f -t -s -xu -xp -u nagios测试 -m nagios test 测试 -o message-content-type=html -o message-charset=utf8这样说明已经能发送邮件了,接下来就是配置到nagios里即可。3配置comand.cfg中的邮件通知cd /usr/local/nagios/etc/fund123/vi command.cfgdefine command command_name notify-host-by-email command_line /usr/bin/printf %b * 详细信息如下 *nNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n | /usr/local/bin/sendEmail -f -t $CONTACTEMAIL$ -s -u * $HOSTALIAS$ is $HOSTSTATE$ * -xu -xp # -o message-charset=utf8define command command_name notify-service-by-email command_line /usr/bin/printf %b * 详细信息如下 *nNotification Type: $NOTIFICATIONTYPE$nService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:n$SERVICEOUTPUT$n | /usr/local/bin/sendEmail -f -t $CONTACTEMAIL$ -s -u * $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ * -xu -xp # -o message-charset=utf8define command command_name notify-host-by-email command_line /usr/bin/printf %b * 详细信息如下 *nNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n | /usr/local/bin/sendEmail -f -t $CONTACTEMAIL$ -s -u * $HOSTALIAS$ is $HOSTSTATE$ * -xu -xp -o message-charset=utf8监控linux客户端:1、服务端安装nrpe 确认安装了apache,gcc,glibc,gd库#tar zxvf NRPE-2.13.tar.gz#cd nrpe-2.13.1#./configure -enable-ssl -with-ssl-lib=/lib/前提是安装了openssl与openssl-devel#rpm -qa | grep ssl 保证:能够抓到 前两个openssl-0.9.8e-12.el5openssl-devel-0.9.8e-12.el5openssl-perl-0.9.8e-12.el5#make all#make install-plugin2、vim 编辑commands.cfg文件定义nrpe对的使用#vim /usr/local/nagios/etc/fund123/commands.cfg/添加如下几行使支持check_nrep#check_nrepdefine command command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 3、新建linux.cfg设置要监控的内容cp /usr/local/nagios/etc/fund123/servers/local-nagios.cfg /usr/local/nagios/etc/fund123/redhat.cfg#vim /usr/local/nagios/etc/fund123/servers/redhat.cfgdefine hostuse linux-serverhost_name redhat /需要修改工作站的主机名 alias mylinuxaddress 4 /工作站主机IP define serviceusegeneric-servicehost_nameredhatservice_descriptioncheck-swap /对下面操作的描述check_commandcheck_nrpe!check_swap/执行检测交换分区命令,监控swap define serviceusegeneric-service host_nameredhatservice_descriptioncheck-loadcheck_commandcheck_nrpe!check_load /监控负载 define service usegeneric-service host_name redhatservice_descriptioncheck-diskcheck_commandcheck_nrpe!check_had1 /监控硬盘 define serviceuse generic-servicehost_nameredhat service_description check-userscheck_command check_nrpe!check_users/监控用户(使用)情况 define service use generic-servicehost_name redhatservice_description otal_procs check_command check_nrpe!check_total_procs/监控进程 /对以上的redhat.cfg文件编辑如果有错,将会导致nagios无法启动;/修改工作站主机的主机名为redhat,保证能够#ping redhat 通信正常,可以选择#echo 4 redhat /etc/hosts#echo 30 nagios /etc/hosts/在服务器端#echo 30nagios /etc/hosts#echo 4redhat/etc/hosts检查nagios的配置文件的正确性#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg/如果上面有错误,请检查系统服务时间是否同步,新建的redhat.cfg是否有语法错误!/在commands.cfg是否添加对nrep使用等#service nagios start 重启nagios服务3、配置工作站上的nagios-plugin/nrpe等1、安装nagios-plugin#useradd nagios#passwd nagios#tar -zxvf nagios-plugins-1.4.16.tar.gz#cd nagios-plugins-1.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 考研西医综合699资料(3篇)
- 净地供地试题及答案
- 桑树栽培工技术考核试卷及答案
- 食品安全管理员试题库及答案解析
- 江山安全员证考试题库及答案解析
- 秩序作业安全知识测试题及答案解析
- 天然气长输管道安全题库及答案解析
- 2025年月嫂试题及答案
- 2025年常州纺织服装职业技术学院单招职业技能测试题库附答案
- 1 x理论考试题库护理及答案解析
- 《中国人民站起来了》课件 (共50张)2025-2026学年统编版高中语文选择性必修上册
- 中国企业供应链金融白皮书(2025)-清华五道口
- 医院常用消毒液的使用及配置方法
- 2022英威腾MH600交流伺服驱动说明书手册
- 分期支付欠薪协议书范本
- 2025年中国药典培训试题及答案
- Q-JJJ 9002-2025 铁路建设项目安全穿透式管理实施指南
- 2025年高校教师资格证之高等教育法规题库(综合题)
- 2025至2030中国数字PCR(dPCR)和实时PCR(qPCR)行业发展趋势分析与未来投资战略咨询研究报告
- 《海堤生态化设计技术指南(T-CHES 139-2024)》知识培训
- DB31/T 1013-2016城市轨道交通地下车站环境质量要求
评论
0/150
提交评论