Rotten mud: nagios Learning (4): pnp4nagios graphical drawing of nagios data, pnp4nagiosnagios

Source: Internet
Author: User
Tags rrd rrdtool install perl

Rotten mud: nagios Learning (4): pnp4nagios graphical drawing of nagios data, pnp4nagiosnagios

This document consistsXiuyi Lin FengProviding friendship sponsorship, first launchedThe world

After nagios is installed, we also add some monitoring objects, but you will find that nagios is just a simple method to list those monitoring objects, instead of integrating the data of these monitoring objects. As follows:

In fact, nagios has provided us with a graphics tool pnp4nagios, but we haven't installed it yet.

Pnp4nagios is a powerful tool based on php and perl. It can use the process_perfdata.pl script to call rrdtool to analyze the performance data of nagios and draw a corresponding performance diagram. Therefore, before installing pnp4nagios, we must first install php, perl, and rrdtool.

For the convenience of the experiment, we will install php and perl using yum.

For the installation of rrdtool, see the following article.

Note: In this article, all operations are performed on the nagios server.

1. What is rrdtool?

Rrdtool is the abbreviation of Round Robin Database Tool. In terms of functionality, rrdtool can be used for data storage + data display. The well-known network traffic plotting software cacti and Cluster Monitoring System Ganglia use rrdtool.

In terms of data storage, rrdtool uses the "Round Robin" mode to store data, that is, ring databases. Note: The suffix of the rrdtool database file is ". rrd ".

For details about rrdtool, refer to Baidu encyclopedia.

Http://baike.baidu.com/view/1867979.htm

Rrdtool can be seen as a powerful Drawing Engine for data presentation. This is one of them on the official website. We have a general understanding of the drawing capabilities of rrdtool.

After introducing the rrdtool function, we will install rrdtool now.

Ii. Install rrdtool

For rrdtool installation, we will introduce the source code and yum installation.

2.1Source code Installation

The source code is installed in several steps.

2.1.1Download the rrdtool package

Download the latest source code package from the official rrdtool website. As follows:

Http://oss.oetiker.ch/rrdtool/

Download rrdtool:

Http://oss.oetiker.ch/rrdtool/pub? M = D

Wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.5.0-rc2.tar.gz

2.1.2Install basic library

Before officially installing rrdtool, we must also install the required base library for rrdtool compilation. As follows:

Yum-y install gcc cairo-devel libxml2-devel pango-devel pango libpng-devel freetype-devel libart_lgpl-devel

2.1.3Install rrdtool

After the basic library is installed, we now start to formally install rrdtool.

Decompress the rrdtool package as follows:

Tar-xf rrdtool-1.5.0-rc2.tar.gz

Cd rrdtool-1.5.0-rc2

Configure rrdtool as follows:

./Configure

Compile rrdtool as follows:

Make

Install rrdtool as follows:

Make install

2.1.4View the rrdtool installation path

After rrdtool is installed, let's check the installation path of rrdtool. Rrdtool's default installation path is/opt/rrdtool-1.5.0-rc2/if you do not specify the rrdtool installation path /. We can know this by installing and configuring rrdtool as follows:

./Configure -- help

View the content of rrdtool installation as follows:

Ll/opt/rrdtool-1.5.0-rc2/

2.1.5Verify rrdtool

After rrdtool is installed, verify that it is correctly installed. Run the following command:

/Opt/rrdtool-1.5.0-rc2/bin/rrdtool-v

We can clearly see the usage and version information of rrdtool. This indicates that rrdtool has been correctly installed.

2.2 yumInstallation Method

The yum method of rrdtool is easy to install. You can directly use the following command to install rrdtool.

Yum-y install rrdtool-perl

After rrdtool is installed, check its installation location as follows:

Which rrdtool

Rpm-ql rrdtool

We can see that the yum method of rrdtool is installed, and the rrdtool is installed in the/usr/bin directory.

Rpm-ql rrdtool-perl

Note:

/Usr/lib64/perl5/vendor_perl/auto/RRDs is the path of the rrds perl module, which will be used when installing and configuring pnp4nagios.

3. Install pnp4nagios

In the previous article, we have introduced the functions of pnp4nagios.

Pnp4nagios is a powerful tool based on php and perl. It can use the process_perfdata.pl script to call rrdtool to analyze the performance data of nagios and draw a corresponding performance diagram.

For the installation of pnp4nagios, we can also install pnp4nagios in source code and yum. The following describes how to install pnp4nagios.

3.1Download the pnp4nagios Software Package

To install pnp4nagios using the source code, we need to download the pnp4nagios software package. We can download it on its official website. As follows:

Http://docs.pnp4nagios.org

Http://docs.pnp4nagios.org/pnp-0.6/start

Http://sourceforge.net/projects/pnp4nagios/

Wget http://jaist.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz

3.2Install the perl-Time-HiRes component

The perl-Time-HiRes component must be installed before pnp4nagios is installed. Otherwise, the following error message is displayed when pnp4nagios is installed:

Configure: error: Perl Module Time: HiRes not available

Run the following command to install the perl-Time-HiRes extension component:

Yum-y install perl-Time-HiRes

3.3Install pnp4nagios

Decompress the pnp4nagios package as follows:

Tar-xf pnp4nagios-0.6.25.tar.gz

Cd pnp4nagios-0.6.25

Configure pnp4nagios as follows:

./Configure -- with-rrdtool =/opt/rrdtool-1.5.0-rc2/bin/rrdtool -- with-perl_lib_path =/opt/rrdtool-1.5.0-rc2/lib/perl/5.10.1/x86_64-linux-thread-multi/auto/RRDs

Note:

-- With-rrdtool =/opt/rrdtool-1.5.0-rc2/bin/rrdtool

Indicates the path of the rrdtool command. In rrdtool, we use the source code for installation.

-- With-perl_lib_path =/opt/rrdtool-1.5.0-rc2/lib/perl/5.10.1/x86_64-linux-thread-multi/auto/RRDs

Indicates the path of the RRD perl module. In rrdtool, we use the source code for installation.

If the path of the rrds perl module is not specified, the following error is displayed during Configuration:

RRDs Perl Modules: *** not found ***

If rrdtool is installed in yum mode, run the following command to configure pnp4nagios:

./Configure -- with-perl_lib_path =/usr/lib64/perl5/vendor_perl/auto/RRDs

Because rrdtool is installed in yum mode, the RRD perl module is installed in the/usr/lib64/perl5/vendor_perl/auto/RRDs path. As follows:

If the pnp4nagios configuration is correct, the following interface is displayed:

Compile pnp4nagios as follows:

Make all

Note:

We know that there are two ways to install pnp4nagios In the last step: make install to install pnp4nagios step by step, and make fullinstall to automatically install pnp4nagios.

To learn more about pnp4nagios installation, we use make install. As follows:

Make install

Note: The default installation path of pnp4nagios is/usr/local/pnp4nagios/, which can be obtained through configuration help information. As follows:

./Configure -- help

The web configuration file for installing pnp4nagios is as follows:

Make install-webconf

NOTE: If apache is installed using the source code, an error will be reported when we execute make install-webconf.

Don't be afraid. Just copy sample-config/httpd. conf to/usr/local/apache2/conf/and rename it pnp4nagios. conf. Install apache in/usr/local/apache2. As follows:

Cp sample-config/httpd. conf/usr/local/apache2/conf/pnp4nagios. conf

Ll/usr/local/apache2/conf/

After the preceding operations, add Include conf/pnp4nagios. conf to the/usr/local/apache/conf/httpd. conf file. Finally, we need to restart apache.

The configuration file for installing pnp4nagios is as follows:

Make install-config

The following is the initialization script for installing pnp4nagios:

Make install-init

3.4 pnp4nagiosDirectory Introduction

After pnp4nagios is installed, let's check its installation directory, as shown below:

Ll/usr/local/pnp4nagios/

The following describes the directory of pnp4nagios:

The bin directory is used to store the pnp4nagios startup command npcd. As follows:

/Usr/local/pnp4nagios/bin/npcd-h

The pnp4nagios boot script is controlled by this command, as follows:

Vi/etc/init. d/npcd

The etc directory stores various configuration files of pnp4nagios, as follows:

Ll/usr/local/pnp4nagios/etc/

The lib directory stores the pnp4nagios library files.

The libexec directory stores the pnp4nagios execution plug-ins, such as process_perfdata.pl.

Other directories do not need to be described.

3.5 yumInstall pnp4nagios

To install pnp4nagios using yum, We need to configure additional yum sources. As follows:

Http://dl.fedoraproject.org/pub/epel/6/x86_64/

Download and install the additional yum source package. As follows:

Rpm-ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

View the files installed on the additional yum source, as shown below:

Rpm-ql epel-release

Obviously, the installation of an additional yum source is the installation of the repo file. For how to use the repo file, refer to the article "mud: use and configuration of yum".

Install pnp4nagios as follows:

Yum-y install pnp4nagios

Note:

YumWhen pnp4nagios is installed, nagios is installed. Therefore, if we use the source code to install nagios, we recommend that you use the source code to install pnp4nagios. If nagios is installed in yum mode, pnp4nagios is also installed in yum mode.

4. Configure pnp4nagios

After pnp4nagios is installed, We will configure pnp4nagios now.

Switch to the etc directory of the pnp4nagios installation directory, as shown below:

Cd/usr/local/pnp4nagios/etc/

Modify the content in the etc directory as follows:

Mv misccommands. cfg-sample misccommands. cfg

Mv nagios. cfg-sample nagios. cfg

Mv rra. cfg-sample rra. cfg

Modify the content in the etc/pages directory as follows:

Mv pages/web_traffic.cfg-sample pages/web_traffic.cfg

Modify the content in the etc/check_commands directory as follows:

Mv check_commands/check_all_local_disks.cfg-sample check_commands/check_all_local_disks.cfg

Mv check_commands/check_nrpe.cfg-sample check_commands/check_nrpe.cfg

Mv check_commands/check_nwstat.cfg-sample check_commands/check_nwstat.cfg

After the preceding modifications, We will configure the pnp4nagios working mode.

V. pnp4nagios Working Mode

Pnp4nagios has five working modes: Synchronous Mode, Bulk Mode, Bulk Mode with NPCD, Bulk Mode with NPCD and npcdmod, and Gearman Mode.

5.1 Synchronous ModeMode

Synchronous Mode is the simplest integration method. It works by directly integrating process_perfdata.pl scripts into nagios, and each event is called once. For example:

5.2 Bulk ModeMode

Bulk Mode (Bulk Mode) is a little more complex than synchronous Mode. Because the synchronization Mode processes each event, if the number of hosts and services is large, the performance of the monitoring server may decrease.

In Bulk mode, nagios writes performance data to a temporary directory in a specific format. Pnp4nagios periodically calls process_perfdata.pl for processing and deletes the data file after processing. This method reduces the number of processes, reduces the IO access and load of the nagios host, and makes up for the shortcomings in the synchronization mode. For example:

5.3 Bulk Mode with NPCDMode

Bulk Mode with NPCD Mode. It can be seen from the name that this Mode is similar to Bulk Mode, but it only takes one more step to move the performance data plus the timestamp to the spool directory for medium processing, the npcd service calls the process_perfdata.pl script to process the data. For example:

This mode is the one we use most and the one we will use in this experiment.

The other two modes are not described here. If you want to know all the working modes of pnp4nagios, you can access this connection. As follows:

Http://docs.pnp4nagios.org/pnp-0.6/config

If you cannot understand the English language, you can also refer to this article pnp4nagios working mode details.

6. Start pnp4nagios

After pnp4nagios is installed, start pnp4nagios. To start pnp4nagios, run the following command:

/Etc/init. d/npcd start

Ps aux | grep npcd

We can see that pnp4nagios is started normally, and that pnp4nagios is running under nagios users.

For future convenience, we will start pnp4nagios directly. As follows:

Chkconfig npcd on

Chkconfig -- list npcd

VII. Access pnp4nagios

After pnp4nagios is started, we can access pnp4nagios through the following connection:

Http: // 192.168.1.247/pnp4nagios/

Note: The above dialog box will pop up. Here, we only need to fill in the users configured in nagios with access permissions. Here, I enter nagiosadmin, the Administrator account of nagios.

The above two images show that pnp4nagios can be accessed normally.

However, in the second figure, we also see the system prompts. As follows:

Your environment passed all requirements. Remove or rename the/usr/local/pnp4nagios/share/install. php file now.

It means to delete or rename the/usr/local/pnp4nagios/share/install. php file.

Now we operate on this file as follows:

Mv/usr/local/pnp4nagios/share/install. php/usr/local/pnp4nagios/share/install. php. bak

Ll/usr/local/pnp4nagios/share/

After the file is operated, refresh the page again and the following error message may appear. As follows:

Session_start (): open (/var/lib/php/session/sess_rv62qv22fno63rrtnq2l80h1_0, O_RDWR) failed: Permission denied (13)

This error indicates that you are not authorized to operate files in the/var/lib/php/session directory.

Why is there no operation permission?

Now we can view the/var/lib/php/session directory permissions as follows:

Ll/var/lib/php/

Through this, we can clearly see that the session directory currently belongs to the root user and apache user group, while pnp4nagios uses the nagios user to run, so this directory has no operation permission.

Now that the problem has been found, we can solve it. Change the session directory to nagios users and user groups. As follows:

Chown nagios: nagios-R/var/lib/php/

Ll/var/lib/php/

After modification, refresh the page. As follows:

We can see that pnp4nagios has drawn an image.

8. Configure nagios

In the pnp4nagios operating modes, we use the Bulk Mode with NPCD Mode. To use Bulk Mode with NPCD Mode, we need to modify the configuration of nagios as follows.

8.1Configure the nagios. cfg file

Modify nagios configuration file nagios. cfg and add or modify the following options in the file:

Vi/usr/local/nagios/etc/nagios. cfg

Process_performance_data = 1

#

# Service performance data

#

Service_perfdata_file =/usr/local/pnp4nagios/var/service-perfdata

Response = DATATYPE: SERVICEPERFDATA \ tTIMET ::$ TIMET $ \ tHOSTNAME ::$ HOSTNAME $ \ tSERVICEDESC ::$ SERVICEDESC $ \ tSERVICEPERFDATA ::$ SERVICEPERFDATA $ \ tSERVICECHECKCOMMAND :: $ SERVICECHECKCOMMAND $ \ tHOSTSTATE: $ HOSTSTATE $ \ tHOSTSTATETYPE ::$ HOSTSTATETYPE $ \ tSERVICESTATE ::$ SERVICESTATE $ \ tSERVICESTATETYPE ::$ SERVICESTATETYPE $

Service_perfdata_file_mode =

Service_perfdata_file_processing_interval = 15

Service_perfdata_file_processing_command = process-service-perfdata-file

#

# Host performance data starting with Nagios 3.0

#

Host_perfdata_file =/usr/local/pnp4nagios/var/host-perfdata

Host_perfdata_file_template = DATATYPE: HOSTPERFDATA \ tTIMET ::$ TIMET $ \ tHOSTNAME ::$ HOSTNAME $ \ tHOSTPERFDATA ::$ HOSTPERFDATA $ \ tHOSTCHECKCOMMAND ::$ HOSTCHECKCOMMAND $ \ tHOSTSTATE :: $ HOSTSTATE $ \ tHOSTSTATETYPE: $ HOSTSTATETYPE $

Host_perfdata_file_mode =

Host_perfdata_file_processing_interval = 15

Host_perfdata_file_processing_command = process-host-perfdata-file

Note:

Process_performance_data = 1 indicates that nagios performance data output is enabled.

If you cannot remember the above content, we can copy it directly from the/usr/local/pnp4nagios/etc/nagios. cfg file. As follows:

Vi/usr/local/pnp4nagios/etc/nagios. cfg + 16

8.2Configure the commands. cfg file

After modifying the nagios. cfg file, edit the commands. cfg file. Add or modify the following options in the file:

Vi/usr/local/nagios/etc/objects/commands. cfg

Define command {

Command_name process-service-perfdata-file

Command_line/bin/mv/usr/local/pnp4nagios/var/service-perfdata/usr/local/pnp4nagios/var/spool/service-perfdata. $ TIMET $

}

Define command {

Command_name process-host-perfdata-file

Command_line/bin/mv/usr/local/pnp4nagios/var/host-perfdata/usr/local/pnp4nagios/var/spool/host-perfdata. $ TIMET $

}

In addition, the original process-host-perfdata and process-service-perfdata definitions in nagios must be commented out. As follows:

If you cannot remember the above content, we can copy it directly from the/usr/local/pnp4nagios/etc/misccommands. cfg file. As follows:

Vi/usr/local/pnp4nagios/etc/misccommands. cfg + 34

8.3Configure the templates. cfg file

After the commands. cfg file is modified, edit the templates. cfg file. Add the following options to the file:

Vi/usr/local/nagios/etc/objects/templates. cfg

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

}

If you cannot remember the content above, it's okay. We can check it directly from the pnp4nagios official website. As follows:

Http://docs.pnp4nagios.org/pnp-0.6/webfe

8.4Configure the host cfg file

After all the above files are configured, we now add a host. As follows:

Vi/usr/local/nagios/etc/ilanni. cfg

Define host {

Use ilanniserver, host-pnp

Host_name ilanni

Alias test server

Address 192.168.1.248

Check_command check-host-alive

}

Define service {

Use generic-service, srv-pnp

Host_name ilanni

Service_description nrpe_load

Check_command check_nrpe! Check_load

}

9. view the pnp4nagios plot

After the nagios configuration is complete, let's check whether the nagios configuration is correct. As follows:

/Etc/init. d/nagios configtest

We can see that the nagios configuration is correct.

Now we can restart pnp4nagios and nagios, as shown below:

/Etc/init. d/npcd restart

/Etc/init. d/nagios reload

Now we can log on to nagios to check the host performance diagram drawn by pnp4nagios, as shown below:

From the above three figures, we can see that pnp4nagios has drawn the host-related data.

Then let's take a look at the pnp4nagios rendering service performance diagram, as shown below:

From the above three figures, we can see that pnp4nagios has drawn the service-related data.

Finally, let's look at the location where pnp4nagios stores the data. As follows:

Ll/usr/local/pnp4nagios/var/perfdata/

Ll/usr/local/pnp4nagios/var/perfdata/ilanni

By now, all the graphs related to pnp4nagios's nagios performance have been completed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.