Tag Archives: Monitoring

Pnp4nagios Pi – Integrate With Nagios Web Interface

Pnp4nagios Pi – Integrate With Nagios Web Interface

Define pnp4nagios host and service definitions

Pnp4nagios can be integrated in to Nagios using the action_url directive in host and service definitions to add an icon / link to graphs.

The first step to integrate pnp4nagios with the Nagios web interface is to define host and service definitions by performing the following steps:

  • Logon to the Raspberry Pi and execute the following command to become root:
sudo -i
  • Backup the existing  /usr/local/nagios/etc/objects/template.cfg file (Optional step)
cp /usr/local/nagios/etc/objects/templates.cfg /usr/local/nagios/etc/objects/templates.cfg-beforepnp4nagios
  • Next edit /usr/local/nagios/etc/objects/templates.cfg using the editor of your choice
  • Go to the end of the file and add the host and services definitions below:
define host {
   name host-pnp
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=HOST
   register 0
}

define service {
   name service-pnp
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
   register 0
}

Update the Nagios generic definitions

  • Next locate the generic-host definition and add in the line shown below in bold:
define host{
        name            generic-host ; The name of this host template
        use             host-pnp
  • FInally locate the generic-service definition and add in the line shown below in bold:
define service{
    name                generic-service ; The 'name' of this service template
    use                 service-pnp
  • Save and exit the file
  • Following the modifications to the templates.cfg file Nagios needs to be restarted by executing the following command:
systemctl restart nagios

PHP 7 Modification

Following the installation and configuration of pnp4nagios I encountered the error shown in the screen shot below:

A quick google turned up the following article https://github.com/lingej/pnp4nagios/issues/148 which gave the solution below for me as my Pi is running PHP 7:

  • Edit the /usr/local/pnp4nagios/share/application/models/data.php file
  • Go to line 979 and change if(sizeof($pages) > 0 ){ to if(is_arrary($pages) && sizeof($pages) > 0 ){
  • Save and exit the file

Pnp4nagios Pi – Configuring Nagios Commands

Pnp4nagios Pi – Configuring Nagios Commands

Configure Nagios to process performance data

Following the successful installation of pnp4nagios the next step is to configure Nagios to process performance data as well as send the data to pnp4nagios. The configuration for this piece is performed by editing the main nagios.cfg file to first enable processing of performance data, then configure the performance data file settings for hosts and services.

To modify configure Nagios to process performance data and configure the performance data file settings for hosts and services perform the following steps:

  • Logon to the Raspberry Pi and execute the following command to become root:
sudo -i
  • Backup the existing /usr/local/nagios/etc/nagios.cfg file (Optional step)
cp /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg-beforepnp4nagios
  • Edit /usr/local/nagios/etc/nagios.cfg using the editor of your choice
  • Locate the line process_performance_date=0 to process_performance_date=1 as shown below:
# PROCESS PERFORMANCE DATA OPTION
# This determines whether or not Nagios will 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
  • Next locate the line starting with #host_perfdata_file= and add in the two lines in bold as shown below to set the performance data file locations to pnp4nagios:
# 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=/usr/local/nagios/var/host-perfdata
#service_perfdata_file=/usr/local/nagios/var/service-perfdata

host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
  • Next locate the line starting with #host_perfdata_file_template= and add in the two lines in bold as shown below to set the data file templates:
# 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_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
  • Next locate the line starting with #host_perfdata_file_mode=a and add the two lines in bold as shown below:
# 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 default append ("a") mode.

#host_perfdata_file_mode=a
#service_perfdata_file_mode=a

host_perfdata_file_mode=a
service_perfdata_file_mode=a
  • Next locate the line starting with #host_perfdata_file_processing_interval= and add the two lines in bold as shown below:
# 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=0
#service_perfdata_file_processing_interval=0

host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
  • Next locate the line starting with #host_perfdata_file_processing_command= and add the two lines in bold as shown below:
# 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

host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd
service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd
  • Save and exit the file

Configure the Nagios commands

The next step in the process is to add the commands to Nagios which will be used to process the performance data with pnp4nagios by performing the following steps:

  • Backup the existing /usr/local/nagios/etc/objects/commands.cfg file (Optional step)
cp /usr/local/nagios/etc/objects/commands.cfg /usr/local/nagios/etc/objects/commands.cfg-beforepnp4nagios
  • Edit /usr/local/nagios/etc/objects/commands.cfg using the editor of your choice
  • Go to the end of the file and add the command definitions below:
define command {
    command_name    process-service-perfdata-file-bulk-npcd
    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-bulk-npcd
    command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
    }
  • Save and exit the file

Validate the Nagios config and restart Nagios

Once the configuration has been applied to Nagios it needs to be validated and restarted by performing the following steps:

  • Validate the Nagios configuration by executing the following command:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  • Next restart Nagios by executing the following command:
systemctl restart nagios

Next, proceed on to the next article in the series to integrate with the Nagios Core Web Interface.

Pnp4nagios Pi – Installing pnp4nagios

Pnp4nagios Pi – Installing pnp4nagios

Introduction

This article explains how to implement pnp4nagios on a Raspberry Pu running Raspian Buster Lite and Nagios Core 4.4.5.

pnp4nagios is an add-on for Nagios Core which analyzes performance data provided by plugins and stores them automatically into RRD-databases. This data can then be displayed as graphs for host and service checks.

Prerequisites

In order to implement pnp4nagios on a Raspberry Pi running Raspian Buster Lite and Nagios 4.4.5 the following pre-requisites must be met:

  • Nagios Core installed

Preparing to install pnp4nagios

Before installing pnp4nagios the prerequisite packages need to be installed and the software downloaded

To prepare for the installation of pnp4nagios perform the following steps:

  • Logon to the Raspberry Pi and execute the following command to become root:
sudo -i
  • The next step is to install the pre-requisite packages by executing the following commands:
apt-get update
apt-get -y install rrdtool librrds-perl php-gd php-xml
  • Once the prerequisite packages have been installed download and unpack the source code by executing the following commands:
cd /tmp
wget -O pnp4nagios-0.6.26.tar.gz https://sourceforge.net/projects/pnp4nagios/files/latest
tar -zxf pnp4nagios-0.6.26.tar.gz

Compiling and installing pnp4nagios

Once the system has been prepared and the software downloaded, perform the following steps to compile and install pnp4nagios:

  • To configure pnp4nagios execute the following commands:
cd pnp4nagios-0.6.26/
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
  • To install pnp4nagios once it has been compiled execute the following commands:
make install
make install-webconf
make install-config
make install-init

Configure and start / restart daemons

The last part of the installation process for pnp4nagios is to configure and start / restart daemons on the server by performing the following steps:

  • To configure and start the npcd daemon execute the following commands:
systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd
  • The final step is to restart Apache on the server by executing the following command:
systemctl restart Apache

Next, proceed on to the next article in the series to configure Nagios commands.

Openfiler – Monitoring With Cacti

Openfiler – Monitoring With Cacti

Introduction

This article explains how to configure an Openfiler server for SNMP monitoring through Cacti.

The infrastructure used for this article was an Openfiler 2.3 virtual machine being monitored by a Fedora Core 10 64-bit server running Cacti.  Both virtual machines were hosted on a Fedora Core 8 64-bit server running VMware Server 1.0.8.

Pre-requisites

In order to configure an Openfiler 2.3 server for SNMP monitoring in Cacti the following pre-requisites must be met :-

  • An installed Openfiler 2.3 server / appliance with SNMP configured
  • An existing Cacti installation

Adding a device

The following section provides the configuration settings selecting when adding an Openfiler server as a new device in Cacti.  In order to add an Openfiler server in to Cacti as a new device perform the following steps :-

  1. Logon to the Cacti web site as an administrative user
  2. Click on the Console tab if neccesary
  3. Click on the Create devices link in the main pane
  4. Set the Description to the friendly name you wish to use within Cacti – E.G. Openfiler Server
  5. Set the Hostname to the FQDN if DNS is configured or the IP Address of the server
  6. Select the Generic SNMP-enabled Host template
  7. Set the SNMP version to Version 2
  8. Set the community string to the required string for your infrastructure – E.G. public
  9. Set the Downed device detection method to Ping and SNMP
  10. Scroll down to the bottom of the page and click on the Save button
  11. In the Devices list click on the device name and scroll down to the bottom of the page
  12. Confirm that at the top of the page that the general SNMP informatio is displayed for the server

Associate data queries to the device

Once the device has been added to Cacti data queries need to be associated to it so that graphs can be produced.  To associate data queries to the device perform the following steps :-

  1. In the Devices list click on the device name and scroll down to the bottom of the page
  2. In the Associated data queries section change the Add data query drop down box to SNMP – Get Mounted Partitions
  3. Click on the Add button to add the new data query
  4. Once added the query will be shown with a status of Success [xx Items, x Rows] (The amount of Items and Rows will differ depending on how many partitions exist on the server)
  5. Change the Add data query drop down box to SNMP – Get Processor Information
  6. Click on the Add button to add the new data query
  7. Once added the query will be shown with a status of Success [x Items, x Rows] (The amount of Items and Rows will differ depending on how many CPU’s exist in the server)
  8. Change the Add data query drop down box to SNMP – Get Interface Statistics
  9. Click on the Add button to add the new data query
  10. Once added the query will be shown with a status of Success [x Items, x Rows] (The amount of Items and Rows will differ depending on how many network interfaces exist in the server)
  11. Click on the Save button to associate the queries to the device.

Create graphs for the device

The next step in configuring an Openfiler server for monitoring through Cacti is to add the graphs required.  To add new graphs for the Openfiler server perform the following steps :-

  1. In the Devices list click on the device name and scroll down to the bottom of the page
  2. Click on the Create graphs for this host
  3. The create devices page for the device will be shown and list all of the items which have been discovered on the server by the Date query names associated in the previous section
  4. In the SNMP – Get Mounted Partitiions section of the screen all the partitions mounted on the server will be listed including the root partition, swap partition, and physical memory.
  5. Enable the tick box on the right hand side of the screen next to each partition you wish to graph
  6. In the SNMP – Get Processor Information section of the screen all of the CPU’s installed in the server will be listed
  7. Enable the tick box on the right hand side of the screen next to each CPU
  8. In the SNMP – Get Interface Statistics section of the screen all of the network interfaces installed in the server will be listed identified by the IP address associated.
  9. Enable the tick box on the right hand side of the screen next to each network interface you wish to graph
  10. Change the graph type drop down box to In/Out Bytes with Total Bandwidth
  11. Click on the Create button to create the graphs