nagios 笔记 nagios服务端+客户端 + 短信报警 + 性能显示的图形插件

 
1. 相关资料
2. 程序下载
3. nagios-cn 安装
4. nagios-plugins 安装
5. nrpe 安装
6. 安装 sms 飞信短信程序
7. nagios 支持 飞信短信报警
8. 其他一些零碎的资料 不完整 我没搭建成功


1. 相关资料
# nagios快速安装参考 http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html
# nagios-cn 下载页面(有最新) http://sourceforge.net/projects/nagios-cn/



2. 程序下载
nagios-cn-3.0.4
# 引用页 http://sourceforge.net/projects/nagios-cn/files/
# 下载地址 http://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.0.4/nagios-cn-3.0.4.tar.gz/download

nagios-plugins-1.4.13
# 引用页 http://www.nagios.org/download/plugins
# 下载地址 http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz/download

nrpe-2.12
# 引用页 http://www.nagios.org/download/addons
# 下载地址 http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz

fetion_linux_20080402.tar.gz (短信程序)
# 下载地址 http://www.it-adv.net/fetion/fetion_linux_20080402.tar.gz



3. 安装
# - - - - - - - - 英文版本 nagios-3.0.6 安装 en - - - - - - - -

cd /opt
wget http://192.168.0.97/download/linux/nagios/nagios-3.0.6.tar.gz
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 http://192.168.0.97/download/linux/nagios/nagios-cn-3.1.0.tar.bz2
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 \

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 http://192.168.0.97/download/linux/nagios/nagios-cn-3.0.4.tar.bz2
wget http://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.0.4/nagios-cn-3.0.4.tar.gz/download
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 http://192.168.0.97/download/linux/nagios/nagios-plugins-1.4.13.tar.gz
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gz/download
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 http://www.example.com/bar
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
Require valid-user
</Directory>



/usr/local/apache2/bin/apachectl restart
service nagios restart

5. nrpe 安装

# - - - - - - - - - nrpe - - - - - - - - - -

cd /opt
#wget http://192.168.0.97/download/linux/nagios/nrpe-2.12.tar.gz
wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz
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 http://192.168.0.97/download/linux/nagios/fetion_linux_20080402.tar.gz
wget http://www.it-adv.net/fetion/fetion_linux_20080402.tar.gz
tar xvfz fetion_linux_20080402.tar.gz
cp sms /usr/bin
sms -h

# 缺少模块 需要下载
# wget http://192.168.0.97/download/linux/nagios/libACE.so.5.4.7
# wget http://192.168.0.97/download/linux/nagios/libACE_SSL.so.5.4.7
# wget http://192.168.0.97/download/linux/nagios/libcrypto.so.0.9.8
# wget http://192.168.0.97/download/linux/nagios/libssl.so.0.9.8

wget http://www.it-adv.net/fetion/library32.rar
# 解压缩后为四个文件
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

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 http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
#rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
#yum -y install rrdtool*

cd /opt
wget http://192.168.0.97/download/linux/nagios/rrdtool/perl-rrdtool-1.2.30-1.el5.rf.i386.rpm
wget http://192.168.0.97/download/linux/nagios/rrdtool/rrdtool-1.2.30-1.el5.rf.i386.rpm
wget http://192.168.0.97/download/linux/nagios/rrdtool/rrdtool-devel-1.2.30-1.el5.rf.i386.rpm

rpm -ivh --nodeps http://192.168.0.97/download/linux/nagios/rrdtool/perl-rrdtool-1.2.30-1.el5.rf.i386.rpm
rpm -ivh --nodeps http://192.168.0.97/download/linux/nagios/rrdtool/rrdtool-1.2.30-1.el5.rf.i386.rpm
rpm -ivh --nodeps http://192.168.0.97/download/linux/nagios/rrdtool/rrdtool-devel-1.2.30-1.el5.rf.i386.rpm


# - - - - - 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 http://192.168.0.97/download/linux/nagios/pnp-0.4.13.tar.gz
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 http://www.example.com/bar
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 插件

# http://down.zdnet.com.cn/link/3/21498.shtml

# 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

你可能感兴趣的:(安装,服务端,程序,短信,下载页面)