来自:网络
1. 相关资料
2. 程序下载
3. nagios-cn 安装
4. nagios-plugins 安装
5. nrpe 安装
6. 安装 sms 飞信短信程序
7. nagios 支持 飞信短信报警
8. 其他一些零碎的资料 不完整 我没搭建成功 nagios培训
1. 相关资料
# nagios快速安装参考 [ /docs/3_0/quickstart-fedora.html]docs/3_0/quickstart-fedora.html[/url]
# nagios-cn 下载页面(有最新) projects/nagios-cn/
2. 程序下载
nagios-cn-3.0.4
# 引用页 projects/nagios-cn/files/
# 下载地址 [ /projects/nagios-cn/files/sourcecode/zh_CN%203.0.4/nagios-cn-3.0.4.tar.gz/download]projects/ ... 0.4.tar.gz/download[/url]
nagios-plugins-1.4.13
# 引用页 [ ttp://www. /download/plugins]http://www. /download/plugins[/url]
# 下载地址 [ /projects/nagiosplug/files/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz/download]projects/ ... .13.tar.gz/download[/url]
nrpe-2.12
# 引用页 [ ttp://www. /download/addons]http://www. /download/addons[/url]
# 下载地址 [ /project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz]p ... 12/nrpe-2.12.tar.gz[/url]
fetion_linux_20080402.tar.gz (短信程序)
# 下载地址 [ /fetion/fetion_linux_20080402.tar.gz]fetion/fetion_linux_20080402.tar.gz[/url]
3. 安装
# - - - - - - - - 英文版本 nagios-3.0.6 安装 en - - - - - - - -
cd /opt
wget [ /download/linux/nagios/nagios-3.0.6.tar.gz]download/linux/nagios/nagios-3.0.6.tar.gz[/url]
rm -rf nagios-3.0.6
tar -zxf nagios-3.0.6.tar.gz
cd /opt/nagios-3.0.6
/usr/sbin/useradd -m nagios
# passwd nagios
/usr/sbin/groupadd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
rm -rf /usr/local/nagios
mkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios
cd /opt/nagios-3.0.6
./configure --with-command-group=nagios
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
# - - - - - - - - /en - - - - - - - -
nagios-cn-3.1.0.tar.bz2
# - - - - - - - - 中文版本nagios-cn-3.1.0安装 (个人感觉美3.0.4好) cn - - - - - - - -
cd /opt
wget [ /download/linux/nagios/nagios-cn-3.1.0.tar.bz2]download/linux/nagios/nagios-cn-3.1.0.tar.bz2[/url]
rm -rf nagios-cn-3.1.0
tar -jxf nagios-cn-3.1.0.tar.bz2
cd /opt/nagios-cn-3.1.0
/usr/sbin/useradd -m nagios
# passwd nagios
/usr/sbin/groupadd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
rm -rf /usr/local/nagios
mkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios
cd /opt/nagios-cn-3.1.0
chown -R nagios.nagios /opt/nagios-cn-3.1.0
chmod -R 777 /opt/nagios-cn-3.1.0
./configure \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
--with-command-user=nagios \
--with-command-group=nagcmd \ nagios实施
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
# - - - - - - - - /cn - - - - - - - -
# - - - - - - - - 中文版本 nagios-cn-3.0.4 安装 (我目前最喜欢这个) cn - - - - - - - -
cd /opt
# wget [ /download/linux/nagios/nagios-cn-3.0.4.tar.bz2]download/linux/nagios/nagios-cn-3.0.4.tar.bz2[/url]
wget [ /projects/nagios-cn/files/sourcecode/zh_CN%203.0.4/nagios-cn-3.0.4.tar.gz/download]projects/ ... 0.4.tar.gz/download[/url]
rm -rf nagios-cn-3.0.4
tar -jxf nagios-cn-3.0.4.tar.bz2
cd /opt/nagios-cn-3.0.4
/usr/sbin/useradd -m nagios
# passwd nagios
/usr/sbin/groupadd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
rm -rf /usr/local/nagios
mkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios
cd /opt/nagios-cn-3.0.4
./configure \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
--with-command-user=nagios \
--with-command-group=nagcmd \
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
# - - - - - - - - /cn - - - - - - - -
4. nagios-plugins 安装
# - - - - - - - - - nagios-plugins - - - - - - - - - -
cd /opt
# wget [ /download/linux/nagios/nagios-plugins-1.4.13.tar.gz]download/lin ... ugins-1.4.13.tar.gz[/url]
wget [ /projects/nagiosplug/files/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz/download]projects/ ... .13.tar.gz/download[/url] 监控软件 rm -rf nagios-plugins-1.4.13
tar -zxf nagios-plugins-1.4.13.tar.gz
cd /opt/nagios-plugins-1.4.13
./configure \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
make
make install
chkconfig --add nagios
chkconfig nagios on
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service httpd restart
service nagios restart
#vi /usr/local/apache2/conf/httpd.conf
vi /opt/lampp/etc/httpd.conf
/# Redirect permanent /foo [ /bar]bar[/url]
iScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users nagios配置 Require valid-user
</Directory>
/usr/local/apache2/bin/apachectl restart
service nagios restart
5. nrpe 安装
# - - - - - - - - - nrpe - - - - - - - - - -
cd /opt
#wget [ /download/linux/nagios/nrpe-2.12.tar.gz]download/linux/nagios/nrpe-2.12.tar.gz[/url]
wget [ /project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz]p ... 12/nrpe-2.12.tar.gz[/url]
rm -rf nrpe-2.12
tar -zxf nrpe-2.12.tar.gz
cd /opt/nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
vi /usr/local/nagios/etc/nrpe.cfg
/allowed_hosts
# 严重警告 如果填写多个IP 则会出现个别错误
# 在allowed_hosts处增加nagios服务端的ip
# 启动nrpe
killall 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.d/rc.local 开源监控软件
# 测试在被监控端主机:
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.191
# 在nagios服务器端:
/usr/local/nagios/libexec/check_nrpe -H 客户端IP
# 运行正常的话将返回nrpe的版本号
service httpd restart
service nagios restart
killall nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
- - - - - - - - - - - - - - -
6. 安装 sms 飞信短信程序
# - - - - - - - - - 短信 sms 安装 - - - - - - - - - -
cd /opt
# wget [ /download/linux/nagios/fetion_linux_20080402.tar.gz]download/lin ... nux_20080402.tar.gz[/url]
wget [ /fetion/fetion_linux_20080402.tar.gz]fetion/fetion_linux_20080402.tar.gz[/url]
tar xvfz fetion_linux_20080402.tar.gz
cp sms /usr/bin
sms -h
# 缺少模块 需要下载
# wget [ /download/linux/nagios/libACE.so.5.4.7]download/linux/nagios/libACE.so.5.4.7[/url]
# wget [ /download/linux/nagios/libACE_SSL.so.5.4.7]download/linux/nagios/libACE_SSL.so.5.4.7[/url]
# wget [ /download/linux/nagios/libcrypto.so.0.9.8]download/linux/nagios/libcrypto.so.0.9.8[/url]
# wget [ /download/linux/nagios/libssl.so.0.9.8]download/linux/nagios/libssl.so.0.9.8[/url]
wget [ /fetion/library32.rar]fetion/library32.rar[/url]
# 解压缩后为四个文件
libACE.so.5.4.7
libACE_SSL.so.5.4.7
libcrypto.so.0.9.8
libssl.so.0.9.8
cp lib*.* /lib/
cp lib*.* /usr/lib/
sms -h
# 显示帮助信息后 则表示 sms 能正常工作了
# 缺少的4个模块 libACE.so.5.4.7 libACE_SSL.so.5.4.7 libcrypto.so.0.9.8 libssl.so.0.9.8
- - - - -- - - - - - sms OK ! - - - -- - -
7. nagios 支持 飞信短信报警
- - - - - - 短信 - - - - - nagios 配置 - - - - -
vi /usr/local/nagios/etc/objects/commands.cfg
i#host-notify-by-sms
define command {
command_name host-notify-by-sms
command_line /usr/local/sms/duanxin.sh 1388shoujihao "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$' " $CONTACTPAGER$
command_line /usr/local/sms/duanxin.sh 15827109880 "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$' " $CONTACTPAGER$
}
#service notify by sms
define command {
command_name service-notify-by-sms
command_line /usr/local/sms/duanxin.sh 1388shoujihao "'$HOSTADDRESS$' $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$
command_line /usr/local/sms/duanxin.sh 15827109880 "'$HOSTADDRESS$' $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$
}
mkdir /usr/local/sms
\cp /opt/sms /usr/local/sms
rm -rf /usr/local/sms/duanxin.sh
vi /usr/local/sms/duanxin.sh
i/usr/local/sms/sms -f 1388shoujihao -p mima -t 1388shoujihao -m "$2"
/usr/local/sms/sms -f 1388shoujihao -p mima -t 1354shoujihao -m "$2"
#/usr/local/sms/sms -f 1388shoujihao -p mima -t 1388shoujihao -m 111 nagios安装
vi /usr/local/nagios/etc/objects/templates.cfg
# - - - - - - 更改 email项为 sms -- - - - - - - -
service_notification_commands service-notify-by-sms
host_notification_commands host-notify-by-sms
chmod -R 777 /usr/local/sms
# - - - - - - - - - - - 短信OK - - - - - - - - - - -
8. 其他一些零碎的资料 不完整 我没搭建成功
# - - - - - pnp - - - - - -
# - - - rrdtool安装问题解决 - - - - -
#cd /opt
#wget [ /rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm]rpmforge-r ... 6-1.el5.rf.i386.rpm[/url]
#rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
#yum -y install rrdtool*
cd /opt
wget [ /download/linux/nagios/rrdtool/perl-rrdtool-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
wget [ /download/linux/nagios/rrdtool/rrdtool-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
wget [ /download/linux/nagios/rrdtool/rrdtool-devel-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
rpm -ivh --nodeps [ /download/linux/nagios/rrdtool/perl-rrdtool-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
rpm -ivh --nodeps [ /download/linux/nagios/rrdtool/rrdtool-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
rpm -ivh --nodeps [ /download/linux/nagios/rrdtool/rrdtool-devel-1.2.30-1.el5.rf.i386.rpm]download/lin ... 0-1.el5.rf.i386.rpm[/url]
# - - - - - nagios 支持 pnp - - - - -
vi /usr/local/nagios/etc/nagios.cfg
/service_perfdata_command=process-service-perfdata
process_performance_data=1
#默认此句被注释掉了
vi /usr/local/nagios/etc/objects/commands.cfg
/process-service-perfdata
# - - - - process-service-perfdata 修改这个选项所有
define command{
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/sbin/insert.cgi
}
# - - - - - - pnp 安装 - - - - -
cd /opt
wget [ /download/linux/nagios/pnp-0.4.13.tar.gz]download/linux/nagios/pnp-0.4.13.tar.gz[/url]
rm -rf pnp-0.4.13
tar -zxf pnp-0.4.13.tar.gz
cd /opt/pnp-0.4.13
./configure --with-rrdtool= --with-perfdata-dir=/usr/local/nagios/share/perfdata/
make all
make install
make install-config
make install-init
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# - - - - - - apache 上添加 pnp 网页地址 - - - - - -
vi /usr/local/apache2/conf/httpd.conf
/# Redirect permanent /foo [ /bar]bar[/url]
iAlias /nagios/pnp "/usr/local/nagios/share/pnp"
<Directory "/usr/local/nagios/share/pnp">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
# - - - - - 准备测试 - - - - -
service httpd restart
http://IP/nagios/pnp/
- - - - - pnp OK ! - - - - -
# 安装浏览 3D 插件
# [ /link/3/21498.shtml]link/3/21498.shtml[/url]
# cortvrml.exe 浏览器中安装 才能观看 3-D状态图
# - - - - - - 如何在nagios中使用外部命令
# 需要给 /usr/local/nagios/var/rw 里面文件的权限就好了 不过每次重启后就会恢复权限 需要在搭建 nagios 的时候设置好 .. 我一直设置失败
#vi /usr/local/nagios/etc/nagios.cfg
#/check_external_commands=1
mkdir /usr/local/nagios/var/rw
chown -R nagios.nagcmd /usr/local/nagios/var/rw
chmod u+rw /usr/local/nagios/var/rw
chmod g+rw /usr/local/nagios/var/rw
chmod g+x /usr/local/nagios/var/rw
chmod 777 /usr/local/nagios/var/rw
# - - - - - vi 替换 在编辑 nagios 配置文件时比较有用
:.,$s/emos-mailserver/sheng193/
. 表示所有
emos-mailserver替换成sheng193
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流 QQ群号 :476809427 |