您好,登錄后才能下訂單哦!
1、最小化安裝Centos系統(tǒng)。
配置網(wǎng)絡(luò)地址使其可以上網(wǎng)。
2、安裝setup工具
yum -y install setuptool ntsysv iptables system-config-securitylevel-tui system-config-network-tui system-config-firewall-tui make vim
3、修改顯示語言
[root@localhost ~]# more /etc/sysconfig/i18n
#LANG=”zh_CN.UTF-8″
LANG=”zh_CN.GB18030″
SYSFONT=”latarcyrheb-sun16″
4、安裝依賴包。
[root@KING ~]# yum -y install gcc glibc glibc-common gd gd-devel httpd
5、添加相應(yīng)用戶及組
[root@KING conf]# groupadd nagcmd
[root@KING conf]# useradd -G nagcmd nagios
[root@KING conf]# useradd -G nagcmd apache
6、正式安裝nagios
#tar zxf nagios-3.4.1.tar.gz
#cd nagios
#./configure –prefix=/usr/local/nagios –with-command-group=nagcmd
#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
7、編譯安裝nagios插件
#tar zvxf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios
#make && make install
#chkconfig –add nagios
#chkconfig nagios on
#chkconfig httpd on
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#service nagios start
#vim /root/.bashrc
#添加一條alias check=’/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg’
#source /root/.bashrc
8、安裝后常見問題解決
問題1打開http://192.168.5.64/nagios輸入口令驗證后出現(xiàn)“You don’t have permission to access /nagios/ on this server”
解決方法沒裝php導(dǎo)致yum -y install php裝好重啟httpd和nagios
問題2如果提示“Whoops! Error: Could not read object configuration data! ”這是因為沒有啟動nagios后臺進程執(zhí)行以下命令
解決方法/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
問題3Nagios顯示類似錯誤HTTP WARNING: HTTP/1.1 403 Forbidden – 5240 bytes in 0.002 second response time。該錯誤表明在apache web根目錄沒有index.html文件。
解決方法在web根目錄如:/var/www/html/目錄建立index.html文件重啟apache和nagios即可。
問題4安裝nagios-pluginsmake時出現(xiàn)如下報錯
make[2]: *** [check_http.o] Error 1
make[2]: Leaving directory `/mnt/nagios-plugins-1.4.13/plugins’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/nagios-plugins-1.4.13′
make: *** [all] Error 2
解決辦法yum -y install openssl openssl-devel然后重新執(zhí)行./configure再編譯安裝。
9、設(shè)置nagios.cmd寫權(quán)限
chmod 777 /usr/local/nagios/var/rw/nagios.cmd
10、安裝nrpe客戶端
首先安裝SSL支持包[root@KING conf.d]# yum -y install openssl openssl-devel xinetd
安裝nrpe[root@KING nagios]# tar -zvxf nrpe-2.12.tar.gz
#cd nrpe-2.12
#./configure
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
#make install-xinetd
vim /etc/xinetd.d/nrpe
only_from = 192.168.5.57
vim /etc/services
添加nrpe 5666/tcp #NRPE
重啟xinetd服務(wù)。
測試下連通性在監(jiān)控端執(zhí)行
/usr/local/nagios/libexec/check_nrpe -H 被監(jiān)控端的地址
如能顯示 “NRPE v2.12”表明NRPE可以和被監(jiān)控端正常通信。
被監(jiān)控端安裝nrpe
同監(jiān)控端額外安裝插件
useradd -s /sbin/nologin nagios
#tar xzf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios
#make && make install
修改/usr/local/nagios/etc/objects/commands.cfg定義命令的文件添加如下內(nèi)容
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
11、定義監(jiān)控
修改/usr/local/nagios/etc/nagios.cfg
去掉cfg_dir=/usr/local/nagios/etc/servers前面的注釋
mkdir //usr/local/nagios/etc/servers
添加文件cacti_56.cfg
define host{
use linux-server
host_name Cacti-56
alias Cacti-56
address 192.168.5.56
}
define service{
use generic-service
host_name Cacti-56
service_description CPU Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name Cacti-56
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name Cacti-56
service_description Disk Free Space /
check_command check_nrpe!check_root
}
define service{
use generic-service
host_name Cacti-56
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name Cacti-56
service_description Zombie Processes
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name Cacti-56
service_description Swap Usage
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name Cacti-56
service_description disk_/
check_command check_nrpe!check_disk_/
}
define service{
use generic-service
host_name Cacti-56
service_description check_tcp_3306
check_command check_tcp!3306
}
檢查配置文件service nagios checkconfig
重新載入service nagios reload
12、修改聯(lián)系人配置文件/usr/local/nagios/etc/objects/contacts.cfg
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
email nagios@bobo365.com
}
define contact{
contact_name nagios
use generic-contact
alias nagios
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email nagios@bobo365.com
}
13、安裝圖形擴展工具pnp4nagios
安裝依賴包yum -y install php-gd rrdtool-perl rrdtool librrds-perl perl-Time-HiRes
tar zxf pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6.tar.gz
./configure –with-nagios-user=nagios –with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make install-init
[root@KING pnp4nagios-0.6.19]# cd /usr/local/pnp4nagios/etc
[root@KING etc]# rename .cfg-sample .cfg *.cfg-sample
[root@KING etc]# cd pages/
[root@KING pages]# rename .cfg-sample .cfg *.cfg-sample
[root@KING pages]# cd ../check_commands/
[root@KING check_commands]# rename .cfg-sample .cfg *.cfg-sample
service npcd restart
修改nagios的主配置文件打開數(shù)據(jù)傳輸
vim nagios.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata #去掉注釋
修改nagios的命令配置文件定義其使用的插件
vim 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
}
配置nagios的樣本文件定義后續(xù)要引用的類
vim templates.cfg
define host {
name hosts-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name services-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
引用的類后面加上hosts-pnn或者services-pnp以“”隔開
重載nagios服務(wù)
/usr/local/pnp4nagios/var/perfdata/下生成以監(jiān)控主機的cfg文件名的文件夾里面會有.rrd和.xml的文件
刪除安裝文件重啟apache。
/usr/local/pnp4nagios/share/install.php
14、nagios報警郵件
關(guān)閉系統(tǒng)自身的郵件系統(tǒng)postfixservice postfix stop
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
tar zxf sendEmail-v1.55.tar.gz
cd sendEmail-v1.55
cp sendEmail /usr/local/bin
chmod 755 /usr/local/bin/sendEmail
修改command.cfg文件:
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$
\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/local/bin/sendEmail -f nagios@bobo365.com -t $CONTACTEMAIL$ -s mail.bobo365.com -u “**
$NOTIFICATIONTYPE$ alert – $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” -xu nagios -xp XXXXXX
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7
1 永久方法 – 需要重啟服務(wù)器
修改/etc/selinux/config文件中設(shè)置SELINUX=disabled 然后重啟服務(wù)器。
2 臨時方法 – 設(shè)置系統(tǒng)參數(shù)
使用命令setenforce 0
附
setenforce 1 設(shè)置SELinux 成為enforcing模式
setenforce 0 設(shè)置SELinux 成為permissive模式
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。