Improve Nagios Performance with TempFS


This post is in the category: Guides

Posts here are mostly step-by-step guides on how to replicate something I have set up in the past. Read over my About page to see how I show commands/output and read the disclaimer.


Converting a couple directories to tmpfs will significantly reduce disk I/O by Nagios for status updates.

This article assumes you compiled and installed Nagios 4.x (or 3.x) from source.

Stop Nagios and remove all checks still waiting to process.

[root]$ service nagios stop
[root]$ rm /usr/local/nagios/var/spool/checkresults/*

We need to create a separate directory to hold objects.cache and status.dat.

[root]$ cd /usr/local/nagios/var
[root]$ mkdir cache
[root]$ chown nagios:nagios cache
[root]$ mv objects.cache cache/

Update the configuration file to point to the new directory for the moved files.

[root]$ vim /usr/local/nagios/etc/nagios.cfg

...
objectcachefile=/usr/local/nagios/var/cache/objects.cache
...
status_file=/usr/local/nagios/var/cache/status.dat
...

Add these two mount points.

[root]$ vim /etc/fstab

tmpfs /usr/local/nagios/var/cache tmpfs defaults,noexec,nosuid,size=128m    0   0
tmpfs /usr/local/nagios/var/spool/checkresults tmpfs defaults,noexec,nosuid,size=128m   0   0

Mount the new filesystems.

[root]$ mount -a

Make sure the new filesystems are showing up.

[root]$ df
Filesystem                   1K-blocks    Used Available Use% Mounted on
/dev/mapper/system-root       30165036 3985844  24646880  14% /
udev                            500464       4    500460   1% /dev
tmpfs                           203824     540    203284   1% /run
none                              5120       0      5120   0% /run/lock
none                            509552       0    509552   0% /run/shm
tmpfs                           131072    6780    124292   6% /usr/local/nagios/var/cache
tmpfs                           131072     292    130780   1% /usr/local/nagios/var/spool/checkresults
/dev/sda1                       233191   94579    126171  43% /boot

Now we can start Nagios.

[root]$ service nagios start
This entry was posted in Guides and tagged on by .

About Andrew Wells

I have been developing on the LAMP stack since about 2006. I run Ubuntu XFCE on my desktop and have a history of managing Ubuntu and CentOS servers. I code web applications mostly in PHP but have experience with other languages as well.

When I’m not working, I can be found working in my home lab or out snowboarding, hiking, camping, or biking depending on the season.

Leave a Reply

Your email address will not be published. Required fields are marked *