古井贡红运价格38度:RHEL6 Nagios 部署+fetion整合
来源:百度文库 编辑:偶看新闻 时间:2024/05/05 15:00:11
2011-11-17 11:59:30标签:主机 fetion 版权声明:原创作品,谢绝转载!否则将追究法律责任。
http://www.it-adv.net/ 下载 fetion 主程序与支持库步骤
(1)IP:192.168.0.85:
cd ~
lftp 127.0.0.1
cd /pub/docs/nagios
get fetion cenos54X64_20101113.rar
cd /pub/docs
get rarlinux-3.8.0.tar.gz
cp fetion /usr/local/nagios/libexec
cd /usr/local/nagios/libexec
chmod +x fetion
chown nagios.nagios fetion
(2)执行 /usr/local/nagios/libexec/fetion
出现没有/lib/ld-linux.so
yum install /lib/ld-linux.so.2 -y
cd /usr/local/nagios/libexec/
./fetion
cd ~
tar zxf rarlinux-3.8.0.tar.gz -C /opt/
cd /opt/rar/unrar
/opt/rar/unrar x cenos54X64_20101113.rar(可能会出错,需要安装以下的包,然后重新执行此步。)yum install libstdc++.so.6
(3) cd ~
lftp 192.168.0.254
cd /pub/docs/nagios
get linuxso_20111113.tar.gz
tar zxf linuxso_20111113.tar.gz -C /usr/local/lib(将库文件放到/usr/local/ib中。ldconfig /usr/local/lib使其生效。)
cd /usr/local/lib
ls 会有4个so文件。
chmod +x *
需要的时候可能需要安装: yum install libgssapi_krb5.so.2 libz.so.1 zlib文件。
ldconfig /usr/local/lib
/usr/local/nagios/libexec/fetion 7执行成功。
(4)vi /etc/ld.so.conf.d/mysql-x86_64.conf
/usr/lib64/mysql
(5) vi fetion.conf
/usr/local/lib
ldconfig
(6) su - nagios
/usr/local/nagios/libexec/fetion --mobile=158029XXXXX --pwd=XXXXXX(飞信密码) --to=15802955XXXX --msg-utf8="hello"
然后你去/usr/local/nagios/libexec找到1509154xxxx.jpg,然后将其复制到桌面,查看其验证码,然后写上去,你就会在1509154xxxx收到一个由mobile=1509154xxxx发来的信息哦!)
你第一次用验证码,第二次就不用验证码。
实验五:
fetion 与 nagios 配置
步骤(1)cd /usr/local/nagios/libexec/
vi fetion.sh
/usr/local/nagios/libexec/fetion --mobile=158029XXXXX --pwd=qqXXXXX --to="$1" --msg-utf8="$2" > /dev/null
(2) chmod +x fetion.sh
chown ngios.nagios fetion.sh
su - nagios
cd /usr/local/nagios/libexec/
./fetion.sh 1509154xxxx "hello" (测试给1509154xxxx发送小心“hello“)
此时因为你重新调用的程序,需要重新找到验证码并输入.....
然后就可以收到信息喽......
(3) cd /usr/local/nagios/etc/objects/
vi templates.cfg
Generic contact definition template - This is NOT a real contact, just a template!define contact{
name generic-contact ; The name of this contact template
.
.
.
service_notification_commands notify-service-by-email,notify-service-by-fetion ; send service notifications via email
host_notification_commands notify-host-by-email,notify-host-by-fetion ; send host notifications via email
..........................
}
(4) vi /usr/local/nagios/etc/objects/commands.cfg
增加以下内容:
# 'notify-host-by-fetion' command definition
define command{
command_name notify-host-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$"
}
# 'notify-service-by-fetion' command definition
define command{
command_name notify-service-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"
}
(5)vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
.
.
.
email 997365139@qq.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager 1509154xxxx(接收飞信信息的手机号码
)
}
(6)测试:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#校验后重新载入 nagios 配置
/etc/init.d/nagios reload
此时你若把被监控端的: service mysqld stop此时会产生报警。然后下次检测的时候你的手机和邮箱会同时收到邮件和信息哦。。
RHEL6 Nagios 部署系统环境:RHEL6 x86_64 selinux and iptables disablednagios 主机:192.168.0.5mysql 主机: 192.168.0.1一,监控本机安装所需要软件yum install httpd gcc make perl-ExtUtils-Embed.x86_64 -yrpm -ivh gd-devel-2.0.35-10.el6.x86_64.rpm useradd nagios 运行 nagios 服务的用户usermod -G nagios apache 使 apache 用户对 nagios 目录具有写权限,不然 web 页面操作失败 tar jxf nagios-cn-3.2.3.tar.bz2 解压nagioscd nagios-cn-3.2.3./configure –-enable-embedded-perl 编译make allmake installmake install-initmake install-commandmodemake install-configmake install-webconf yum install mysql-devel openssl-devel -y 编译所需软件包tar zxf nagios-plugins-1.4.15.tar.gz nagios 插件安装cd nagios-plugins-1.4.15./configure —with-nagios-user=nagios —with-nagios-group=nagios--enable-extra-opts —enable-libtap —enable-perl-modulesMake && make install vi /usr/local/nagios/etc/nagios.cfg #nagios配置cfg_file=/usr/local/nagios/etc/objects/hosts.cfg #新建 hosts.cfg 文件,存放主机与主机组定义cfg_file=/usr/local/nagios/etc/objects/services.cfg #新建 services.cfg 文件,存放服务与服务组定义#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg#注释 localhost.cfg 文件如下图: cp -r localhost.cfg hosts.cfgvi /usr/local/nagios/etc/objects/hosts.cfg去掉service部分,只留下想要的的hosts部分define host{ use linux-server ; 给网络设备用的 host_name Desktop5 alias nagios address 192.168.0.5 2d_coords 100,200 3d_coords 100,200,100 }define hostgroup{ hostgroup_name linux-servers ; The name of the hostgroup alias Linux Servers ; Long name of the group members * ; Comma separated list of hosts that belong to this group }如下图: cp -r localhost.cfg services.cfgvi /usr/local/nagios/etc/objects/services.cfg去掉hosts部分,只留下想要的的service部分 define servicegroup{ servicegroup_name 系统负荷检查 alias 负荷检查 members Desktop5,进程总数,Desktop5,登录用户数,Desktop5,根分区,Desktop5,交换空间利用率 }define servicegroup{ servicegroup_name 全部联通性检查 alias 联通性检查 members Desktop5,PING } define service{ use local-service host_name * service_description PING check_command check_ping!100.0,20%!500.0,60% } define service{ use local-service host_name Desktop5 service_description 根分区 check_command check_local_disk!20%!10%!/ } define service{ use local-service host_name Desktop5 service_description 进程总数 check_command check_local_procs!250!400!RSZDT } define service{ use local-service host_name Desktop5 service_description 系统负荷 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 }define service{ use local-service host_name Desktop5 service_description SSH check_command check_tcp!22!1.0!10.0 notifications_enabled 0 } /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检测语法的正确性/etc/init.d/httpd restart/etc/init.d/nagios restarthtpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin #nagios 监控页面访问用户和密码就能访问http://192.168.0.5/nagio 二.监控另外一台机器的数据库(mysql)Yum install mysql* -y/etc/init.d/mysql restartMysqlmysql>create database nagdb; 创建用户mysql> grant select on nagdb.* to nagdb@'192.168.0.5'; 使其具有查看权限mysql> flush privileges; 刷新数库 在nagios服务器中查看是否能够链接到mysql主机/usr/local/nagios/libexec/usr/local/nagios/libexec/check_mysql -H 192.168.0.1 -u nagdb -d nagdb 在 nagios 主机上添加对 mysql 服务监控的定义vi /usr/local/nagios/etc/objects/commands.cfg (添加如下行)define command{ command_name check_mysql command_line $USER1$/check_mysql -H $HOSTADRESS$ -u nagdb -d nagdb}vi /usr/local/nagios/etc/objects/hosts.cfg (添加如下行) define host{ use linux-server host_name mysql服务器 alias Desktop1 address 192.168.0.1 2d_coords 500,200 3d_coords 500,200,100}vi /usr/local/nagios/etc/objects/services.cfg (添加如下行)define service{ use local-service host_name mysql服务器 check_command check_mysql } /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg/etc/init.d/httpd restart/etc/init.d/ngios restart就能访问http://192.168.0.5/nagio 三.Nagios 通过 NRPE 监控远程主机系统状况
远程主机设定useradd nagios tar xzf nagios-plugins-1.4.15.tar.gzcd nagios-plugins-1.4.15./configure —with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-perl-modules —with-openssl --enable-libtap makemake install yum install xinetd -y tar zxf nrpe-2.12.tar.gzcd nrpe-2.12./configuremake allmake install-pluginmake install-daemonmake install-daemon-configmake install-xinetd vi /etc/xinetd.d/nrpe 修改如下行only_from= 192.168.0.5 #nagios 主机 ip 地址 vi /etc/services 添加如下行nrpe 5666/tcp nrpe务监听端口 vi /usr/local/nagios/etc/nrpe.cfg 修改如下行command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /#根分区监测service xinetd restartnetstat -antlp |grep 5666tcp 0 0 :::5666#看到如下输出说明 NRPE 正常启动,并确保防火墙允许此端口:::*LISTEN26359/xinetd 监控主机设定tar zxf nrpe-2.12.tar.gzcd nrpe-2.12./configure --with-nagios-user=nagios --with-nagios-group=nagiosmake allmake install-plugin/usr/local/nagios/libexec/check_nrpe -H 192.168.0.1NRPE v2.12#如看到如下输出说明连接正常 vi /usr/local/nagios/etc/objects/commands.cfg 添加如下行define command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$} vi /usr/local/nagios/etc/objects/services.cfg 添加如下行define service{ use local-service host_name mysql服务器 check_command check_mysql service_description mysql服务}define service{ use generic-service host_name mysql服务器 service_description CPU 使用率 check_command check_nrpe!check_load}define service{ use generic-service host_name mysql服务器 service_description 登录用户数量 check_command check_nrpe!check_users} define service{ use generic-servicehost_name mysql服务器service_description 根使用率check_command check_nrpe!check_disk} /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgservice nagios reload#检测无误后重载 nagios Nagios 整合飞信
http://www.it-adv.net/ 下载 fetion 主程序与支持库步骤
(1)IP:192.168.0.85:
cd ~
lftp 127.0.0.1
cd /pub/docs/nagios
get fetion cenos54X64_20101113.rar
cd /pub/docs
get rarlinux-3.8.0.tar.gz
cp fetion /usr/local/nagios/libexec
cd /usr/local/nagios/libexec
chmod +x fetion
chown nagios.nagios fetion
(2)执行 /usr/local/nagios/libexec/fetion
出现没有/lib/ld-linux.so
yum install /lib/ld-linux.so.2 -y
cd /usr/local/nagios/libexec/
./fetion
cd ~
tar zxf rarlinux-3.8.0.tar.gz -C /opt/
cd /opt/rar/unrar
/opt/rar/unrar x cenos54X64_20101113.rar(可能会出错,需要安装以下的包,然后重新执行此步。)yum install libstdc++.so.6
(3) cd ~
lftp 192.168.0.254
cd /pub/docs/nagios
get linuxso_20111113.tar.gz
tar zxf linuxso_20111113.tar.gz -C /usr/local/lib(将库文件放到/usr/local/ib中。ldconfig /usr/local/lib使其生效。)
cd /usr/local/lib
ls 会有4个so文件。
chmod +x *
需要的时候可能需要安装: yum install libgssapi_krb5.so.2 libz.so.1 zlib文件。
ldconfig /usr/local/lib
/usr/local/nagios/libexec/fetion 7执行成功。
(4)vi /etc/ld.so.conf.d/mysql-x86_64.conf
/usr/lib64/mysql
(5) vi fetion.conf
/usr/local/lib
ldconfig
(6) su - nagios
/usr/local/nagios/libexec/fetion --mobile=158029XXXXX --pwd=XXXXXX(飞信密码) --to=15802955XXXX --msg-utf8="hello"
然后你去/usr/local/nagios/libexec找到1509154xxxx.jpg,然后将其复制到桌面,查看其验证码,然后写上去,你就会在1509154xxxx收到一个由mobile=1509154xxxx发来的信息哦!)
你第一次用验证码,第二次就不用验证码。
实验五:
fetion 与 nagios 配置
步骤(1)cd /usr/local/nagios/libexec/
vi fetion.sh
/usr/local/nagios/libexec/fetion --mobile=158029XXXXX --pwd=qqXXXXX --to="$1" --msg-utf8="$2" > /dev/null
(2) chmod +x fetion.sh
chown ngios.nagios fetion.sh
su - nagios
cd /usr/local/nagios/libexec/
./fetion.sh 1509154xxxx "hello" (测试给1509154xxxx发送小心“hello“)
此时因为你重新调用的程序,需要重新找到验证码并输入.....
然后就可以收到信息喽......
(3) cd /usr/local/nagios/etc/objects/
vi templates.cfg
Generic contact definition template - This is NOT a real contact, just a template!define contact{
name generic-contact ; The name of this contact template
.
.
.
service_notification_commands notify-service-by-email,notify-service-by-fetion ; send service notifications via email
host_notification_commands notify-host-by-email,notify-host-by-fetion ; send host notifications via email
..........................
}
(4) vi /usr/local/nagios/etc/objects/commands.cfg
增加以下内容:
# 'notify-host-by-fetion' command definition
define command{
command_name notify-host-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$"
}
# 'notify-service-by-fetion' command definition
define command{
command_name notify-service-by-fetion
command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"
}
(5)vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
.
.
.
email 997365139@qq.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
pager 1509154xxxx(接收飞信信息的手机号码
)
}
(6)测试:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#校验后重新载入 nagios 配置
/etc/init.d/nagios reload
此时你若把被监控端的: service mysqld stop此时会产生报警。然后下次检测的时候你的手机和邮箱会同时收到邮件和信息哦。。
.net部署到虚拟主机
“部署”、“布署”的区别
什么是vpn 如何部署
Exchange Server2003如何部署
如何部署javabean?
如何部署javaBean?
请问如何部署javaBean?
.NET web安装部署
什么是静态目录部署
邮件服务器如何部署
软件部署是什么意思
在java中怎么部署javabean(部署class)
什么叫软件部署啊
软件部署到底是什么啊?
Symantec Antivirus 企业版如何部署?
市场部部署计划什么写
如何写市场部部署计划
ClickOnce部署路径的问题
vs.net2003怎么安装部署
中国SU27的部署地区
中国SU27的部署地区
美军在东亚地区的军事部署
计算机部署出音乐拉无声音
八年抗战游戏怎么部署部队