您好,登錄后才能下訂單哦!
Nagios是一款功能強(qiáng)大的網(wǎng)絡(luò)監(jiān)視工具,它可以有效的監(jiān)控windows、linux、unix主機(jī)狀態(tài)以及路由器交換機(jī)的網(wǎng)絡(luò)設(shè)置,打印機(jī)工作狀態(tài)等,并將狀態(tài)出現(xiàn)異常的服務(wù)及時(shí)以郵件、msn短信等形式第一時(shí)間通告管理員。由于它是一款遵循GPLv2的開源網(wǎng)絡(luò)監(jiān)控軟件,以其出色的性能低廉的使用成本,深受廣大用戶的好評(píng)。
yum groupinstall -y 'Development Libraries' 'Development Tools" 'Legacy Software Development' 'X Software Development'
|
yum -y install httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server mysql-devel openssl-devel
# 安裝Nagios必須的基本組件的運(yùn)行依賴于httpd、mysql、gd以及編譯用到的gcc |
groupadd nagcmd
#添加與nagios運(yùn)行相關(guān)服務(wù)的組 useradd -m nagios #添加nagios用戶 usermod -a -G nagcmd nagios #將nagios用戶追加附加組 usermod -a -G nagcmd apache #將apache用戶追加nagcmd組使之工作時(shí)具有足夠的權(quán)限 |
tar xvf nagios-3.3.1.tar.gz
cd nagios # ./configure --with-command-group=nagcmd --enable-event-broker #默認(rèn)安裝路徑在/usr/local/nagios/ make all && make install && make install-init && make install-config && make install-commandmode && make install-webconf #安裝主程序、添加初始化程序、生成配置文件、生成web配置文件 |
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: Re-type new password: Adding password for user nagios #為nagios的web頁(yè)面創(chuàng)建賬號(hào)密碼,對(duì)訪問(wèn)進(jìn)行身份認(rèn)證 service httpd restart chkconfig httpd on #啟動(dòng)httpd,并設(shè)置開機(jī)啟動(dòng) |
tar xvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql #添加mysql依賴 make && make install #編譯并安裝 Ps:作者在安裝nagios-cn-3.2.3.tar過(guò)程中,在此處編譯完成發(fā)現(xiàn)mysql關(guān)聯(lián)庫(kù)文件本跳過(guò)。經(jīng)分析原因是由于在編譯nagios時(shí)修改了nagios的默認(rèn)安裝路徑(非/usr/local/nagios)。 解決辦法: |
cp /usr/lib/mysql/mysql_config /usr/lib/pkgconfig/
#將mysql的配置文件放在這個(gè)目錄下使之能夠在編譯過(guò)程中讀到相關(guān)配置選項(xiàng) 再進(jìn)行編譯安裝nagios-plugins |
chkconfig --add nagios
chkconfig nagios on #添加nagios到開機(jī)啟動(dòng)項(xiàng) vim /etc/profile PATH=$PATH:/usr/local/nagios/bin #向profile加入這一行,指明nagios命令的path . /etc/profile nagios -v /usr/local/nagios/etc/nagios.cfg #檢查配置文件的語(yǔ)法 service nagios start #如語(yǔ)法監(jiān)測(cè)為報(bào)錯(cuò)則嘗試開啟服務(wù) |
方法一、直接關(guān)閉selinux
getenforce #查看selinux的運(yùn)行狀態(tài) setenforce 0 #如果是enforce(開啟)狀態(tài),則關(guān)閉 Ps:如果您想在今后的使用中完全關(guān)閉selinux,可以通過(guò)編輯/etc/sysconfig/selinux文件,將其中的selinux后面的值“force”修改為“disable”即可。 方法二、修改相關(guān)文件的type chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin chcon -R -t httpd_sys_content_t /usr/local/nagios/share #進(jìn)行這些操作就可以在selinux開啟的狀態(tài)下正常訪問(wèn)nagios |
vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg #將這一行注釋去掉 |
vim /usr/local/nagios/etc/objects/windows.cfg
define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we're giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.0.72 ; windowsIP } #修改IP,此ip為windows主機(jī)IP |
tar xvf nrpe-2.12.tar
cd nrpe-2.12 ./configure --enable-ssl --with-ssl-lib=/lib/ make all && make install-plugin |
vi /usr/local/nagios/etc/objects/commands.cfg
#check nrpe define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } #在末行添加這些內(nèi)容 |
vim /usr/local/nagios/etc/objects/mylinux.cfg
define host{ use linux-server host_name mylinux alias mylinux address 192.168.1.2#客戶端IP即被監(jiān)控的IP } define service{ use generic-service host_name mylinux service_description check-load check_command check_nrpe!check_load } define service{ use generic-service host_name mylinux service_description check-users check_command check_nrpe!check_users } define service{ use generic-service host_name mylinux service_description otal_procs check_command check_nrpe!check_total_procs } chown -R nagios:nagios mylinux.cfg #修改配置文件的屬主屬組
|
vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg #在主配置文件指明linux主機(jī)的配置文件路徑 |
useradd nagios
|
tar zxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make && make install |
yum install openssl-devel
#先安裝openssl解決依賴 tar -zxvf nrpe-2.12.tar.gz cd nrpe-2.12.tar.gz ./configure --enable-ssl --with-ssl-lib=/usr/lib/ make all && make install-plugin && make install-daemon && make install-daemon-config #編譯安裝 |
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=192.168.1.1 #監(jiān)控端的IP /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d #開啟進(jìn)程 |
service nagiso restart
|
yum install mysql mysql-server
#簡(jiǎn)單起見yum安裝mysql service mysqld start #啟動(dòng)mysql mysqladmin -uroot -p password '123456' #給root用戶創(chuàng)建mysql密碼 mysql -uroot -p #進(jìn)入mysql mysql> create database nagios; #創(chuàng)建數(shù)據(jù)庫(kù) mysql> grant select on nagios.* to nagios@'%' identified by 'redhat'; #給nagios用戶賦予查詢權(quán)限 mysql> flush privileges; #刷新特權(quán)表 |
vim /usr/local/nagios/etc/objects/command.cfg
#check mysql define command{ command_name check_mysql command_line $USER1$/check_mysql -H 192.168.1.2 -u nagios -d nagios -p redhat } #在命令配置文件中添加這些字段 |
vim /usr/local/nagios/etc/objects/mylinux.cfg
define service{ use generic-service host_name mylinux service_description check_mysql check_command check_mysql } #在linux主機(jī)配置文件中定義服務(wù) |
service nagios restart
|
unzip fetion.zip
cd ../fetion mv fetion /usr/bin/ #將飛信腳本放在/usr/lib chmod +x /usr/bin/fetion #添加執(zhí)行權(quán)限 mv ./* /usr/lib #將剩余所有庫(kù)文件移動(dòng)到/usr/lib |
vim /usr/local/nagios/etc/templates.cfg
define contact{ name generic-contact service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s service_notification_commands notify-service-by-fetion host_notification_commands notify-host-by-fetion register 0 } #修改成上面字段 vim /usr/local/nagios/etc/commands.cfg commands.cfg define command{ command_name notify-service-by-fetion command_line /usr/bin/fetion --mobile 您的手機(jī)號(hào) --pwd 您的飛信密碼 --to 您的手機(jī)號(hào) --msg-tpye=0 --msg-utf8 $HOSTNAME } #添加這些字段 |
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。