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
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
# 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
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