您好,登錄后才能下訂單哦!
煮酒品茶:cwtea.blog.51cto.com
#yum intsall -y httpd php gcc make |
tar zxvf nagios-3.5.0rc2.tar.gz |
cd nagios |
./configure --prefix=/usr/local/nagios
make all
make install
useradd nagios
#把nagios加入到apache組。
usermod -G nagios apache
make install
make install-init
make install-commandmode
make install-config
make install-webconf
|
./configure --prefix=/usr/local/nagios
make
make install
|
Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 3.5.0rc2 03-09-2013 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
#PID號
Lock file: ${prefix}/var/nagios.lock
#檢查結果目錄
Check result directory: ${prefix}/var/spool/checkresults
#服務配置目錄
Init directory: /etc/rc.d/init.d
#apache for nagios目錄
Apache conf.d directory: /etc/httpd/conf.d
#mail程序
Mail program: /bin/mail
#主機名
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
|
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
#安裝主程序,CGI文件和Html文件。
make install-init
- This installs the init script in /etc/rc.d/init.d
#安裝nagios服務,腳本在/etc/rc.d/init.d/nagios
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
#安裝和配置權限在外部命令目錄
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
#把樣版配置文件拷到/usr/local/nagios/etc目錄。
make install-webconf
- This installs the Apache config file for the Nagios
web interface
#安裝apache配置nagios選項文件。yum安裝會創建/etc/http/conf.d/nagios.cfg
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
#主題
make install-classicui
- This installs the classic theme for the Nagios
web interface
#經典主題
|
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
|
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
|
[Fri Mar 15 00:22:46 2013] [error] [client 192.168.100.80] (13)Permission denied: exec of '/usr/local/nagios/sbin/status.cgi' failed, referer: http://192.168.100.84/nagios/side.php |
It appears as though you do not have permission to view information for any of the services you requested... |
authorized_for_system_information=cwtea
authorized_for_configuration_information=cwtea
authorized_for_system_commands=cwtea
authorized_for_all_services=cwtea
authorized_for_all_hosts=cwtea
authorized_for_all_service_commands=cwtea
authorized_for_all_host_commands=cwtea
|
#hostgroup
define hostgroup {
hostgroup_name ktm-server
alias ktm server
members nagios-server
}
#host
define host {
host_name nagios-server
alias nagios server
address 192.168.100.85
contact_groups ktm
check_command check-host-alive
max_check_attempts 5
notification_interval 10
notification_period 24x7
notification_options d,u,r
}
#contact
define contact {
contact_name cwtea
alias system administrator
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email zwhset@163.com
pager 15010228888
}
#contactgroup
define contactgroup {
contactgroup_name ktm
alias system administrator
members cwtea
}
|
#service in host
define service {
host_name nagios-server
service_description check-host-alive
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups ktm
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive
}
|
cfg_file=/usr/local/nagios/etc/objects/hc.cfg
cfg_file=/usr/local/nagios/etc/objects/service.cfg
#add #
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
|
.
├── archives
├── nagios.lock #PID號保存文件。
├── nagios.log #當然是日志啦。
├── objects.cache #當你查看這個文件,你就會喜歡上他了。緩存的,看下面解釋。
├── retention.dat #上面緩存一個,這里又保留一個。好兄弟要哥倆啊。
├── rw
│?? └── nagios.cmd #看下面解決。
├── spool
│?? └── checkresults #這個文件夾在工作的時候會經常寫冊文件,這當然是在采集數據存放于此。
└── status.dat #這個就有意思了,網站讀的就是這個文件,service模塊下有個performance_data=rta=0.497000ms;3000.000000;5000.000000;0.000000 pl=0%;80;100;0,對比網站上的是不是一樣?
|
# OBJECT CACHE FILE
# This option determines where object definitions are cached when
# Nagios starts/restarts. The CGIs read object definitions from
# this cache file (rather than looking at the object config files
# directly) in order to prevent inconsistencies that can occur
# when the config files are modified after Nagios starts.
對象緩存文件。這些選項將決定當Nagios啟動時或重新啟動時,對象定義將被緩存在什么地方。CGI將從這個對象文件中讀取對象的定義,而不是在之前的對象配置文件路徑中去找。這樣做是為了避免修改Nagios配置文件后引起的不一致問題。換句簡單的話說就是更改配置文件后要重新運新Nagios新的配置參數才會生效,而當前運行的Nagios只參考緩存中的配置參數而已。
object_cache_file=/var/log/nagios/objects.cache
|
# EXTERNAL COMMAND FILE
# This is the file that Nagios checks for external command requests.
# It is also where the command CGI will write commands that are submitted
# by users, so it must be writeable by the user that the web server
# is running as (usually 'nobody'). Permissions should be set at the
# directory level instead of on the file, as the file is deleted every
# time its contents are processed.
這是Nagios用來檢查外部命令請求的文件。這個文件同樣也是用戶操作提交與CGI命令寫入的地方,所以這個文件必須對于相關服務可寫,一般是針對Apache的宿主用戶可寫。并且注意,這個文件所在的目錄的權限必須被Apache可寫,而不單指這文件,因為這個文件在工作當中是頻繁被刪除的。(之前我們將Apahe歸入Nagios組的時候就已經完成了)
command_file=/var/log/nagios/rw/nagios.cmd
|
# STATUS FILE
# This is where the current status of all monitored services and
# hosts is stored. Its contents are read and processed by the CGIs.
# The contents of the status file are deleted every time Nagios
# restarts.
狀態文件。這個文件將保存著目前檢測到的服務和主機數據信息。這個文件當中的內容是被CGI讀取并處理的,而它也是在每次Nagios重新啟動的時候被刪除清空的。
status_file=/var/log/nagios/status.dat
|
.
├── nagios #這個是啟動文件
└── nagiostats #運行一下這個,你會發現世界是多么的精彩。這個不就是nagios web界面上的信息嗎?他也是采集這個文件。
|
#網上找的說明,難得敲字。
bin Nagios執行程序所在目錄,nagios文件即為主程序
etc Nagios配置文件位置,初始安裝完后,只有幾個*.cfg-sample文件
sbin Nagios Cgi文件所在目錄,也就是執行外部命令所需文件所在的目錄
Share Nagios網頁文件所在的目錄
Var Nagios日志文件、spid 等文件所在的目錄
|
//$corewindow="main.php";
$corewindow="cgi-bin/status.cgi";
|
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。