设为首页 收藏本站
查看: 877|回复: 0

nagios 的安装

[复制链接]

尚未签到

发表于 2017-4-20 08:33:05 | 显示全部楼层 |阅读模式
  来源:
  http://webcache.googleusercontent.com/search?q=cache:KYssdPHmkHoJ:www.techmajha.com/2010/04/15/rpmforge-yum-repository/+nagios+Configuration+validation+failed&cd=10&hl=zh-CN&ct=clnk
  http://heipark.iteye.com/blog/1190929
  service nagios start
  出错:
  nagios is stopped
  Configuration validation failed
  
解决办法:
  # vi /etc/selinux/config
SELINUX=disabled

然后重启计算机,就OK了.
#安装nagios
yum -y install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe check_logfiles

#添加nagios到系统自动运行
chkconfig --add nagios
chkconfig nagios on
 

nagios相关路径:

/etc/nagios #配置文件目录:
/etc/nagios/objects #模板相关配置
/usr/bin/nagios# nagios程序
配置Apache密码访问

 

# nagiosadmin为用户名,配置这个用户名为省很多事
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
启动并测试

 

service nagios start
service httpd start
#打开浏览器,输入密码,在host里面应该有“localhost”这台机器
http://{your_ip_address}/nagios
  nagios is stopped
Configuration validation failed
解决办法:
How to Access NTFS partition from linux (Centos / RHEL) ?
How to install media player like VLC on Centos / RHEL ?

How to install network monitoring tool likenagioson Centos / RHEL ?
You may have reached here while googling solution for above question’s ?
Centos / RHEL are the enterprise level server operating system and is not packaged with entertainment pack.
Whereas distributions like fedora, ubuntu Desktop are meant for clients or desktop computers. Where you will not come across above issues, the entertainment packages is the part of fedora and ubuntu distribution.
Here, RPMforge RPM repositories come into picture.
RPMforge is a collaboration of Dag, Dries, and other packagers. They provide over 4000 packages for CentOS, including mplayer, VLC, xmms-mp3, and other popular media tools. It is not part of RedHat or CentOS but is designed to work with these major distributions.

To install RPMforge YUM repository use following 5 steps.
Note: Internet required
1.Use following 3 sub steps to Install DAG GPG key
 
# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm –import RPM-GPG-KEY.dag.txt
# rm RPM-GPG-KEY.dag.txt
 
2.Install yum-priorities.
Note :The yum-priorities is used to enforce ordered protection of repositories, by giving priorities to repositories. Packages from repositories with a lower priority will be given lowest priority. This plugin is particularly useful for anyone who uses one or more third-party repositories, as these repositories may update system files, which can potentially compromise the stability of your CentOS installation.

 
# yum install yum-priorities
 
3.Download and install package (i386 – 32bit) Use following 3 sub steps
 
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rm rpmforge-release-0.3.6-1.el5.rf.i386.rpm
 
3.Download and install package (x86_64 – 64bit) Use following 3 sub steps
 
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
# rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
# rm rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
 
4.Files created in /etc/yum.repos.d/ folder
# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo mirrors-rpmforge rpmforge.repo
5.Properly configure priorities of yum repositories as follows :
 
# vim /etc/yum.repos.d/CentOS-Base.repo
[base] or [updates] or [addons] or [extras]
priority=1
[centosplus]
priority=2
 
 
# vim /etc/yum.repos.d/rpmforge.repo
[rpmforge]
priority=10
 
Note: The Repository with higher priority will be given higher priority for installing any package. e.g. if you want rpmforge repository should have highest priority than you can set highest priority for the same as above. The priorities are also in effect when a new package is installed – if a package is in more than one repository, it will be installed from the repository with the highest priority.
——————————————————————————————————————————————————

Examples:
Gstreamer Movie Player is multimedia player for *NIX systems

# yum clean all
# yum install gstreamer*
# yum whatprovides gstreamer-plugins-ugly
# yum install gstreamer-plugins-ugly
# yum install gstreamer-plugins-bad
VLC Player is commonly used multimedia player
 
To install VLC Playerjust type
# yum install vlc
 
————————————————————————————–
Following is the result of successful installation of ntfs module.
 
# yum install -y fuse fuse-ntfs-3g
 
———————————————————————————
To installnagios
# yum installnagiosnagios-pluginsnagios-plugins-nrpenagios-devel
# chkconfignagioson
#nagios-v /etc/nagios/nagios.cfg
Things look okay – No serious problems were detected during the pre-flight check
Configure Apache forNagios: Add User :
# htpasswd -c /etc/nagios/htpasswd.usersnagios
New password:
Re-type new password:
Adding password for usernagios
Restart Apache to make new settings effective.
# /etc/init.d/httpd restart
Restartnagiosservice
# servicenagiosrestart
Configurationvalidationfailed [FAILED]
As shown above Ifnagiosservicefailedto start. you should disable selinux and restart machine to activate changes :
# vi /etc/selinux/config
SELINUX=disabled
On restartnagiosshould start successfully.
Open the browser like Mozilla and type :
http://localhost/nagios/
username :nagios
password :
you will have following error :

To overcome above error Configure Apache forNagios: Add User :nagiosadmin
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
This will add user nagiosadmin
# vim /etc/nagios/cgi.cfg
# AUTHENTICATION USAGE
use_authentication=1
# SYSTEM/PROCESS INFORMATION ACCESS
authorized_for_system_information=nagiosadmin
#CONFIGURATIONINFORMATION ACCESS
authorized_for_configuration_information=nagiosadmin
# SYSTEM/PROCESS COMMAND ACCESS
authorized_for_system_commands=nagiosadmin
# GLOBAL HOST/SERVICE VIEW ACCESS
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
# GLOBAL HOST/SERVICE COMMAND ACCESS
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
Once again open the browser like Mozilla and type :
http://localhost/nagios/
username : nagiosadmin
password :


NagiosConfigurationfiles/directories :
# ls /etc/nagios/
cgi.cfg htpasswd.users objects/
command-plugins.cfgnagios.cfg resource.cfg
# ls /etc/nagios/objects/
commands.cfg localhost.cfg switch.cfg timeperiods.cfg
contacts.cfg printer.cfg templates.cfg windows.cfg
————————————————————————–
ClientConfiguration
  Linux client configuraiton
# /usr/sbin/useraddnagios
# passwdnagios
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
# tar -xzfnagios-plugins-1.4.14.tar.gz
# cdnagios-plugins-1.4.14
# ./configure –with-nagios-user=nagios–with-nagios-group=nagios
# make
# make install
# chownnagios.nagios/usr/local/nagios
# chown -Rnagios.nagios/usr/local/nagios/libexec
# yum install xinetd
# yum install libssl-dev
# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz/download
# tar xvzf nrpe-2.12.tar.gz
# cd nrpe-2.12
# ./configure
# make all
# make install-plugin
# make install-daemon
# vi /etc/xinetd.d/nrpe
Should Look Like:
# default: on
# description: NRPE (NagiosRemote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user =nagios
group =nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg –inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 [NAGIOSSERVER ADDRESS]
}
# vi /etc/services
add:
nrpe 5666/tcp # NRPE
# service xinetd restart
# netstat -at | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
USERS WARNING – 6 users currently logged in |users=6;5;10;0
# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs
PROCS WARNING: 178 processes
# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
OK – load average: 0.15, 0.24, 0.25|load1=0.150;15.000;30.000;0; load5=0.240;10.
000;25.000;0; load15=0.250;5.000;20.000;0;
# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1
DISK OK – free space: /boot 81 MB (87% inode=99%);| /boot=11MB;78;88;0;98
If this worked correctly its time to setup yourNagiosserver to monitor your remote host, so ssh once againg into yourNagiosserver.
Now we are going to add separate host file i.e linux.cfg for the new host so we need to edit the nano “nagios.cfg” file:

# vi /etc/nagios/nagios.cfg
And Add following line
cfg_file=/etc/nagios/objects/linux.cfg
# vi /etc/nagios/objects/linux.cfg
##################################################
##################################################
# HOST DEFINITIONS
##################################################
##################################################
# Define a host for the Windows machine we’ll be monitoring
# Change the host_name, alias, and address to fit your situation
define host{
use linux-server ; Inherit default values from a template
host_name remotelinux ; The name we’re giving to this host
alias My Linux Server ; A longer name associated with the host
address 192.168.19.146 ; IP address of the host
}
##################################################
# HOST GROUP DEFINITIONS
##################################################
# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group
define hostgroup{
hostgroup_name linux clients ; The name of the hostgroup
alias linux ; Long name of the group
members remotelinux
}
##################################################
# SERVICE DEFINITIONS
##################################################
# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name remotelinux
service_description Ping
check_command check_ping!100.0,20%!500.0,60%
}
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name remotelinux
service_description Users
check_command check_nrpe!check_users
}
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name remotelinux
service_description CPU Load
check_command check_nrpe!check_load
}
# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name remotelinux
service_description HDD Status
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name remotelinux
service_description CPU Load
check_command check_nrpe!check_hda1
}
# servicenagiosrestart
Stoppingnagios: [ OK ]
Startingnagios: [ OK ]
# /usr/bin/nagios-v /etc/nagios/nagios.cfg
———————————————————————————
Windows clientconfiguration
Download 64bit NSClient from :
http://sourceforge.net/projects/nscplus/files/nscplus/NSClient%2B%2B%200.3.8/NSClient%2B%2B-0.3.8-x64.msi/download
Download 32bit NSClient from :
http://sourceforge.net/projects/nscplus/files/nscplus/NSClient%2B%2B%200.3.8/NSClient%2B%2B-0.3.8-Win32.zip/download
Edit fileC:\Program Files\NSClient++\nsc.ini
This file is divided in sections placed in brackets.

1.First go to [modules] section and uncheck the modules you want to monitor.
The FileLogger.dll logs the activities of the NSClient++.
CheckDisk.dll checks the file size and hard disk use.
The CheckSystem.dll will check for memory, uptime, service stats and processes.
You will also need to uncomment the NSClientListener.dll and the NRPEListener.dll in order to communicate withNagios.

2.Then go to [Settings] section. Under the ALLOWED HOSTS ADDRESSES section enter the local host and the machine you want to monitor.
These addresses should be separated by a comma.

[Settings]
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to the all daemons.
; If leave this blank anyone can access the deamon remotly (NSClient still requires a valid password).
; The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that subnet access
allowed_hosts=127.0.0.1/32,192.168.19.0/24

3.Now go to [NSClient] section. Under the ALLOWED HOSTS ADDRESSES section enter the IP Address of machine you want to monitor.
[NSClient]
;# ALLOWED HOST ADDRESSES
; This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon.
; If you leave this blank the global version will be used instead.
; Enter the IP Address ofNagiosServer
allowed_hosts=192.168.19.187/255.255.255.0

4.Finally, under [NRPE] set your port that NRPE will listen to.
[NRPE]
;# NRPE PORT NUMBER
; This is the port the NRPEListener.dll will listen to.
port=5666

Since, NSClient++ is configured according to our requirement.
Go to Start -> run -> services.msc -> look for NSClient++ and restart it.


Once all is set up and running ssh intonagiosserver and check your connection.
# /usr/lib/nagios/plugins/check_nrpe -H 192.168.19.52
I (0.3.8.75 2010-05-27) seem to be doing fine…

If you get any errors you will need to correct them, use the log for locating the errors.

Enable WARNING / CRITICAL status email notification
# vi /etc/nagios/objects/contacts.cfg
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
aliasNagiosAdmin ; Full name of user
email techmajha@gmail.com ; ***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
——————————————————–
Graphing inNagiosbased on Historical Data
We will use PNP4Nagios for Graphs. PNP is an addon for theNagiosNetwork Monitoring System. PNP provides easy to use, easy to configure RRDTools based performance charts feeded by the performance data output of theNagiosPlugins.
Download PNP4Nagios software
# wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.7.tar.gz/download
# tar xvzf pnp4nagios-0.6.7.tar.gz
# cd pnp4nagios-0.6.7
# ./configure
***Configurationsummary for pnp4nagios-0.6.7 09-27-2010 ***
General Options:
————————- ——————-
Nagiosuser/group:nagiosnagios
Install directory: /usr/local/pnp4nagios
HTML Dir: /usr/local/pnp4nagios/share
Config Dir: /usr/local/pnp4nagios/etc
Location of rrdtool binary: /usr/bin/rrdtool Version 1.4.4
RRDs Perl Modules: FOUND (Version 1.4004)
RRD Files stored in: /usr/local/pnp4nagios/var/perfdata
process_perfdata.pl Logfile: /usr/local/pnp4nagios/var/perfdata.log
Perfdata files (NPCD) stored in: /usr/local/pnp4nagios/var/spool

Web Interface Options: ————————- ——————-
HTML URL: http://localhost/pnp4nagios
Apache Config File: /etc/httpd/conf.d/pnp4nagios.conf

Review the options above for accuracy. If they look okay,
type ‘make all’ to compile.

# make all
*** Compile finished ***
make install
– This installs the main program and HTML files

Enjoy.
# make install
*** Main program, Scripts and HTML files installed ***
Please run ‘make install-webconf’ to install the
webconfigurationfile

Please run ‘make install-config’ to install sample
configurationfiles

Please run ‘make install-init’ if you want to use
BULK Mode with NPCD

# make install-config
# make install-webconf
/usr/bin/install -c -m 644 httpd.conf /etc/httpd/conf.d/pnp4nagios.conf
*** Apache config file installed ***
Now open /etc/nagios/nagios.cfg and uncomment lines as listed below
# vi /etc/nagios/nagios.cfg
# PROCESS PERFORMANCE DATA OPTION
# This determines whether or notNagioswill process performance
# data returned from service and host checks. If this option is
# enabled, host performance data will be processed using the
# host_perfdata_command (defined below) and service performance
# data will be processed using the service_perfdata_command (also
# defined below). Read the HTML docs for more information on
# performance data.
# Values: 1 = process performance data, 0 = do not process performance data
process_performance_data=1
# HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS
# These commands are run after every host and service check is
# performed. These commands are executed only if the
# enable_performance_data option (above) is set to 1. The command
# argument is the short name of a command definition that you
# define in your hostconfigurationfile. Read the HTML docs for
# more information on performance data.
#host_perfdata_command=process-host-perfdata
#service_perfdata_command=process-service-perfdata
# HOST AND SERVICE PERFORMANCE DATA FILES
# These files are used to store host and service performance data.
# Performance data is only written to these files if the
# enable_performance_data option (above) is set to 1.
host_perfdata_file=/tmp/host-perfdata
service_perfdata_file=/tmp/service-perfdata
# HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES
# These options determine what data is written (and how) to the
# performance data files. The templates may contain macros, special
# characters (\t for tab, \r for carriage return, \n for newline)
# and plain text. A newline is automatically added after each write
# to the performance data file. Some examples of what you can do are
# shown below.
host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
# HOST AND SERVICE PERFORMANCE DATA FILE MODES
# This option determines whether or not the host and service
# performance data files are opened in write (“w”) or append (“a”)
# mode. If you want to use named pipes, you should use the special
# pipe (“p”) mode which avoid blocking at startup, otherwise you will
# likely want the defult append (“a”) mode.
host_perfdata_file_mode=a
service_perfdata_file_mode=a
# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL
# These options determine how often (in seconds) the host and service
# performance data files are processed using the commands defined
# below. A value of 0 indicates the files should not be periodically
# processed.
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS
# These commands are used to periodically process the host and
# service performance data files. The interval at which the
# processing occurs is determined by the options above.
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
At the end of /etc/nagios/objects/commands.cfg, add the command definitions
define command{
command_name process-service-perfdata-file
command_line $USER1$/process_perfdata.pl –bulk=/usr/local/nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line $USER1$/process_perfdata.pl –bulk=/usr/local/nagios/var/host-perfdata
}
Append following 2 entries to /etc/nagios/objects/templates.cfg :
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
These are templates that you add to each host and service definition for graphs in /etc/nagios/objects/windows.cfg and /etc/nagios/objects/linux.cfg files and any other client config file.:
# vi /etc/nagios/objects/windows.cfg
define host{
use windows-server,host-pnp ; Inherit default values from a template
host_name winserver ; The name we’re giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.19.52 ; IP address of the host
}
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
use generic-service,srv-pnp
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
use generic-service,srv-pnp
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
RestartNagios
# servicenagiosrestart

Possibly Related Posts:

  • Printer Drivers for linux
  • OCS Inventory NG and GLPI
  • Wifi: Wireless card drivers of Dell vostro laptops for Centos
  • google chrome on centos
  • How to setup pptpconfig (VPN client tunnel)
 
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-366592-1-1.html 上篇帖子: nagios windows 下篇帖子: nagios pnp
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表