Improve Nagios Performance -using RAMDISK




If you are using Nagios to monitor few hundred hosts / services. You may notice increasing disk IO.
To keep nagios running as fresh installed, you can use ramdisk / tmpfs for files created during checks.

Run following commands once.

mkdir /var/ramdrive
rm -rf /usr/local/nagios/var/spool/checkresults/
Change location for check results</strong>
Enter followings in /etc/rc.local
<code>mke2fs -m 0 /dev/ram0
mount /dev/ram0 /var/ramdrive
ln -s /var/ramdrive/checkresults/ /usr/local/nagios/var/spool/checkresults/
mkdir /var/ramdrive/checkresults
chown nagios: /var/ramdrive -R
service nagios start

Change location for objects.cache & status.dat

vi /usr/local/nagios/etc/nagios.cfg
#change from 
object_cache_file=/usr/local/nagios/var/objects.cache
#to 
object_cache_file=/var/ramdrive/objects.cache
 
#change from 
status_file=/usr/local/nagios/var/status.dat
#to
status_file=/var/ramdrive/status.dat

Once you are through with above changes, run /etc/rc.local & service nagios restart.

If you wish to increase size of ramdisk append ramdisk_size=50000 in grub.conf for running kernel.

OR you may use tmpfs, which is convenient

mount -t tmpfs -o size=51M,mode=0755 tmpfs /var/ramdrive

——————————————————————————————————————————-

Update 2012-02-07
You can also make relevant changes in nagios.conf file to use ramdrive.

mke2fs -m 0 /dev/ram0
mount /dev/ram0 /var/ramdrive
mkdir -p /var/ramdrive/spool/checkresults
mkdir -p /var/ramdrive/spool/perfdata/
 
chown nagios: /var/centreon_temp/ -R
chown nagios: /var/ramdrive -R

nagios.cfg changes

/usr/local/nagios/etc/nagios.cfg
object_cache_file=/var/ramdrive/objects.cache
status_file=/var/ramdrive/status.dat
check_result_path=/var/ramdrive/spool/checkresults
#below is for pnp4nagios
service_perfdata_file=/var/ramdrive/spool/perfdata/service-perfdata
host_perfdata_file=/var/ramdrive/spool/perfdata/host-perfdata

npcd.cfg changes

/usr/local/nagios/etc/pnp/npcd.cfg
perfdata_spool_dir = /var/ramdisk/spool/perfdata/
perfdata_file = /var/ramdisk/spool/perfdata/perfdata.dump


if you find any missing point in here, please let us know in comment section or tweet us at @linuxreaders. To get more articles like this, subscribe to our RSS feeds / Mails.
Read 240 articles by
  • ian orszaczki

    Nice article. A would suggest a few more things to make this setup survive a boot. Add the mounted filesystem to /etc/fstab and add some code to the nagios start script to create the checkresults directory with the correct ownership and permissions.

Trending Posts