RAM Disk in Nagios XI

A large Nagios installation creates an enormous amount of disk activity. RAM Disk in Nagios XI can help cure this.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix Nagios related issues

In this context, we shall look into how to free an enormous amount of disk activity, by adding RAM disks to the local filesystem.

More information about Nagios XI and RAM Disk?

Although enough CPU power on a Nagios server is important, a hardware limitation to a Nagios system is disk I/O.

If the hard disk cannot keep up with the constant traffic flow, a large number of CPUs are going to wait for the disk in order to write new information to the disk.

This can cause check latencies to soar even though the CPU usage appears within a safe range.

Sometimes using creative file mounts on separate partitions or purchasing extremely fast disks for servers help.

Now you shall learn how to use a RAM disk to boost performance on a Nagios XI server.

Utilizing RAM Disk in Nagios XI

Along with utilizing RAM Disk in Nagios XI let us focus on various aspects of its disk activity.

1. Key Files That Affect Disk I/O

Now let us look at some of the key files that create disk activity on a Nagios install.


This file contains all the "live" information on the monitoring environment. They update every 10-20 seconds (as specified in nagios.cfg) with all current status information.


This file stores all object configuration data for Nagios. It only updates upon a restart of the Nagios process.

/usr/local/nagios/var/host-perfdata & service-perfdata

These files may be in a different location for Core install. However, they function as an intermediary file for PNP’s NPCD daemon that processes performance data results. These files update about every 10-15 seconds.


This directory tree acts as a dropbox for all incoming check results. The disk activity is almost constant since both Nagios and NPCD continually creates result files.


These log-files are worth mentioning. Minimize all unnecessary logging, particularly with performance data processing.

We can minimize logging by editing: /usr/local/nagios/etc/pnp/npcd.cfg and /usr/local/nagios/etc/pnp/process_perfdata.cfg, and setting the log level to 0.

2. Automatic RAM Disk Installation

The easiest way to install RAM disk on the Nagios XI is to use install_ramdisk.sh script. We establish a terminal session to Nagios XI server as the root user and execute:

# cd /tmp
# wget https://assets.nagios.com/downloads/nagiosxi/scripts/install_ramdisk.sh
# chmod +x install_ramdisk.sh
# ./install_ramdisk.sh

The script will prompt for the size of the RAM Disk.

The install_ramdisk.sh script works for the following operating systems:

Red Hat Enterprise Linux (RHEL), CentOS, Oracle Linux

◦ 6.x 32-bit and 64-bit

◦ 7.x 64-bit


◦ 8.x 32-bit and 64-bit

◦ 9.x 32-bit and 64-bit


◦ All active Long Term Support (TLS)

◦ 32-bit and 64-bit

If we have an older distribution, we need to follow the manual install instructions. The same is valid when we have a "non-standard" Nagios XI instance or if we want to set up the RAM disk in a "non-default" location.

3. Manual RAM Disk Installation

This should only be followed if using the install_ramdisk.sh script is not possible.

Initially, we need to determine the size of the RAM disk. We can determine the recommended size of the RAM disk based on the total number and hosts and services that we are monitoring.

Total Number of Hosts + Services              RAM Disk Size

Less than 1000                                                  100 MB

1000 to 5000                                                      300 MB

More than 5000                                                500 MB

It is always a good idea to use a higher number than the “recommended size” in order to give some leeway and allow for growth.

[Need help with Server Monitoring? We are available 24*7]

INIT or SYSTEMD and RAM Disk in Nagios XI

The method we use to implement RAM disk is different on different OS versions due to how services are controlled in the back-end.

Let us look in detail at the steps depending on our OS version.

Each method requires us to establish a terminal session to the Nagios XI server as a root user to complete these steps.


a) Create a RAM Disk Directory

We execute these commands to create the base directory:

# mkdir /var/nagiosramdisk/
# chown -R nagios.nagios /var/nagiosramdisk

b) Editing INIT Files

The /etc/init.d/nagios script should have the following few lines added to it (around line 69):

if test -f /etc/sysconfig/nagios; then

. /etc/sysconfig/nagios

If these lines are missing, we add them to the top of the /etc/init.d/nagios file below the comments.

Then we create a file called nagios in the /etc/sysconfig/ directory and set permissions:

# mkdir -p /etc/sysconfig
# cd /etc/sysconfig/
# touch nagios
# chown nagios:nagios nagios
# chmod 775 nagios

Next, we open the nagios file in vi:

# vi nagios

We add the following lines:

if [ “`mount |grep “${RAMDISK_DIR} type tmpfs”`”X == “X” ]; then
mount -t tmpfs -o size=${RAMDISK_SIZE}m tmpfs ${RAMDISK_DIR}
mkdir -p -m 775 ${RAMDISK_DIR} ${RAMDISK_DIR}/tmp ${RAMDISK_DIR}/spool
${RAMDISK_DIR}/spool/checkresults ${RAMDISK_DIR}/spool/xidpe ${RAMDISK_DIR}/spool/perfdata
chown -R nagios:nagios ${RAMDISK_DIR}

The command starting with mkdir and ending with perfdata is all on one line

Finally, save, and close the file.


a) Create RAM Disk Directory

We execute these commands to create the base directory:

# mkdir /var/nagiosramdisk/
# chown -R nagios.nagios /var/nagiosramdisk

b) Create SYSTEMD Service

The following steps will create a ramdisk.service file, the location of this file differs depending on our OS. We change into the correct directory as per:

RHEL, CentOS, Oracle Linux

◦ cd /usr/lib/systemd/system/

Ubuntu, Debian

◦ cd /lib/systemd/system/

To create the ramdisk.service file and set permissions:

# touch ramdisk.service
# chown nagios:nagios ramdisk.service
# chmod 775 ramdisk.service

Then we open the ramdisk.service file in vi:

# vi ramdisk.service

Next, we need to add lines on the following page:

ExecStartPre=/usr/bin/mkdir -p -m 775 /var/nagiosramdisk
ExecStartPre=/usr/bin/mount -t tmpfs -o size=100m tmpfs /var/nagiosramdisk
ExecStartPre=/usr/bin/mkdir -p -m 775 /var/nagiosramdisk/tmp
/var/nagiosramdisk/spool /var/nagiosramdisk/spool/checkresults
/var/nagiosramdisk/spool/xidpe /var/nagiosramdisk/spool/perfdata
ExecStart=/usr/bin/chown -R nagios:nagios /var/nagiosramdisk

The third instance of the ExecStartPre line ending with perfdata is all on one line

Finally, we save and close the file.

Then we need to issue this command for the OS to detect the new service:

# systemctl daemon-reload
# systemctl enable ramdisk.service

iii. Editing Configuration Files to utilize RAM Disk in Nagios XI

Furthermore, Let us see how our Support Techs edit the configuration files.


First we open up the /usr/local/nagios/etc/nagios.cfg file in vi:

# vi /usr/local/nagios/etc/nagios.cfg

Then we update the following lines:


Once done, we save and close the file.


Initially we open /usr/local/nrdp/server/config.inc.php in vi:

# vi /usr/local/nrdp/server/config.inc.php

Then we update the following line:


Finally, save and close the file.


To begin with, we open /usr/local/nagiosxi/html/config.inc.php in vi:

# vi /usr/local/nagiosxi/html/config.inc.php

Then we update the following lines:

$cfg[‘xidpe_dir’] = ‘/var/nagiosramdisk/spool/xidpe/’;
$cfg[‘perfdata_spool’] = ‘/var/nagiosramdisk/spool/perfdata/’;

In the end, we save and close the file.


First we open up /usr/local/nagios/etc/pnp/npcd.cfg in vi:

# vi /usr/local/nagios/etc/pnp/npcd.cfg

Next, we update the following line:

perfdata_spool_dir = /var/nagiosramdisk/spool/perfdata/

When finished, save and close the file.


Initially, we open up /usr/local/nagiosmobile/include.inc.php in vi:

# vi /usr/local/nagiosmobile/include.inc.php

Then we update the following lines:

$STATUS_FILE = “/var/nagiosramdisk/status.dat”;
$OBJECTS_FILE = “/var/nagiosramdisk/objects.cache”;

Once done, we save and close the file.

[Confused with the Linux Software Configuration? We’d be happy to assist]

Update Performance Data Commands

We login to Nagios XI and navigate to Configure > Core Config Manager > Commands > >_ Commands.

In the search field, we type file-bulk and press Enter.

The screen will update with the two commands process-host-perfdata-file-bulk and processservice-perfdata-file-bulk.

Make a copy of the existing commands, prior to modifying them. Leave the “old” commands (copies) inactive. This can be helpful if we need to go back.

Both of these commands need to be updated with the new directory locations as follows:


# /bin/mv /var/nagiosramdisk/host-perfdata /var/nagiosramdisk/spool/xidpe/$TIMET$.perfdata.host


# /bin/mv /var/nagiosramdisk/service-perfdata /var/nagiosramdisk/spool/xidpe/$TIMET$.perfdata.service

After making these changes we click the Apply Configuration button.

It is possible that the Apply Configuration will fail the first time. Simply click the Try Again button and it will succeed the second time.

Restart Services

After making all of these changes, we execute the following commands in the terminal session:


# service nagios restart
# service httpd restart
# service npcd restart


# systemctl restart nagios.service
# systemctl restart npcd.service

RHEL, CentOS, Oracle Linux

◦ systemctl restart httpd.service

Ubuntu, Debian

◦ systemctl restart apache2.service

[Can't figure out how to utilize RAM Disk in Nagios XI? We are here for you!]


This article will guide you on how to make use of a RAM disk can provide huge performance improvements on larger systems or any system where check latencies are greater than 2 seconds.