Battle centos 6.0 + Nagios Chinese version + PNP + Nagios web management tool nagiosql Chinese Version
17:17:56 | category:
RHEL _ monitoring | label:
| Large font size, medium/small subscription
The Nagios online tutorials are written by Baidu. I found that some of the tutorials are somewhat different. It is estimated that some of them are copies, copies, and posts are messy. I can't do anything as I said. Today I personally practice it, the on-site screenshot helps you to clearly understand the problems encountered in the process and how to solve them. It is a little hard to capture the picture and write it out. It is worth learning everything, follow me ~!
Download centos 6.0 and install the system. It is best to use VMWare for the best.
Centos 6.0 latest version of Domestic: http://mirrors.163.com/centos/6.0/isos/i386/
After installing the system, prepare the environment before installation.
I paste the command out. To facilitate your operation, you just need to copy and paste the command with me, saving the trouble of hitting the command and avoiding mistakes (tips: after centos is installed, install VMware Tools in X-Windows to copy and paste the files between the physical machine and the virtual machine. The method is simple)
Yum-y install httpd gettext MySQL mysql-server mysql-devel PHP-mysql PHP-Pear
Yum install PHP-mysql MySQL Perl mysql-Server Perl-DBI Perl-DBD-mysql httpd GCC glibc-common GD Gd-devel PHP
Download Nagios apps and plug-ins online
Wget
Http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz (the latest version of plug-in now)
Wget
Http://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.2.3/nagios-cn-3.2.3.tar.bz2/download (the latest version of 3.3.1, installed on the interface that has become difficult to see, by the way to find a Chinese Version)
Preparation of users and groups
Start to install the main program
./Configure -- prefix =/usr/local/Nagios -- With-Nagios-user = Nagios -- With-Nagios-group = Nagios -- With-command-group = nagcmd
The following error occurs when you execute the make all command.
It seems that the compiler is not installed by default in centos. Install the following:
Yum-y install GCC automake Autoconf libtool make
Continue the make all operation and find the final error,
Execute the make clean operation first, and then execute
./Configure & make all operation (problem sharing) and then execute the following command.
Next, install the plug-in.
./Configure -- With-Nagios-user = Nagios -- With-Nagios-group = Nagios
Add the user nagiosadmin and password to access the page. Remember this password.
Htpasswd-C/usr/local/Nagios/etc/htpasswd. Users nagiosadmin
Start Related Services
Check whether the configuration file is correct
/Usr/local/Nagios/bin/Nagios-V/usr/local/Nagios/etc/Nagios. cfg
[Experience Sharing: Because the command for checking this string is long and the application rate is high, we can customize a command to replace this long string of commands.
Edit the. bashrc file.
Use alias to customize a command instead. Here I use check
Use the source command to read and execute the commands in bashrc in the current bash Environment
In this way, the custom command takes effect. If you enter check, you can check whether the Nagios configuration file is incorrect. This is simple and convenient.]
If no warning or error is found, it indicates that it has passed.
Now you can access the Nagios web access console through http: // serverip/Nagios.
If you enable the firewall, remember to open port 80. Otherwise, the connection will fail, or you can directly disable the firewall by using the Command Service iptables stop.
Problem sharing: this error is reported when you click host or other options when you enter the page. Later, Baidu started The SELinux mandatory access control security module.
NOTE: If SELinux is enabled, You need to configure the following two steps:
Chcon-r-t httpd_sys_content_t/usr/local/Nagios/sbin/
Chcon-r-t httpd_sys_content_t/usr/local/Nagios/share/
Now that the authentic Chinese version is available, we have taken a small step towards success. Please be patient and let us continue ~~!
[Experience Sharing: I am using virtual machines here. Remember to create a System Snapshot after the system and network parameters are configured. After Nagios is installed successfully, we will create a snapshot, in order to avoid subsequent configuration errors, we can return here and re-configure them, which is convenient and convenient. Remember to shut down the VM before creating a snapshot. Otherwise, the snapshot file is too scary, after the snapshot file is closed, the snapshot file size will be several hundred kb.]
OK. Let's proceed.
[Nrpe_plugins Metric Collection Program is mainly used to analyze the plug-in script of the nrpe client to collect performance metric data. Currently, performance indicators of CPU, memory, disk, buffer, singleprocess, Oracle, Sybase, and other aspects are implemented. This plug-in must be installed on the master and control terminals respectively, this plug-in requires OpenSSL support. If not, you can directly install it online (YUM install OpenSSL-devel). Therefore, you still need to install it on the Nagios host and the controlled terminal, which is quite troublesome, we can't help it.]
Download nrpe first.
Wget
Http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
Decompress the file
Compile and install
After the task is completed, no error occurs. You can see the following generated files.
Ii. Configure PNP
[PNP is a tool based on PHP and Perl that uses rrdtool to plot the data collected by Nagios. Therefore, you must install PHP Perl and rrdtool before installing PNP. Here, you can directly install rrdtool using yum, there are many dependencies between downloading and installation separately, which is quite troublesome.]
The latest version is 0.6.15.
Wget
Http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.15.tar.gz/download
An error was reported during compilation.
Yum install Perl-time-hires
The Perl modules is not found during compilation. It seems that the command is used to accelerate the compilation.
Continue as prompted
Then, change the related suffix with the sample file to a non-sample suffix.
Configure Nagios to enable PNP
Enable_environment_macros = 1 is enabled by default.
Pnp4nagios has many working modes. Here we use the synchronization mode. If you want to select another mode, you can refer to the instructions for detailed configuration tutorials (different modes have different configurations)
Here we will follow the instructions for setting
[Copy the file for executing data collection in pnp4nagios to libexec in Nagios to facilitate Unified Command Execution path.]
CP/usr/local/pnp4nagios/libexec/process_perfdata.pl/usr/local/Nagios/libexec/
Add the following content to commands. cfg (the synchronization mode setting method is used here)
# Process-host-perfdata 'COMMAND Definition
Define command {
Command_name process-host-perfdata
Command_line $ user1 $/process_perfdata.pl-D hostperfdata
}
# Process-service-perfdata 'COMMAND Definition
Define command {
Command_name process-service-perfdata
Command_line $ user1 $/process_perfdata.pl
}
Then add a small Sun template and embed it on the Nagios page.
[There are two ways to view a graph. The first method is to open the Graph view in a new window when the sun icon is displayed, the second method is that you only need to move the mouse over the sun icon and the image will pop up automatically. You can choose one of the following two methods as you like]
The first method is to add the following to templates. cfg:
Define host {
Name host-PNP
Action_url/pnp4nagios/index. php/graph? Host = $ hostname $ & SRV = _ host _
Register 0
}
Define Service {
Name SRV-PNP
Action_url/pnp4nagios/index. php/graph? Host = $ hostname $ & SRV = $ servicedesc $
Register 0
}
The second method is described as follows:
Copy the status-header.ssi to the/usr/local/Nagios/share/ssi/directory (this step is important, or else move to the Sun tag for a diagram)
Define host {
Name host-PNP
Action_url/pnp4nagios/index. php/graph? Host = $ hostname $ & SRV = _ host _ 'class = 'tids' rel = '/pnp4nagios/index. php/popup? Host = $ hostname $ & SRV = _ host _
Register 0
}
Define Service {
Name SRV-PNP
Action_url/pnp4nagios/index. php/graph? Host = $ hostname $ & SRV = $ servicedesc $ 'class = 'tids' rel = '/pnp4nagios/index. php/popup? Host = $ hostname $ & SRV = $ servicedesc $
Register 0
}
Method 2 Final
Add a small Sun icon next to the target host icon
Add a small Sun flag for related services
Run the pnp4nagios environment test and find that the PHP-Gd module is invalid. The command Yum install PHP-Gd will not work after the installation is successful, later, the old boy instructed him to use Yum install PHP *-y to install and then restarted the system,
Rename install. php as required
Run the following command to restart the Nagios service.
OK. Now we have configured the PNP, which is a little tired. But we have to continue. The last Nagios web management tool in this chapter is nagiosql (note: there is also a Nagios web management tool named nconf)
Wget
Http://sourceforge.net/projects/nagiosql/files/nagiosql/NagiosQL%203.1.1/nagiosql_311.tar.gz/download
Nagiosql is a Web management tool. You only need to put it in Apache. This is because it should be integrated with Nagios. To facilitate management, put it under the Nagios directory.
Create a directory for nagiosql to export the Nagios configuration file and modify the permissions
Create a directory and Change permissions
Mkdir-P/etc/nagiosql/{hosts, services, backup/{, hosts, services}, import}
Chown-r Apache: Nagios/etc/nagiosql/
Chmod-r 755/etc/nagiosql
Chmod 777/usr/local/Nagios/nagiosql/config
Nagios-Related File Permission settings
Chown Nagios: Apache/usr/local/Nagios/etc
Chown Nagios: Apache/usr/local/Nagios/etc/{Nagios. cfg, CGI. cfg}
Chown Nagios: Apache/usr/local/Nagios/etc /*
Chmod 664/usr/local/Nagios/etc/{Nagios. cfg, CGI. cfg}
Chmod 775/usr/local/Nagios/etc
Set Nagios binary file permissions so that they can be executed through web programs
Chown Nagios: Apache/usr/local/Nagios/bin/Nagios
Chmod 750/usr/local/Nagios/bin/Nagios
Chown-r Apache. Nagios/usr/local/Nagios/var/spool/
Chown Nagios: Apache/usr/local/Nagios/var/RW/Nagios. cmd
Chmod 660/usr/local/Nagios/var/RW/Nagios. cmd
Add a virtual directory named nagiosql for Apache
Alias/nagiosql "/usr/local/Nagios/nagiosql"
<Directory "/usr/local/Nagios/nagiosql">
# Sslrequiressl
Options none
AllowOverride none
Order allow, deny
Allow from all
</Directory>
Reload the HTTPd service and start the mysqld service
Create a nagiosql Installation File
Touch/usr/local/Nagios/nagiosql/install/enable_installer
Access http: // ip/nagiosql for Installation
Problem sharing: I was prompted that I didn't have the access permission during the access. After half a day, it was originally caused by SELinux. I modified the real-time running mode of SELinux and set setenforce 0 (set SELinux to permissive mode) this is only a temporary solution. The advantage is that you do not need to restart the system to take effect, but if you want to completely disable SELinux, you need to set the SELinux parameter to 0 in/etc/sysconfig/SELinux.
Select Chinese and click "Start installation ".
If the environment required for testing passes, simply follow the next step.
Delete the installation directory. Change the permission to chmod 000/usr/local/Nagios/nagiosql/install.
The installation process is complete. Next we need to perform the relevant configuration.
Manage-Domain-localhost --- click "modify"
Just change the corresponding path.
Tool-some configuration files are listed on the right of the imported data. Select import.
Import only imports the content of the configuration file to the MySQL database. When using the configuration file, CFG files are used one by one. Therefore, the write process is as follows:
Tool-Nagios control-write detection data-Write Other data
Check that the configuration file is successful.
After writing, you can see the corresponding cfg file and check whether the write is successful. The output below shows that the write is successful.
Modify the configuration file of Nagios, comment out all the items starting with pai_file, and add the newly written configuration file.
Comment out
Add a new configuration file path
Export _dir =/etc/nagiosql/hosts/
Export _dir =/etc/nagiosql/services/
Export _file =/etc/nagiosql/commands. cfg
Export _file =/etc/nagiosql/contactgroups. cfg
Export _file =/etc/nagiosql/contacts. cfg
Export _file =/etc/nagiosql/contacttemplates. cfg
Export _file =/etc/nagiosql/hostdependencies. cfg
Export _file =/etc/nagiosql/hostescalations. cfg
Export _file =/etc/nagiosql/hostextinfo. cfg
Export _file =/etc/nagiosql/hostgroups. cfg
Pai_file =/etc/nagiosql/hosttemplates. cfg
Export _file =/etc/nagiosql/servicedependencies. cfg
Export _file =/etc/nagiosql/serviceescalations. cfg
Export _file =/etc/nagiosql/serviceextinfo. cfg
Export _file =/etc/nagiosql/servicegroups. cfg
Export _file =/etc/nagiosql/servicetemplates. cfg
Pai_file =/etc/nagiosql/timeperiods. cfg
Check whether there is a problem with the Nagios configuration file and restart the Nagios service. Now the entire setup process is complete. The next section will explain the important part, how to Use nagiosql to add the host to be monitored and enable the Nagios alarm mechanism ~~!
Monitor Windows Hosts
There are three implementation methods for Nagios to monitor Windows Host: SNMP, nsclient ++, and nrpe. The following two methods need to install the agent on Windows, this document only describes how to use nsclient ++ to monitor windows
Install and configure Windows Host plug-ins
:
Http://nsclient.org/nscp/downloads
I used version 0.3.8.zip and found that the latest version 0.3.9 is not compatible with Windows server2003 SP1 and cannot be started.
Decompress the package and run the installation command.
The-noboot parameter must be added before installation. Otherwise, problems may occur.
Decompress the package and edit NSC. ini. Remove the semicolon, as shown in.
Add the IP address of the server that allows the host to access in the Settings section. Enter the IP address of your Nagios server.
In the nsclient section, enable the default listening port 12489 of nsclinet and the host name that allows access to the local machine. After editing, save and exit.
Run the netstat-An command to check whether the port service is running.
Go to the server and run./check_nrpe-h to monitor the server's Host IP address. If you see the IP address, it means it is okay.
Use nagiosql to add the host to be monitored
Supervisor-host-add
Set host name, address, and select Template
Then add other services as needed. First, add the usage of drive C,Supervisor-service-add
Complete the overall settings as shown in.
The above just explains how to define a service. In fact, all the services to be monitored have been defined, so we can directly call these services and want to learn more, click Modify to see how each item is set. (To monitor what you want, you need to learn more by yourself and then define the services you want)
Add the services defined above for the current host (and then return to the current defined host) and select "service options"-select the defined services to be monitored, in fact, you can select a host when defining a service, or you can select related services on the host.
Remember to select write configuration here, and then restart the Nagios service.
Run Once from top to bottom
After a while, you can see the following figure on the Nagios interface:
Click the corresponding service options on the graphic monitoring interface to display the corresponding graphic monitoring interface.
Add the server to the beauty icon
As shown in, if the device is a vro, we will add a graph generator icon next to it. If the device is a service, we will add a Server icon. At a glance, we will be able to differentiate the type of the device, easy management,
[Read the official documentation and find that there are four variables available in the host definition to specify the icon file name for each host. The default storage location is/usr/local/Nagios/share/images/logos.
Icon_image: You can use GIF, PNG, or JPG files. The recommended image size is 40x40.
Icon_image_alt: indicates the alt attribute value of the Image Element in HTML syntax.
Vrml_image
Statusmap_image: Submit