Minimizing Nagios write?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Minimizing Nagios write?

Post by t3dus »

I put Nagios Core 4.3.4 back on my Raspberry PI but and set the logs to write to memory.

My question is how do I prevent Nagios from writing to the drive constantly? I see that /usr/local/nagios/bin/nagios -d /user/local/nagios/etc/nagios.cfg is writing every 5 seconds or so.

I'm trying to maximize my SD card life. Last time my SD card only lasted 3 months cuz nagios killed it off.

Btw I'm using a Class 10 32gb Sandisk Ultra 95mb/s card so they aren't exactly super cheap.
Attachments
nagios.PNG
nagios.PNG (5.43 KiB) Viewed 1805 times
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Minimizing Nagios write?

Post by mcapra »

Short list of possible ways to alleviate this depending on specifically what is causing the frequent "disk" writes, in order of "difficulty":
  • Fiddle with the status_update_interval setting to write status.dat out less frequently.
  • Use a ramdisk for status.dat and the checkresults file.
  • Pipe logs to /dev/null, leverage the use_syslog directive to ship all Nagios logs to a syslog aggregator (this will require some rsyslog/syslog-ng knowledge). Share the resulting syslog aggregator paths as a netshare and mount to /usr/local/nagios/var/archives on the Pis. Or just don't persist logs at all and pipe everything to /dev/null (this breaks historical reporting). Or stuff them in memory as you have and not have persistence if the Pi dies.
There's a handful of places in the main nagios.cfg file to adjust what gets written and to where:

Code: Select all

# CHECK RESULT PATH
# This is directory where Nagios stores the results of host and
# service checks that have not yet been processed.
#
# Note: Make sure that only one instance of Nagios has access
# to this directory!

check_result_path=/usr/local/nagios/var/spool/checkresults



# STATUS FILE
# This is where the current status of all monitored services and
# hosts is stored.  Its contents are read and processed by the CGIs.
# The contents of the status file are deleted every time Nagios
#  restarts.

status_file=/usr/local/nagios/var/status.dat



# STATUS FILE UPDATE INTERVAL
# This option determines the frequency (in seconds) that
# Nagios will periodically dump program, host, and
# service status data.

status_update_interval=10



# DEBUG VERBOSITY
# This option determines how verbose the debug log out will be.
# Values: 0 = Brief output
#         1 = More detailed
#         2 = Very detailed

debug_verbosity=1



# DEBUG FILE
# This option determines where Nagios should write debugging information.

debug_file=/usr/local/nagios/var/nagios.debug


# LOG ARCHIVE PATH
# This is the directory where archived (rotated) log files should be
# placed (assuming you've chosen to do log rotation).

log_archive_path=/usr/local/nagios/var/archives



# LOGGING OPTIONS
# If you want messages logged to the syslog facility, as well as the
# Nagios log file set this option to 1.  If not, set it to 0.

use_syslog=1
I think you could get Nagios Core to keep *almost* everything in memory with clever use of a ramdisk. This can make startup a bit of a PITA, but if your only issues around stability is the cards dying I think this is a fair trade.
Former Nagios employee
https://www.mcapra.com/
User avatar
t3dus
Posts: 161
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA
Contact:

Re: Minimizing Nagios write?

Post by t3dus »

I have no problem manually starting services when the PI boots. The PI is on a UPS so it will rarely if ever be turned off. I'd prefer to write as much as I can to memory. I don't need historical data, this is more of a "in the now current state" monitoring that I care about.

Reason for using a PI vs one of my servers that are currently collecting dust is because I'm a cheap skate. Trying to save power and the PI is super cheap to run.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Minimizing Nagios write?

Post by cdienger »

Thanks for the excellent post @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked