生活随笔
收集整理的這篇文章主要介紹了
监控利器nagios
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、先安裝apahce+php這里不做介紹了。
二、安裝nagios
1、建立用戶
#?useradd?-s?/sbin/nologins?nagios?#?mkdir?/usr/local/nagios?#?chown?-R??nagios.nagios?/usr/local/nagios/??#?tar?xf?nagios-3.4.1.tar.gz?#?cd?nagios?#?./configure?--prefix=/usr/local/nagios/?#?make?all?#?make?install?#?make?install-init?#?make?install-commandmode?#?make?install-config??#?chkconfig?--add?nagios?#?chkconfig?nagios?on?#?chkconfig?--list?nagios?
2、安裝插件
#?tar?xf?nagios-plugins-1.4.16.tar.gz?#?cd?nagios-plugins-1.4.16?#?./configure?--prefix=/usr/local/nagios/?#?make?&&?make?install?
三、修改配置
1、修改apache的配置文件
#?vim?/usr/local/apache2/conf/httpd.conf?User?nagios?Group?nagios??最后添加如下內容,設置成需要輸入密碼才能登陸?ScriptAlias?/nagios/cgi-bin?"/usr/local/nagios/sbin"?<Directory?"/usr/local/nagios/sbin">?????????AuthType?Basic?????????Options?ExecCGI?????????AllowOverride???None?????????Order?allow,deny?????????Allow?from?all?????????AuthName?"Nagions?Access"?????????AuthUserFile?/usr/local/nagios/etc/htpasswd?????????Require?valid-user?</Directory>??Alias?/nagios???"/usr/local/nagios/share"?<Directory?"/usr/local/nagios/share">?????????AuthType?Basic?????????Options?None?????????AllowOverride?None?????????Order?allow,deny?????????Allow?from?all?????????AuthName?"Nagios?Access"?????????AuthUserFile?/usr/local/nagios/etc/htpasswd?????????Require?valid-user?</Directory>??建立登陸的用戶名密碼?#?/usr/local/apache2/bin/htpasswd?-c?/usr/local/nagios/etc/htpasswd?admin?啟動httpd以后訪問輸入用戶名密碼就可以看到Nagios了?
2、配置nagios
在/usr/local/nagios/etc下建立2個文件:?(1)hosts.cfg定義主機的文件?define?host{?????use????linux-server????????//引用linux-server的屬性信息,linux-server在templates.cfg中定義?????host_name????localhost????//主機名?????alias????host1????????????//別名?????address????192.168.163.143????????//ip地址?}?define?host{?????use????linux-server?????host_name????host-142?????alias????host2?????address????192.168.163.142?}??(2)services.cfg?定義主機服務的文件?define?service{?????use????local-service????????//引用local-service的屬性信息,在template.cfg中定義?????host_name????host-142????//監控那個主機,host-142在hosts.cfg中定義?????service_description????ssh????//對監控內容的描述?????check_command????check_ping????//指定監控的命令,check_ping在commands.cfg中定義?}?define?service{?????use????local-service?????host_name????localhost?????service_description????Ping?????check_command????check_ping?}?
3、添加admin用戶信息,這里的admin用戶是之前htpasswd生成的用戶:
default_user_name=admin?authorized_for_system_information=nagiosadmin,admin?authorized_for_configuration_information=nagiosadmin,admin?authorized_for_system_commands=nagiosadmin,admin?authorized_for_all_services=nagiosadmin,admin?authorized_for_all_hosts=nagiosadmin,admin?authorized_for_all_service_commands=nagiosadmin,admin?authorized_for_all_host_commands=nagiosadmin,admin?
4、修改nagios.cfg文件,添加文件路徑信息:
cfg_file=/usr/local/nagios/etc/hosts.cfg?cfg_file=/usr/local/nagios/etc/services.cfg?cfg_file=/usr/local/nagios/etc/objects/commands.cfg?cfg_file=/usr/local/nagios/etc/objects/contacts.cfg?cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg?cfg_file=/usr/local/nagios/etc/objects/templates.cfg
5、檢查是否有問題
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如下正常,如果有問題的話nagios會提示那有錯誤非常明確的
#service nagios restart
啟動nagios后訪問下:
1、查看主機的信息:
2、查看服務的信息
轉載于:https://blog.51cto.com/peaceweb/1033722
總結
以上是生活随笔為你收集整理的监控利器nagios的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。