您的位置:首页 > 运维架构 > Linux

nagios监控windows及linux从而实现飞信报警

2013-11-02 13:47 549 查看
nagios主要功能是实现报警yum环境搭建:[root@localhost~]#mount/dev/cdrom/mnt/cdrom/mount:blockdevice/dev/cdromiswrite-protected,mountingread-only[root@localhost~]#vim/etc/yum.repos.d/rhel-debuginfo.repo[rhel-server]name=RedHatEnterpriseLinuxserverbaseurl=file:///mnt/cdrom/Serverenabled=1gpgcheck=1gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release安装步骤安装lamp环境yuminstallmysqlmysql-develhttpdphpphp-gdphp-mbstring测试lamp环境创建一个组nagcmd[root@localhostnagios-3.2.1]#groupaddnagcmd创建一个账号nagios[root@localhostnagios-3.2.1]#useradd-mnagios加入组[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdnagios将apache账号也添加进来[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdapache解压缩cdnagios-cn-3.2.3配置./configure--with-command-group=nagcmd--enable-event-broker或者./configure--with-command-group=nagcmd--prefix=/usr/local/nagios--sysconfdir=/etc/nagios--enable-event-brokerroot@localhostnagios-3.2.1]#makeall[root@localhostnagios-3.2.1]#makeinstall(-Thisinstallstheinitscriptin/etc/rc.d/init.d)makeinstall-commandmode-Thisinstallsandconfigurespermissionsonthedirectoryforholdingtheexternalcommandfilemakeinstall-config-Thisinstallssampleconfigfilesin/usr/local/nagios/etc进入nagios目录cd/usr/local/nagios/在http服务器的配置目录(conf.d)下形成nagiosweb程序cdnagios-cn-3.2.3makeinstall-webconf创建一个登陆nagiosweb程序的用户这个账号在以后通过web登陆nagios认证时使用htpasswd-c/usr/local/nagios/etc/htpasswd.usersnagiosadmin启动apacheservicehttpdstartchkconfighttpdon安装nagios插件./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios或者./configure--with-nagios-user=nagios--with-nagios-group=nagiosmakemakeinstall将nagios服务加入chkconfig管理之类chkconfig--addnagioschkconfig--addnagios检查nagios的配置文件的语法是否正确/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg可以将/usr/local/nagios/bin加入命令搜索路径中vim.bashrc..bashrc重新读取环境文件可以将/usr/local/nagios/etc/nagios.cfg设置为一个连接ln-s/usr/local/nagios/etc/nagios.cfg/etc/nagios.cfg检查语法nagios-v/etc/nagios.cfg启动nagios服务启动httpd服务编辑vim/usr/local/nagios/etc/nagios.cfg注释36行#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg重启nagios会报错,原因,是无可监控打开该文件中的其他主机比如windows39cfg_file=/usr/local/nagios/etc/objects/windows.cfg重启服务windows检测客户端配置Snmp161Nsclienrt12489check_ntNrpe5666naclient改变里面的ns.ini然后从其windows上的ncclient在nagios服务器上,更改object下的window。dfg定义重启nagios服务










linux客户段安装先创建账号nagios[root@localhost~]#yuminstallmysqlmysql-serverhttpdmysql-devel[root@localhost~]#useraddnagios安装插件./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios或者./configure--with-nagios-user=nagios--with-nagios-group=nagiosmake&&makeinstall安装nrpe(客户端和服务端都需要)#tar-zxvfnrpe-2.12.tar.gz#cdnrpe-2.12.tar.gz#./configure--with-nrpe-user=nagios\--with-nrpe-group=nagios\--with-nagios-user=nagios\--with-nagios-group=nagios\--enable-command-args\--enable-ssl#makeall#makeinstall-plugin#makeinstall-daemon#makeinstall-daemon-config编辑客户端nrpe配置文件vim/usr/local/nagios/etc/nrpe.cfg(allowed_hosts=192.168.101.102(服务器地址))以进程的方式启动nrpe/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-dnrpe服务器段1.#./configure--with-nrpe-user=nagios\--with-nrpe-group=nagios\--with-nagios-user=nagios\--with-nagios-group=nagios\--enable-command-args\--enable-ssl#makeall#makeinstall-plugin2.commands.cfg定义外部构件nrpevim/usr/local/nagios/etc/objects/commands.cfg增加definecommand{command_namecheck_nrpecommand_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$}3.为了监控linux系统修改nagios.cfgvim/usr/local/nagios/etc/nagios.cfg添加一行cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg4.在/usr/local/nagios/etc/objects创建mylinux.cfgdefinehost{uselinux-server;Inheritdefaultvaluesfromatemplatehost_namemylinux;Thenamewe'regivingtothishostaliasmylinux;Alongernameassociatedwiththehostaddress192.168.101.110;IPaddressofthehost}defineservice{usegeneric-servicehost_namemylinuxservice_descriptioncheck-swapcheck_commandcheck_nrpe!check_swap}defineservice{usegeneric-servicehost_namemylinuxservice_descriptioncheck_loadcheck_commandcheck_nrpe!check_load}defineservice{usegeneric-servicehost_namemylinuxservice_descriptioncheck-diskcheck_commandcheck_nrpe!check_had1}defineservice{usegeneric-servicehost_namemylinuxservice_descriptioncheck_usercheck_commandcheck_nrpe!check_users}defineservice{usegeneric-servicehost_namemylinuxservice_descriptioncheck_procscheck_commandcheck_nrpe!check_total_procs}改变数组chownnagios.nagiosmylinux.cfg5实现飞信报警脚本(附件下载)a、将飞信的文档传入linux系统,将库文件放入/usr/lib目录chmoda+xfetionb、使用下列命令测试./fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAMEc.编辑vim/usr/local/nagios/etc/objects/contacts.cfg(这个文件可以不修改)vim/usr/local/nagios/etc/objects/templates.cfg34service_notification_commandsnotify-service-by-fetion;sendservicenotificationsviaemail35host_notification_commandsnotify-service-by-fetion;sendhostnotificationsviaemaild。定义命令vim/usr/local/nagios/etc/objects/commands.cfgdefinecommand{command_namenotify-service-by-fetioncommand_line/usr/bin/fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME}check_nrpe语法:check_nrpe...-c<command>[-a<argument><argument><argument>]check_nrpe的内置命令:·CheckAlwaysCRITICAL(check)·CheckAlwaysOK(check)·CheckAlwaysWARNING(check)·CheckCPU(check)·CheckCRITICAL(check)·CheckCounter(check)·CheckEventLog/CheckEventLog(check)·CheckFile(check)·CheckFileSize(check)·CheckMem(check)·CheckMultiple(check)·CheckOK(check)·CheckProcState(check)·CheckServiceState(check)·CheckTaskSched/CheckTaskSched(check)·CheckUpTime(check)·CheckVersion(check)·CheckWARNING(check)·CheckWMI/CheckWMI(check)·CheckWMIValue(check)用法如:#check_nrpe...-cCheckCPU-awarn=80crit=90time=20mtime=10stime=4
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息