仓酷云

标题: Linux教程之CentOS 6.2+Nginx+Nagios,手机短信和qq邮箱提示 [打印本页]

作者: 海妖    时间: 2015-1-14 20:41
标题: Linux教程之CentOS 6.2+Nginx+Nagios,手机短信和qq邮箱提示
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!CentOS6.2+Nginx+Nagios,手机短信和qq邮箱提示


注:192.168.0.21办事端
192.168.0.22客户端
情况:两台centos6.064位体系,都已搭建好了源码的lnmp平台
开头附上所需的软件包


1.nagios装置(中文版)
1
2
3
4
5
6
7
8
9
10
11
12
tarxvfnagios-cn-3.2.3.tar.bz2
cdnagios-cn-3.2.3
useradd-m-s/bin/bashnagios
usermod-a-Gnagcmdnagios
./configure--prefix=/usr/local/nagios--with-command-group=nagcmd
make
makeall
makeinstall
makeinstall-init#天生init启动剧本
makeinstall-config#装置示例设置文件
makeinstall-commandmode#设置响应的目次权限
chmodo+rwx/usr/local/nagios/var/rw



2.nagios-plugins装置
1
2
3
4
5
6
7
8
wgethttp://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins
tarzxvfnagios-plugins-1.4.16.tar.gz
cdnagios-plugins-1.4.16
yuminstallmakeapr*autoconfautomakecurlcurl-develgccgcc-c++zlib-devel
opensslopenssl-develpcre-develgdgd-develkernelkeyutilspatchperlperl-devel
kernelkeyutilskernel-headerscompat*mpfrcppglibclibgomplibstdc++-develppl
cloog-pplkeyutils-libs-devellibcom_err-devellibsepol-devellibselinux-devel
krb5-develzlib-devellibXpm*freetypelibjpeg*libpng*php-commonphp-gdncurses*libtool*libxml2libxml2-develpatch-y



1
2
3
./configure--prefix=/usr/local/nagios--with-mysql=/home/mysql/
make
makeinstall





3.nrpe装置
1
2
3
4
5
6
7
8
9
10
11
12
tarxzvfnrpe-2.12.tar.gz
cdnrpe-2.12
./configure
make
./configure
makeall
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config
cpsrc/check_nrpe/usr/local/nagios/libexec/
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
echo/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d>>/etc/rc.local



1
2
3
4
5
要重启nrpe举行就先杀失落举行,然后重启
kill`psaux|grepnrpe|grep-vgrep|awk{print$2}`
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
本机测试下:
/usr/local/nagios/libexec/check_nrpe-Hlocalhost-ccheck_users





到场体系办事

1
2
3
4
5
6
到场体系办事并设为开机主动
chkconfig--addnagios
chkconfignagioson
chownnagios.nagios/usr/local/nagios/var/rw
#测试设置文件是不是准确
/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg





增加别号下令,便利测试设置文件
1
2
3
4
5
vi~/.bashrc
在内里用alias来自界说一个下令来取代,这里我用check
aliascheck=/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
source~/.bashrc
此时能够用check下令来检测设置文件了





修正接洽人邮箱,修正为用于报警吸收的邮件地点
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
vi/usr/local/nagios/etc/objects/contacts.cfg
###############################################################################
#CONTACTS.CFG-SAMPLECONTACT/CONTACTGROUPDEFINITIONS
#
#LastModified:05-31-2007
#
#NOTES:Thisconfigfileprovidesyouwithsomeexamplecontactandcontact
#groupdefinitionsthatyoucanreferenceinhostandservice
#definitions.
#
#Youdontneedtokeepthesedefinitionsinaseparatefilefromyour
#otherobjectdefinitions.Thishasbeendonejusttomakethings
#easiertounderstand.
#
###############################################################################
###############################################################################
###############################################################################
#
#CONTACTS
#
###############################################################################
###############################################################################
#Justonecontactdefinedbydefault-theNagiosadmin(thatsyou)
#Thiscontactdefinitioninheritsalotofdefaultvaluesfromthegeneric-contact
#templatewhichisdefinedelsewhere.
definecontact{
contact_namenagiosadmin;Shortnameofuser
usegeneric-contact;Inheritdefaultvaluesfromgeneric-contacttemplate(definedabove)
aliasNagiosAdmin;Fullnameofuser
emailnagios@localhost;<<*****CHANGETHISTOYOUREMAILADDRESS******
}
###############################################################################
###############################################################################
#
#CONTACTGROUPS
#
###############################################################################
###############################################################################
#Weonlyhaveonecontactinthis***configurationfile,sothereis
#noneedtocreatemorethanonecontactgroup.
definecontactgroup{
contactgroup_nameadmins
aliasNagiosAdministrators
membersnagiosadmin
}
界说check_nrpe下令
vi/usr/local/nagios/etc/objects/commands.cfg
definecommand{
command_namecheck_nrpe
command_line/usr/local/nagios/libexec/check_nrpe-H$HOSTADDRESS$-c$ARG1$
}



检测设置文件是不是有误
check




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nginx设置,Nginxfastcgiperl(pl、cgi)撑持
装置FCGI模块
cd
tarzxvfFCGI-0.70.tar.gz
cdFCGI-0.70
perlMakefile.PL
make
makeinstall
cd
装置IO和IO::ALL模块
tarzxvfIO-1.25.tar.gz
cdIO-1.25
perlMakefile.PL
make
makeinstall
cd
tarzxvfIO-All-0.41.tar.gz
cdIO-All-0.41
perlMakefile.PL
make
makeinstall
cd
unzipperl-fcgi.zip
cpperl-fcgi.pl/usr/local/nginx/
chmod755/usr/local/nginx/perl-fcgi.pl





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
vi/usr/local/nginx/start_perl_cgi.sh
#!/bin/bash
#set-x
dir=/usr/local/nginx/
stop()
{
#pkill-f$dir/perl-fcgi.pl
kill$(cat$dir/logs/perl-fcgi.pid)
rm$dir/logs/perl-fcgi.pid2>/dev/null
rm$dir/logs/perl-fcgi.sock2>/dev/null
echo"stopperl-fcgidone"
}
start()
{
rm$dir/now_start_perl_fcgi.sh2>/dev/null
chownnobody.root$dir/logs
echo"$dir/perl-fcgi.pl-l$dir/logs/perl-fcgi.log-pid$dir/logs/perl-fcgi.pid-S$dir/logs/perl-fcgi.sock">>$dir/now_start_perl_fcgi.sh
chownnobody.nobody$dir/now_start_perl_fcgi.sh
chmodu+x$dir/now_start_perl_fcgi.sh
sudo-unobody$dir/now_start_perl_fcgi.sh
echo"startperl-fcgidone"
}
case$1in
stop)
stop
;;
start)
start
;;
restart)
stop
start
;;
esac





start_perl_cgi.sh文件中的nobody全体用nagios交换,nginx目次上的用户




1
2
3
sed-is@nobody@nagios@g/usr/local/nginx/start_perl_cgi.sh
chmod755/usr/local/nginx/start_perl_cgi.sh
/usr/local/nginx/start_perl_cgi.shstart






1
2
3
4
5
#作废用户认证(便利调试)
vi/usr/local/nagios/etc/cgi.cfg
找到use_authentication=1并把值改成0
修正接洽人邮箱,修正为用于报警吸收的邮件地点
vi/usr/local/nagios/etc/objects/contacts.cfg









到这一步就是一般的
上面nginx设置
我把监听改成80的了


然后开启办事
就能够会见了,然后持续装置客户端,最初给人人截图看效果
servicenagiosstart




nagios被控端装置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
yuminstallopenssl-devel-y
1.nagios-plugins装置
groupaddnagios
useraddnagios-M-s/sbin/nologin-gnagios
tarxvfnagios-plugins-1.4.16.tar.gz
cdnagios-plugins-1.4.16
./configure--prefix=/usr/local/nagios--with-nagios-user=nagios--with-nagios-gourp=nagios--with-mysql=/usr/local/mysql&&make&&makeinstall
cd
2.nrpe装置
tarzxvfnrpe-2.13.tar.gz
cdnrpe-2.13
./configure
makeall
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config




1
2
3
启动nrpe
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
echo/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d>>/etc/rc.local





<pstyle="padding:0px;clear:both;height:auto;overflow:hidden;color:#505050;font-family:宋体,arialnarrow,arial,serif;font-size:14px;line-height:28px;background-color:#ffffff;margin-top:0px;margin-bottom:0px;">监控办事端本机:本人监控本人不必要设置<strongstyle="padding:0px;margin:0px;">
作者: 仓酷云    时间: 2015-1-16 21:32
标题: Linux教程之CentOS 6.2+Nginx+Nagios,手机短信和qq邮箱提示
这种补充有助于他人在邮件列表/新闻组/论坛中搜索对你有过帮助的完整解决方案,这可能对他们也很有用。
作者: 小魔女    时间: 2015-1-25 23:29
查阅经典工具书和Howto,特别是Howto是全球数以万计的Linux、Unix的经验总结非常有参考价值通常40%的问题同样可以解决。
作者: 变相怪杰    时间: 2015-2-4 17:52
下面看看一个让人无法回答的问题:“救命各位高手,向你们请教一些问题:如何在Linux下配制HTTP、FTP、Samba、DNS、DHCP、Sendmail服务器,谢谢”这样的问题。
作者: 冷月葬花魂    时间: 2015-2-10 05:45
Windows?是图形界面的,Linux类似以前的?DOS,是文本界面的,如果你运行了图形界面程序X-WINDOWS后,Linux?也能显示图形界面,也有开始菜单、桌面、图标等。
作者: 若天明    时间: 2015-3-1 01:28
以前觉得Linux就跟dos一样,全是用命令窗口,相对于窗口界面来说多麻烦呀。
作者: 小女巫    时间: 2015-3-10 13:01
其实当你安装了一个完整的Linux系统后其中已经包含了一个强大的帮助,只是可能你还没有发现和使用它们的技巧。
作者: 深爱那片海    时间: 2015-3-17 09:11
下面笔者在论坛看到的一个好问题: “安装红旗4.0后,系统紫光输入法自带的双拼方案和我的习惯不一样,如何自定义双拼方案解决?谢谢?”这个问题很简练。
作者: 再现理想    时间: 2015-3-24 05:59
Linux最大的特点就是其开源性,这一点是十分难得的,这也是它能够存在到现在的原因之一。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2