您好,登录后才能下订单哦!
# Installation instructions of Nagios on CentOS 6.4 64bit
Author : Larry Zhao
Q Q : 920057952
B L O G: larryzhao.blog.51cto.com
E-mail : zhaolong0508@126.com
# NTP Service
yum install ntp
service ntpd start
chkconfig ntpd on
crontab -e
* * * * * /usr/sbin/ntpdate cn.pool.ntp.org
# Packets Prepare
nagios-3.3.1.tar.gz nagios-plugins-1.4.15.tar.gz nrpe-2.12.tar.gz rrdtool-1.4.7.tar.gz pnp4nagios-0.6.6.tar.gz
# We use X-shell to upload these files to our server
mkdir /upload;cd /upload
######################### Nagios Server 10.0.0.145 ######################################
tar zxvf nagios-3.3.1.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
tar zxvf nrpe-2.12.tar.gz
tar zxvf rrdtool-1.4.7.tar.gz
tar zxvf pnp4nagios-0.6.6.tar.gz
rm -f *.gz
# Environment Prepare
yum install -y net-snmp net-snmp-utils httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server mysql-devel openssl-devel
yum install -y libpangocairo pango pango-devel cairo cairo-devel redhat-lsb-graphics pkgconfig groff glib glib-devel libart* gettext gettext-devel libxml2 libxml2-devel
yum install -y freetype freetype-devel libpng libpng-devel libjpeg libjpeg-devel libiconv libiconv-devel qpixman qpixman-devel
#SELINUX
vim /etc/selinux/config
SELINUX=disabled
#IPTABLES
service iptables stop
chkconfig iptables off
# Install Nagios
groupadd nagcmd
useradd -m nagios
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
cd nagios
./configure --with-command-group=nagcmd --enable-event-broker
make all && make install && make install-init && make install-config && make install-commandmode && make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# type new password twice
Here we use nagios as our password
service httpd start
chkconfig httpd on
cd ../nagios-plugins-1.4.15/
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql
make && make install
chkconfig --add nagios
chkconfig nagios on
vim /etc/profile
# Insert "PATH=$PATH:/usr/local/nagios/bin" into /etc/profile
PATH=$PATH:/usr/local/nagios/bin
#save and exit
. /etc/profile
nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
#Now if you want access your nagios server, http://ip/nagios. Username:nagiosadmin Password:nagios
cd ../nrpe-2.12/
./configure --enable-ssl --with-ssl-lib=/lib/
make all && make install-plugin
# It is necessary to insert some lines of code into /usr/local/nagios/etc/objects/commands.cfg
vim /usr/local/nagios/etc/objects/commands.cfg
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#save and exit
#We can use the command_line below to check our config files
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
cd ../rrdtool-1.4.7
./configure --prefix=/usr/local/rrdtool
make && make install
cd ../pnp4nagios-0.6.6
chown nagios.nagios *
chmod +x *
./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool
make all
make install
make install-webconf
make install-config
make install-init
cd /usr/local/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
mv npcd.cfg-sample npcd.cfg
mv process_perfdata.cfg-sample process_perfdata.cfg
cd pages/
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands/
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
service npcd restart
# Nagios config files
vim /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
vim /usr/local/nagios/etc/objects/commands.cfg
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
command_name process-service-perfdata
command_line /usr/local/nagios/libexec/process_perfdata.pl
}
vim /usr/local/nagios/etc/objects/templates.cfg
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
cp /upload/pnp4nagios-0.6.6/contrib/ssi/* /usr/local/nagios/share/ssi/
cd /usr/local/pnp4nagios/share/
mv install.php install.php.bak
#check npcd.cfg
/usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg
#First time to access
http://ip/php4nagios
# create some config files as we like
cd /usr/local/nagios/etc/objects/
touch mylinux.cfg;vim mylinux.cfg
define host{
use linux-server,host-pnp
host_name puppet
alias puppty_jd_server
address 10.0.0.148
}
define serviceextinfo {
host_name puppet
service_description check_load
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$'class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
}
define service{
use generic-service,srv-pnp
host_name puppet
service_description check_local_load
check_command check_nrpe!check_load
}
define service{
use generic-service,srv-pnp
host_name puppet
service_description check_users
check_command check_nrpe!check_users
}
vim ../nagios.cfg
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
service nagios restart
service npcd restart
service httpd restart
############################ Nagios Client 10.0.0.148 ###################################
# NTP Service
yum install ntp
service ntpd start
chkconfig ntpd on
crontab -e
* * * * * /usr/sbin/ntpdate cn.pool.ntp.org
# Packets Prepare
nagios-plugins-1.4.15.tar.gz nrpe-2.12.tar.gz
# We use X-shell to upload these files to our server
mkdir /upload;cd /upload
tar zxvf nagios-plugins-1.4.15.tar.gz
tar zxvf nrpe-2.12.tar.gz
rm -f *.gz
# Environment Prepare
yum -y install net-snmp net-snmp-utils openssl-devel gcc glibc glibc-common *gd*
#SELINUX
vim /etc/selinux/config
SELINUX=disabled
#IPTABLES
service iptables stop
chkconfig iptables off
useradd nagios
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
cd ../nrpe-2.12
./configure --enable-ssl --with-ssl-lib=/usr/lib/
make all
make install-plugin && make install-daemon && make install-daemon-config
chown -R nagios:nagios /usr/local/nagios
cp /usr/local/nagios/etc/nrpe.cfg /etc/nrpe.cfg
#allowed_hosts change to the nagios server's IP address
vim /etc/nrpe.cfg
allowed_hosts=10.0.0.145
#Three lines need to change, you can use set nu to find them
vim /etc/snmp/snmpd.conf
line 41 com2sec notConfigUser default larryzhao
line 62 access notConfigGroup "" any noauth exact mib2 none none
line 89 view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
service snmpd restart
chkconfig snmpd on
#Start nrpe service
/usr/local/nagios/bin/nrpe -c /etc/nrpe.cfg -d
#To check nrpe work status
ps -ef |grep nrpe
#add nrpe to rc.local
vim /etc/rc.d/rc.local
/usr/local/nagios/bin/nrpe -c /etc/nrpe.cfg -d
############################### E-mail Notice ##########################################
yum install -y sendmail
yum install -y sendmail-cf
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
vi /etc/mail/local-host-names
larryzhao.com
vi /etc/mail/submit.cf
find #Dj$w.Foo.COM
Djlarryzhao.com
service sendmail restart
vim /usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email zhaolong0508@126.com,920057952@qq.com
}
vim /usr/local/nagios/etc/objects/commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。