您好,登錄后才能下訂單哦!
所有安裝包和文檔http://down.51cto.com/data/1877051
1安裝 nagios(中文版本的)
Get nagios-cn-3.2.3.tar.bz2 nagios-plugins-1.4.16.tar.gz
www.nagios.org 官網下載安裝包和查看文檔
tar jxf nagios-cn-3.2.3.tar.bz2
cd /nagios-cn-3.2.3
./configure
Useradd nagios
Usermod -G nagios apache
Yum install -y perl-ExtUtils-Embed
Rpm -q gd 查看系統上gd的版本號
Yum list gd 查看安裝包的gd版本
Get gd-devel-2.0.35-11.el6.x86.rpm
Yum localinstall gd-devel-2.0.35-11.el6.x86.rpm
./configure --enable-embedded-perl 配置完成后
Make all
Make install
Make install-init
Make install-commandmode
Make install-config
Make install-webconf
Cd /usr/local/nagios/
Cd etc/
Vi nagios.cfg 主配置文件
Cd objects/
Vi commands.cfg 命令配置文件
Cd /usr/local/nagios/libexec/
Tar zxf nagios-plugins-1.4.16.tar.gz
Cd nagios-plugins-1.4.16
./configure --enable-extra-opts --enable-perl-modules --enable-libtap
make
make install
Cd /usr/local/nagios/libexec/
Chown nagios.nagios *
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 檢查語法錯誤
Total Warnings:0
Total Errors:0 說明沒有錯誤
/etc/init.d/nagios restart
Cd /etc/httpd/conf.d/
Cat nagios.conf
Cat /usr/local/nagios/etc/htpasswd.users
Cd /usr/local/nagios/etc/
Mv htpasswd.user htpasswd.users
Htpasswd -m /usr/local/nagios/etc/htpasswd.users nagiosadmin 更改nagios的ssl密碼它是加密訪問的
Cat /usr/local/nagios/etc/htpasswd.uers 驗證密碼
/etc/init.d/httpd restart
https://ip/nagios
輸入用戶名和密碼
Yum install -y mailx
Cd /usr/local/nagios/etc/
Vi nagios.cfg 更改如下:
(Cfg_file=/usr/local/nagios/etc/objects/hosts.cfg原來的)吧主機配置和服務配置分開
cfg_file=/usr/local/nagios/etc/objects/host187.cfg
cfg_file=/usr/local/nagios/etc/objects/server187.cfg
Cd objects/
Cp -p localhost.cfg hosts.cfg
Cp -p localhost.cfg servers.cfg
Vi hosts.cfg 更改如下:
Define host{
Use linux-server
Host_name server67.example.com
Alias Manager
Address 192.168.0.196
Icon_p_w_picpath server.gif
Statusmap_p_w_picpath server.gd2
2d_coords 500,200
3d_coords 500,200,100
}
Define hostgroup{
Hostgroup_name linux-server
Alias linux Server
Members *
}
Vi servers.cfg更改如下:
刪除掉所有的hosts,替換所有的田朝陽家用機為server96.example.com
:%s/田朝陽家用機/server96.example.com/g
Define servicegroup{
Servicegroup_name 系統負荷檢查
Alias 負荷檢查
Membersserver96.example.com,進程總數,server96.example.com,登錄用戶數,server96.example.com,更分區,server96.example.com,交換空間利用率
}(只留一個servergroup)
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 檢查語法錯誤
/etc/init.d/nagios restart
用nagios監控另外一臺主機上的mysql
Server27 上yum install mysql-server
/etc/init.d/mysqld restart
Mysql
Create database nagdb;
Grant select on nagdb.* to nagios@’192.168.0.196’ ;
Server96 上
Cd /usr/local/nagio/libexec
./check_mysql --help
./check_mysql -H 192.168.0.127 -u nagios -d nagdb
Cd /usr/local/nagios/etc/objects/
Vi commands.cfg 更改如下:
#’check_mysql’ command definition
Define command{
Command_name check_mysql
Command_line $UER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -d $ARG2$
}
Vi hosts.cfg更改如下:
define host{
use linux-server
host_name mytest2
alias mysql
address 192.168.11.185
icon_p_w_picpath server.gif
statusmap_p_w_picpath server.gd2
2d_coords 400,100
3d_coords 400,100,50
}
Vi services.cfg更改如下:
define service{
use local-service
host_name mytest2
service_description MySQL
check_command check_mysql!nagios!cactidb
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 檢查語法錯誤
/etc/init.d/nagios reload
Vi contacts.cfg 設置監控的內容出現錯誤時email通知的地址
Define contact{
Contact_name nagiosadmin
Use generic-contact
Alias Nagios Admin
Email yakexi007@westos.org
}
/etc/init.d/nagios reload
nagios安裝好后,網頁訪問出現如下錯誤:
無權查看任何主機的信息。
請檢查HTTP服務器關于該CGI的訪問權限設置。
解決辦法:
vi /usr/local/nagios/etc/cgi.cfg
將use_authentication的值改為0.
use_authentication=0
然后重啟nagios服務
service nagios restart
還有可能:
配置文件中的hostname和service_description使用了中文。
建議hostname和service_description 不要使用中文
Su - nagios
Mail yakexi007@westos.org 發送測試郵件
在/usr/locl/nagios/var/ 查看nagios的日志nagios.log
用nagios監控其他主機的磁盤,用戶,根分區等要在所要監控的織機上安裝nagios的插件
Server27
Get nrpe-2.14.tar.gz
Tar zxf nrpe-2.14.tar.gz
在 nrpe-2.14/docs/查看安裝步驟
Evince NRPE.pdf &
Useradd nagios
Get nagios-plugins-1.4.16.tar.gz
Tar nagios-plugins-1.4.16.tar.gz
Cd nagios-plugins-1.4.16
Yum install gcc make -y
./configure 配置出現如圖但要支持那些功能
Yum install –y mysql-devel openssl-devel
./configure
Make &&make install
Cd /usr/local/
Ll -d nagios
Chown -R nagios.nagios nagios/
Chown -R nagios.nagios /usr/local/nagios/libexec
Yum install xinetd -y
Cd nrpe-2.14
./configure
Make all
Make install-plugin
Make install-daemon
Make install-daemon-config
Make install-xinetd
Vi /etc/xinetd.d/nrpe 更改如下:
吧only-from = 192.168.0.196 改成這樣
Vi /etc/services 更改如下:
nrpe 5666/tcp 添加這一行讓xinetd接聽nrpe的端口
/etc/init.d/xinetd start
Netstat -natple | grep 5666
Cd /usr/local/nagios/etc/
Vim nrpe.cfg 更改如下:
更改這行如command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
/etc/init.d/xinetd restart
在server96上也安裝nrpe
Tar zxf nrpe-2.14.tar.gz
Cd nrpe-2.14
./configure
Make all
Make install-plugin
Cd /usr/local/nagios/libexec/
./check_nrpe -H 192.168.0.127
如果出現NRPE V2.14則配置成功
./check_nrpe -H 192.168.0.127 -c check_disk
./check_nrpe -H 192.168.0.127 -c check_users
Cd /usr/local/nagios/etc/objects/
Vi commands.cfg添加
Define command{
Command_name check_nrpe
Command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Vi services.cfg添加
Define servicegroup{
Servicegroup_name 系統負荷檢查
Alias 系統負荷
Members server96.example.com,進程總數,server96.example.com,登錄用戶數,server96.example.com,交換空間利用率,server27.example.com,根分區,server27.example.com,登錄用戶數,server27.example.com,系統負荷
}
Define service{
Use local-service
Host_name server27.example.com
Service_description更分區
Check_command check_nrpe!check_disk
}
Define service{
Use local-service
Host_name server27.example.com
Service_description 登錄用戶數
Check_command check_nrpe!check_users
}
Define service{
Use local-service
Host_name server27.example.com
Service_description 系統負荷
Check_command check_nrpe!check_load
}
/usr/local/nagios/bin/nagios -v /usr/locals/nagios/etc/nagios.cfg
/etc/init.d/nagios reload 這樣就可以在圖形中監控另外一臺主機的根分區,登錄用戶等信息了。
當系統出現問題時用飛信給管理員發短信
Get fetion linuxso_2010113.tar.gz
Mv fetion /usr/local/nagios/libexec/
Cd /usr/lib/
Tar zxf linuxso_20101113.tar.gz -C /usr/lib
Cd /usr/lib
Ll
Chmod +x libACE-5.7.2.so libACE_ssl-5.7.2.so libcrypto.so.4 libssl.so.4
Ldconfig /usr/lib 不關機的情況下更新系統的庫
Cd/usr/local/nagios/libexec/
Chmod +x fetion
Chown nagios.nagios fetion
./fetion 運行飛信提示錯誤
-bash:./fetion:/lib/ld-linux.so.2:bad ELF interpreter Nosuch file or directory
Yum install –y /lib/ld-linux.so.2
Su nagios
/usr/local/nagios/libexec/fetion提示錯誤 error while loading share libraries :libstdc++.so.6
Su - root
Yum install libstdc++.so.6 -y
Su - nagios
/usr/local/nagios/libexec/fetion提示錯誤error while loading shared libraries:libgssapi_krb5.so.2
Su - root
Yum install -y libgssapi_krb5.so.2
Su - nagios
/usr/local/nagios/libexec/fetion提示錯誤error while loading shared librarles:libz.so.1
Su - root
Yum install –ylibz.so.1
Su - nagios
/usr/local/nagios/libexec/fetion 好了
/usr/local/nagios/libexec/fetion --mobile=18091883113(發送飛信的號)
--pwd=(發送飛信的手機號的密碼) --to=18091883113(收飛信的手機號) –msg-utf8=”good luck(飛信的內容)”
如果提示要輸入驗證碼則在一臺裝了圖形的主機上用ssh連接次主機然后cd /usr/local/nagios/libexec scp 13679270227.jpg 192.168.0.251:/home/wxh/Desktop(裝了圖形的主機) 然后再裝了圖形的主機上打開此圖片得到驗證碼
Su - nagios
Cd /usr/local/nagios/libexec/
Vi fetion.sh
/usr/local/nagios/libexec/fetion --mobile=13679270227 --pwd=yakxi007 --to=”$1” –msg-utf8=”$2”
Cd /usr/local/nagios/etc/objects
Vi commands.cfg 更改如下:
Define command{
Command_name notify-host-by-fetion
Command_line $USER1$/fetion.sh $CONTACTPAGER$”NOTIFICATIONTYPE$Host Alert: $HOSTNAME$ is $HOSTSTATE$”
}
Define command{
Command_name notify-service-by-fetion
Command_line $USER1$/fetion.sh $CONTACTPAGER$ “$NOTIFICATIONTYPE service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICETATE$”
}
Vi templates.cfg 更改如下:
Define contact{
在這一樣添加如下:
Host_notification_commands notify-host-by-email,notify-host-by-fetion
}
Vi contacts.cfg更改如下:
Define contact{
加一行 pager 18209184795
}
/urs/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios reload
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。