煮酒品茶: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" # 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 Alias /nagios "/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 |
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"; |