您好,登錄后才能下訂單哦!
Nagios是一款功能強大的網絡監視工具,它可以有效的監控windows、linux、unix主機狀態以及路由器交換機的網絡設置,打印機工作狀態等,并將狀態出現異常的服務及時以郵件、msn短信等形式第一時間通告管理員。由于它是一款遵循GPLv2的開源網絡監控軟件,以其出色的性能低廉的使用成本,深受廣大用戶的好評。
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必須的基本組件的運行依賴于httpd、mysql、gd以及編譯用到的gcc |
groupadd nagcmd
#添加與nagios運行相關服務的組 useradd -m nagios #添加nagios用戶 usermod -a -G nagcmd nagios #將nagios用戶追加附加組 usermod -a -G nagcmd apache #將apache用戶追加nagcmd組使之工作時具有足夠的權限 |
tar xvf nagios-3.3.1.tar.gz
cd nagios # ./configure --with-command-group=nagcmd --enable-event-broker #默認安裝路徑在/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頁面創建賬號密碼,對訪問進行身份認證 service httpd restart chkconfig httpd on #啟動httpd,并設置開機啟動 |
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過程中,在此處編譯完成發現mysql關聯庫文件本跳過。經分析原因是由于在編譯nagios時修改了nagios的默認安裝路徑(非/usr/local/nagios)。 解決辦法: |
cp /usr/lib/mysql/mysql_config /usr/lib/pkgconfig/
#將mysql的配置文件放在這個目錄下使之能夠在編譯過程中讀到相關配置選項 再進行編譯安裝nagios-plugins |
chkconfig --add nagios
chkconfig nagios on #添加nagios到開機啟動項 vim /etc/profile PATH=$PATH:/usr/local/nagios/bin #向profile加入這一行,指明nagios命令的path . /etc/profile nagios -v /usr/local/nagios/etc/nagios.cfg #檢查配置文件的語法 service nagios start #如語法監測為報錯則嘗試開啟服務 |
方法一、直接關閉selinux
getenforce #查看selinux的運行狀態 setenforce 0 #如果是enforce(開啟)狀態,則關閉 Ps:如果您想在今后的使用中完全關閉selinux,可以通過編輯/etc/sysconfig/selinux文件,將其中的selinux后面的值“force”修改為“disable”即可。 方法二、修改相關文件的type chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin chcon -R -t httpd_sys_content_t /usr/local/nagios/share #進行這些操作就可以在selinux開啟的狀態下正常訪問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主機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$ } #在末行添加這些內容 |
vim /usr/local/nagios/etc/objects/mylinux.cfg
define host{ use linux-server host_name mylinux alias mylinux address 192.168.1.2#客戶端IP即被監控的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主機的配置文件路徑 |
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 #監控端的IP /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d #開啟進程 |
service nagiso restart
|
yum install mysql mysql-server
#簡單起見yum安裝mysql service mysqld start #啟動mysql mysqladmin -uroot -p password '123456' #給root用戶創建mysql密碼 mysql -uroot -p #進入mysql mysql> create database nagios; #創建數據庫 mysql> grant select on nagios.* to nagios@'%' identified by 'redhat'; #給nagios用戶賦予查詢權限 mysql> flush privileges; #刷新特權表 |
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主機配置文件中定義服務 |
service nagios restart
|
unzip fetion.zip
cd ../fetion mv fetion /usr/bin/ #將飛信腳本放在/usr/lib chmod +x /usr/bin/fetion #添加執行權限 mv ./* /usr/lib #將剩余所有庫文件移動到/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 您的手機號 --pwd 您的飛信密碼 --to 您的手機號 --msg-tpye=0 --msg-utf8 $HOSTNAME } #添加這些字段 |
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。