Page 2 of 2

Re: RAMDISK Config lost after NagiosXI upgrade

Posted: Mon Mar 16, 2015 11:02 am
by cmerchant
Fred, sorry I didn't want to give an answer without checking to see if the new init script would have all of the parameters that your old config needed.
The ramdisk code in the new init script does not have all of the directories created that you have defined. I would still add that code back into your script.

I have found nothing in any document that describes this secret incantation, and hopefully in the next release of Nagios there will be updated documentation as well as streamlining the ramdisk/ tmpfs process. You still need to have the nagios.cfg file to match the ramdisk directories in order to utilize the ramdisk.

I would recommend to anyone who has modified the nagios init script /etc/init.d/nagios, to make a backup copy of the script before proceeding:

Code: Select all

cp /etc/init.d/nagios /etc/nagios.init.orig
Copy over the nagios.init script from the install directory into /etc/init.d/nagios (overwriting the nagios init script)

Code: Select all

cp -r /tmp/nagiosxi/subcomponents/nagioscore/mods/nagios.init /etc/init.d/nagios
Edit the new nagios init script: (to add the your old ramdisk dir's back)

Code: Select all

vi /etc/init.d/nagios

Code: Select all

change the following:
if test "$USE_RAMDISK" -ne 0 && test "$RAMDISK_SIZE"X != "X"; then
        ramdisk=`mount |grep "${RAMDISK_DIR} type tmpfs"`
        if [ "$ramdisk"X == "X" ]; then
                mkdir -p -m 0755 ${RAMDISK_DIR}
                mount -t tmpfs -o size=${RAMDISK_SIZE}m tmpfs ${RAMDISK_DIR}
                mkdir -p -m 0755 ${RAMDISK_DIR}/checkresults
                chown -R $NagiosUser:$NagiosGroup ${RAMDISK_DIR}
        fi
fi
to:

Code: Select all

if test "$USE_RAMDISK" -ne 0 && test "$RAMDISK_SIZE"X != "X"; then
        ramdisk=`mount |grep "${RAMDISK_DIR} type tmpfs"`
        if [ "$ramdisk"X == "X" ]; then
                mkdir -p -m 0755 ${RAMDISK_DIR}
                mount -t tmpfs -o size=${RAMDISK_SIZE}m tmpfs ${RAMDISK_DIR}
               mkdir -p -m 775 /var/nagiosramdisk
               mkdir -p -m 775  ${RAMDISK_DIR}/tmp
               mkdir -p -m 775  ${RAMDISK_DIR}/spool
               mkdir -p -m 775  ${RAMDISK_DIR}/spool/checkresults
               chown -R $NagiosUser:$NagiosGroup ${RAMDISK_DIR}
        fi
fi
I edited the /etc/sysconfig/nagios file (created one, if it didn't exist before)

Code: Select all

vi /etc/sysconfig/nagios
and I added the following lines:

Code: Select all

export USE_RAMDISK=1
export RAMDISK_DIR=/var/nagiosramdisk
export RAMDISK_SIZE=50
saved the file and then restarted nagios

Code: Select all

service nagios restart

Re: RAMDISK Config lost after NagiosXI upgrade

Posted: Mon Mar 16, 2015 5:04 pm
by tbyrne
I don't know if this helps but I am running snmptt to capture trap messages and I needed a /ramdisk/spool/snmptt directory with permissions for snmptt.
I just put all of the commands to create the directories and setup permissions in to a script and put it in /etc/init.d with a link in to /etc/rc3.d/S30ramdisk
now my directories are created regardless of any updates.

#! /bin/sh
# /etc/init.d/ramdisk
#

echo "Creating directories on ramdisk"
mkdir -p -m 775 /ramdisk/tmp
mkdir -p -m 775 /ramdisk/spool
mkdir -p -m 775 /ramdisk/spool/checkresults
mkdir -p -m 775 /ramdisk/spool/perfdata
mkdir -p -m 775 /ramdisk/spool/xidpe
chown nagios.nagios /ramdisk
chown nagios.nagios /ramdisk/tmp
chown nagios.nagios /ramdisk/spool
chown nagios.nagios /ramdisk/spool/checkresults
chown nagios.nagios /ramdisk/spool/perfdata
chown nagios.nagios /ramdisk/spool/xidpe
mkdir -p -m 775 /ramdisk/spool/snmptt
chown snmptt.snmptt /ramdisk/spool/snmptt
#echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk directories created >> /var/log/ramdisk.log
exit 0

Re: RAMDISK Config lost after NagiosXI upgrade

Posted: Mon Mar 16, 2015 5:10 pm
by ssax
Fred Kroeger, let us know if you have any questions on cmerchant's information.

Re: RAMDISK Config lost after NagiosXI upgrade

Posted: Mon Mar 16, 2015 8:02 pm
by Fred Kroeger
Thanks all - I will ignore the RAMDISK configs for now in the init.d file as it doesn't appear to quite ready....
and just keep adding back my settings for now if they get deleted (from my saved backup copy of course!).

Thanks for your input tbryne - the benefit of having the RAMDisk setup in the nagios init.d file is that the RAMDisk configs always get recreated if required when you restart the Nagios service.
However , I like your idea of using a RAMDisk for the trap messages - certainly takes the I/O load off the VM virtual disks.

You can close this as I eagerly await the updated RAMDisk doco - regards... Fred

Re: RAMDISK Config lost after NagiosXI upgrade

Posted: Tue Mar 17, 2015 6:22 am
by cmerchant
Thanks Fred for your feedback. I will go ahead and close this topic for now.