yum -y install gd gd-devel openssl openssl-devel httpd php gcc glibc glibc-common make net-snmp wget2) 创建nagios账户与组配置时使用--with-nagios-user和--with-nagios-group指定以该账号的身份运行Nagios。useradd nagios3) ×××地址Nagios:http://superb-sea2.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.2.1/nagios-4.2.1.tar.gzNagios-plugin:https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gzNrpe:http://pilotfiber.dl.sourceforge.net/project/nagios/nrpe-3.x/nrpe-3.0.1.tar.gz4) Nagios的安装tar -zxf nagios-4.2.1.tar.gz -C /usr/local
cd /usr/local
cd nagios-4.2.1/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install #安装主程序,CGI以及HTML文件
make install-init #安装启动脚本/etc/init.d/nagios
make install-commandmode #安装与配置目录权限
make install-config #安装配置文件模板
# 由于nagios最终将以web的形式进行管理与监控,安装过程中使用make install-webconf命令将生成Apache附加配置文件/etc/httpd/conf.d/nagios.conf
make install-webconf5) Nagios插件安装tar -zxf nagios-plugins-2.1.2.tar.gz -C /usr/local
cd /usr/local/nagios-plugins-2.1.2/
./configure --prefix=/usr/local/nagios
make
make install
tar -zxf nrpe-3.0.1.tar.gz -C /usr/local/
cd /usr/local
cd nrpe-3.0.1/
./configure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
chown nagios:nagios -R /usr/local/nagios6) 禁用selinux并关闭防火墙setenforce 0
service iptables stop7) 创建web访问账户htpasswd -c /usr/local/etc/htpasswd.users tomcat8) 启动nagios/etc/init.d/httpd start
/etc/init.d/nagios start9) 修改nagios配置文件主配置文件:nagios.cfg主配置文件中使用cfg_file配置项加载其他配置文件,为了方便管理,将两台监控主机创建不同的配置文件,10.20.2.235配置文件名为web1.cfg,10.20.2.236配置文件名为web2.cfgvi /usr/local/nagios/etc/nagios.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
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
#下面两个配置文件需要手动创建出来,用于监控两台web服务器
cfg_file=/usr/local/nagios/etc/web1.cfg
cfg_file=/usr/local/nagios/etc/web2.cfg
……修改CGI配置文件(cgi.cfg),需要将访问web页面的账号加入进来vi /usr/local/nagios/etc/cgi.cfg
use_authentication=1
authorized_for_system_information=nagiosadmin,tomcat
authorized_for_configuration_information=nagiosadmin,tomcat
authorized_for_system_commands=nagiosadmin,tomcat
authorized_for_all_services=nagiosadmin,tomcat
authorized_for_all_hosts=nagiosadmin,tomcat
authorized_for_all_service_commands=nagiosadmin,tomcat
authorized_for_all_host_commands=nagiosadmin,tomcat
……修改命令配置文件(commands.cfg),该文件定义具体的命令实现方式,如发送报警邮件具体使用什么工具、邮件内容格式定义。vi /usr/local/nagios/etc/objects/commands.cfg
……
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
……
#以下内容需要手动添加,用于进行远程主机监控,需要安装nrpe软件包
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
} 修改nrpe配置文件(nrpe.cfg),用于监控远程主机所需要的命令vi /usr/local/nagios/etc/nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
#下面一行为手动添加
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10%
……修改监控主机配置文件(localhost.cfg),该文件用于设置如何监控本机服务器资源。vi /usr/local/nagios/etc/objects/localhost.cfg
……
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
}
……
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members localhost ; Comma separated list of hosts that belong to this group
}
…… 创建远程监控配置文件web1.cfg与web2.cfg,用于监控远程服务器系统资源与服务,可以使用localhost.cfg作为参考模板。下面列出web1.cfg的所有内容,web2.cfg 只需要参考web1.cfg的内容修改主机名称、IP地址以及主机名称即可。define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name web1
alias test.com
address 10.20.2.235
}
define hostgroup{
hostgroup_name webs ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members web1 ; Comma separated list of hosts that belong to this group
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
notifications_enabled 1
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description Sys_Load
check_command check_nrpe!check_load
notifications_enabled 1
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description Current Users
check_command check_nrpe!check_users
notifications_enabled 1
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description Total Processes
check_command check_nrpe!check_total_procs
notifications_enabled 1
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description SSH
check_command check_ssh
notifications_enabled 1
}
define service{
use generic-service ; Name of service template to use
host_name web1
service_description HTTP
check_command check_http
notifications_enabled 1
}10) 重新加载nagios配置其他配置文件不需修改,可以直接使用,重启nagios,重新加载所有的配置/etc/init.d/nagios restart3. Nagios监控端部署下面以web1为例,web2与web1操作一致1) yum安装nagios插件需依赖的软件包yum -y install openssl openssl-devel2) 创建nagios用户和组useradd -s /sbin/nologin nagios3) 安装Nagios-plugintar -zxf nagios-plugins-2.1.2.tar.gz -C /usr/local
cd /usr/local/
cd nagios-plugins-2.1.2/
./configure
make
make install4) 安装Nrpetar -zxf nrpe-3.0.1.tar.gz -C /usr/local
cd /usr/local/nrpe-3.0.1/
./configure
make all
make install-plugin
make install-daemon
make isntall-daemon-config
chown -R nagios:nagios /usr/local/nagios 5) 修改nrpe配置文件cp /usr/local/nrpe-3.0.1/sample-config/nrpe.cfg /usr/local/nagios/etc/
vi /usr/local/nagios/etc/nrpe.cfg
……
allowed_hosts=127.0.0.1,10.20.2.233
……
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
#下面一行为手动添加
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10%6) 禁用selinux并关闭防火墙setenforce 0
service iptables stop 7) 启动nrpe/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d4. 验证并进行监控1) 验证监控端的nrpe管理员在Nagios服务端通过check_nrpe检测被监控端相关的性能参数,单独使用check_nrpe可以检测被监控端的nrpe版本号[root@test etc]# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.235
NRPE v3.0.1
[root@test etc]# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.236
NRPE v3.0.1
[root@test etc]# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.237
connect to address 10.20.2.237 port 5666: Connection refused
connect to host 10.20.2.237 port 5666: Connection refused2) 访问web页面进行监控以上信息已经能够检测到被监控端的nrpe,此时可以通过浏览器进行访问:http://10.20.2.233/nagios


我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm