nagios监控windows及linux从而实现飞信报警-创新互联

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=RedHatEnterpriseLinuxserver

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=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-broker

root@localhostnagios-3.2.1]#makeall

[root@localhostnagios-3.2.1]#makeinstall

(-Thisinstallstheinitscriptin/etc/rc.d/init.d)

makeinstall-commandmode

-Thisinstallsandconfigurespermissionsonthe

directoryforholdingtheexternalcommandfile

makeinstall-config

-Thisinstallssampleconfigfilesin/usr/local/nagios/etc

进入nagios目录

cd/usr/local/nagios/

在http服务器的配置目录(conf.d)下形成nagiosweb程序

cdnagios-cn-3.2.3

makeinstall-webconf

创建一个登陆nagiosweb程序的用户这个账号在以后通过web登陆nagios认证时使用

htpasswd-c/usr/local/nagios/etc/htpasswd.usersnagiosadmin

启动apache

servicehttpdstartchkconfighttpdon

安装nagios插件

./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios

或者

./configure--with-nagios-user=nagios--with-nagios-group=nagios

make

makeinstall

将nagios服务加入chkconfig管理之类

chkconfig--addnagios

chkconfig--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会报错,原因,是无可监控

打开该文件中的其他主机比如windows

39cfg_file=/usr/local/nagios/etc/objects/windows.cfg

重启服务

windows检测客户端配置

Snmp161

Nsclienrt12489check_nt

Nrpe5666

naclient改变里面的ns.ini

然后从其windows上的ncclient

在nagios服务器上,更改object下的window。dfg定义

重启nagios服务

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

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

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

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

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=nagios

make&&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-d

nrpe服务器段

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-plugin

2.commands.cfg定义外部构件nrpe

vim/usr/local/nagios/etc/objects/commands.cfg

增加

definecommand{

command_namecheck_nrpe

command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$

}

3.为了监控linux系统修改nagios.cfg

vim/usr/local/nagios/etc/nagios.cfg

添加一行

cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg

4.在/usr/local/nagios/etc/objects创建mylinux.cfg

definehost{

uselinux-server;Inheritdefaultvaluesfromatemplate

host_namemylinux;Thenamewe'regivingtothishost

aliasmylinux;Alongernameassociatedwiththehost

address192.168.101.110;IPaddressofthehost

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck-swap

check_commandcheck_nrpe!check_swap

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_load

check_commandcheck_nrpe!check_load

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck-disk

check_commandcheck_nrpe!check_had1

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_user

check_commandcheck_nrpe!check_users

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck_procs

check_commandcheck_nrpe!check_total_procs

}

改变数组

chownnagios.nagiosmylinux.cfg

5实现飞信报警

脚本(附件下载)

a、将飞信的文档传入linux系统,将库文件放入/usr/lib目录

chmoda+xfetion

b、使用下列命令测试./fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME

c.编辑vim/usr/local/nagios/etc/objects/contacts.cfg(这个文件可以不修改)

vim/usr/local/nagios/etc/objects/templates.cfg

34service_notification_commandsnotify-service-by-fetion;sendservicenotificationsviaemail

35host_notification_commandsnotify-service-by-fetion;sendhostnotificationsviaemail

d。定义命令

vim/usr/local/nagios/etc/objects/commands.cfg

definecommand{

command_namenotify-service-by-fetion

command_line/usr/bin/fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME

}

check_nrpe语法:

check_nrpe...-c[-a]

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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前题目:nagios监控windows及linux从而实现飞信报警-创新互联
文章转载:http://hbruida.cn/article/dcscph.html